DynamoVisualProgramming.ZeroTouchLibrary by Autodesk

<PackageReference Include="DynamoVisualProgramming.ZeroTouchLibrary" Version="3.3.0-beta5725" />

 CoordinateSystem

using Autodesk.DesignScript.Geometry.Properties; using Autodesk.DesignScript.Interfaces; using Autodesk.DesignScript.Runtime; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; namespace Autodesk.DesignScript.Geometry { public class CoordinateSystem : DesignScriptEntity { internal ICoordinateSystemEntity CoordinateSystemEntity => HostImpl as ICoordinateSystemEntity; public bool IsSingular => CoordinateSystemEntity.get_IsSingular(); public bool IsScaledOrtho => CoordinateSystemEntity.get_IsScaledOrtho(); public bool IsUniscaledOrtho => CoordinateSystemEntity.get_IsUniscaledOrtho(); public double Determinant => CoordinateSystemEntity.get_Determinant(); public Point Origin => Point.Wrap(CoordinateSystemEntity.get_Origin(), true); public Vector XAxis => Vector.Wrap(CoordinateSystemEntity.get_XAxis().Scale(1 / DesignScriptEntity.scaleFactor), true); public Vector YAxis => Vector.Wrap(CoordinateSystemEntity.get_YAxis().Scale(1 / DesignScriptEntity.scaleFactor), true); public Vector ZAxis => Vector.Wrap(CoordinateSystemEntity.get_ZAxis().Scale(1 / DesignScriptEntity.scaleFactor), true); public double XScaleFactor => CoordinateSystemEntity.get_XScaleFactor(); public double YScaleFactor => CoordinateSystemEntity.get_YScaleFactor(); public double ZScaleFactor => CoordinateSystemEntity.get_ZScaleFactor(); public Plane XYPlane => Plane.Wrap(CoordinateSystemEntity.get_XYPlane(), true); public Plane YZPlane => Plane.Wrap(CoordinateSystemEntity.get_YZPlane(), true); public Plane ZXPlane => Plane.Wrap(CoordinateSystemEntity.get_ZXPlane(), true); internal CoordinateSystem(ICoordinateSystemEntity host, bool persist) : base(host, persist) { } public override string ToString() { string[] obj = new string[15] { "CoordinateSystem(Origin = ", Origin?.ToString(), ", XAxis = ", XAxis?.ToString(), ", YAxis = ", YAxis?.ToString(), ", ZAxis = ", ZAxis?.ToString(), ", XScaleFactor = ", null, null, null, null, null, null }; double num = XScaleFactor; obj[9] = num.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture); obj[10] = ", YScaleFactor = "; num = YScaleFactor; obj[11] = num.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture); obj[12] = ", ZScaleFactor = "; num = ZScaleFactor; obj[13] = num.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture); obj[14] = ")"; return string.Concat(obj); } internal static CoordinateSystem Wrap(ICoordinateSystemEntity host, bool persist = true) { if (host == null) return null; return new CoordinateSystem(host, persist); } internal static CoordinateSystem[] Wrap(ICoordinateSystemEntity[] hosts, bool persist = true) { return (from x in hosts select Wrap(x, persist)).ToArray(); } internal static ICoordinateSystemEntity[] Unwrap(CoordinateSystem[] o) { return o.Select(Unwrap).ToArray(); } internal static ICoordinateSystemEntity Unwrap(CoordinateSystem o) { return o.CoordinateSystemEntity; } public static CoordinateSystem Identity() { return Wrap(HostFactory.Factory.CoordinateSystemIdentity(), true); } [Obsolete("This method is deprecated and will be removed in a future version of Dynamo.")] [IsObsolete("coordinatesystem_bymatrix_deprecated", typeof(Resources))] [IsVisibleInDynamoLibrary(false)] public static CoordinateSystem ByMatrix(double[] matrix) { return Wrap(HostFactory.Factory.CoordinateSystemByMatrix(matrix), true); } public static CoordinateSystem ByOrigin(double x = 0, double y = 0) { DesignScriptEntity.CheckArgsForAsmExtents(new List<double> { x, y }); x /= DesignScriptEntity.scaleFactor; y /= DesignScriptEntity.scaleFactor; return Wrap(HostFactory.Factory.CoordinateSystemByOrigin(x, y), true); } public static CoordinateSystem ByOrigin(double x = 0, double y = 0, double z = 0) { DesignScriptEntity.CheckArgsForAsmExtents(new List<double> { x, y, z }); x /= DesignScriptEntity.scaleFactor; y /= DesignScriptEntity.scaleFactor; z /= DesignScriptEntity.scaleFactor; return Wrap(HostFactory.Factory.CoordinateSystemByOrigin(x, y, z), true); } public static CoordinateSystem ByOrigin([DefaultArgument("Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0)")] Point origin) { return Wrap(HostFactory.Factory.CoordinateSystemByOrigin(Point.Unwrap(origin)), true); } public static CoordinateSystem ByPlane([DefaultArgument("Autodesk.DesignScript.Geometry.Plane.XY()")] Plane plane) { return Wrap(HostFactory.Factory.CoordinateSystemByPlane(Plane.Unwrap(plane)), true); } public static CoordinateSystem ByOriginVectors([DefaultArgument("Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0)")] Point origin, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(1, 0, 0)")] Vector xAxis, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0, 1, 0)")] Vector yAxis) { return Wrap(HostFactory.Factory.CoordinateSystemByOriginVectors(Point.Unwrap(origin), Vector.Unwrap(xAxis), Vector.Unwrap(yAxis)), true); } public static CoordinateSystem ByOriginVectors([DefaultArgument("Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0)")] Point origin, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(1, 0, 0)")] Vector xAxis, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0, 1, 0)")] Vector yAxis, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0, 0, 1)")] Vector zAxis) { return Wrap(HostFactory.Factory.CoordinateSystemByOriginVectors(Point.Unwrap(origin), Vector.Unwrap(xAxis), Vector.Unwrap(yAxis), Vector.Unwrap(zAxis)), true); } public static CoordinateSystem ByCylindricalCoordinates([DefaultArgument("Autodesk.DesignScript.Geometry.CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem cs, double radius = 0, double theta = 0, double height = 0) { DesignScriptEntity.CheckArgsForAsmExtents(new List<double> { radius, height }); radius /= DesignScriptEntity.scaleFactor; height /= DesignScriptEntity.scaleFactor; return Wrap(HostFactory.Factory.CoordinateSystemByCylindricalCoordinates(Unwrap(cs), radius, theta, height), true); } public static CoordinateSystem BySphericalCoordinates([DefaultArgument("Autodesk.DesignScript.Geometry.CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem cs, double radius = 0, double theta = 0, double phi = 0) { DesignScriptEntity.CheckArgsForAsmExtents(new List<double> { radius }); radius /= DesignScriptEntity.scaleFactor; return Wrap(HostFactory.Factory.CoordinateSystemBySphericalCoordinates(Unwrap(cs), radius, theta, phi), true); } public CoordinateSystem Inverse() { return Wrap(CoordinateSystemEntity.Inverse(), true); } public CoordinateSystem Mirror(Plane mirrorPlane) { ICoordinateSystemEntity host = CoordinateSystemEntity.Mirror(mirrorPlane.PlaneEntity) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem PostMultiplyBy(CoordinateSystem other) { return Wrap(CoordinateSystemEntity.PostMultiplyBy(Unwrap(other)), true); } public CoordinateSystem PreMultiplyBy(CoordinateSystem other) { return Wrap(CoordinateSystemEntity.PreMultiplyBy(Unwrap(other)), true); } public Vector ScaleFactor() { return Vector.Wrap(CoordinateSystemEntity.ScaleFactor().Scale(1 / DesignScriptEntity.scaleFactor), true); } public bool IsEqualTo(CoordinateSystem other) { return CoordinateSystemEntity.IsEqualTo(Unwrap(other)); } public CoordinateSystem Translate(double xTranslation = 0, double yTranslation = 0, double zTranslation = 0) { DesignScriptEntity.CheckArgsForAsmExtents(new List<double> { xTranslation, yTranslation, zTranslation }); xTranslation /= DesignScriptEntity.scaleFactor; yTranslation /= DesignScriptEntity.scaleFactor; zTranslation /= DesignScriptEntity.scaleFactor; ICoordinateSystemEntity host = CoordinateSystemEntity.Translate(xTranslation, yTranslation, zTranslation) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Translate(Vector direction) { ICoordinateSystemEntity host = CoordinateSystemEntity.Translate(direction.VectorEntity) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Translate(Vector direction, double distance = 0) { DesignScriptEntity.CheckArgsForAsmExtents(new List<double> { distance }); distance /= DesignScriptEntity.scaleFactor; ICoordinateSystemEntity host = CoordinateSystemEntity.Translate(direction.VectorEntity, distance) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Transform(CoordinateSystem coordinateSystem) { ICoordinateSystemEntity host = CoordinateSystemEntity.Transform(coordinateSystem.CoordinateSystemEntity) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Transform(CoordinateSystem fromCoordinateSystem, CoordinateSystem contextCoordinateSystem) { ICoordinateSystemEntity host = CoordinateSystemEntity.TransformFromTo(fromCoordinateSystem.CoordinateSystemEntity, contextCoordinateSystem.CoordinateSystemEntity) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Rotate(Point origin, Vector axis, double degrees = 0) { ICoordinateSystemEntity host = CoordinateSystemEntity.Rotate(origin.PointEntity, axis.VectorEntity, degrees) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Rotate(Plane plane, double degrees = 0) { ICoordinateSystemEntity host = CoordinateSystemEntity.Rotate(plane.PlaneEntity, degrees) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Scale(double amount = 1) { ICoordinateSystemEntity host = CoordinateSystemEntity.Scale(amount) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Scale(double xamount = 1, double yamount = 1, double zamount = 1) { ICoordinateSystemEntity host = CoordinateSystemEntity.Scale(xamount, yamount, zamount) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Scale(Plane plane, double xamount = 1, double yamount = 1, double zamount = 1) { ICoordinateSystemEntity host = CoordinateSystemEntity.Scale(Plane.Unwrap(plane), xamount, yamount, zamount) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Scale(Point basePoint, Point from, Point to) { ICoordinateSystemEntity host = CoordinateSystemEntity.Scale(basePoint.PointEntity, from.PointEntity, to.PointEntity) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Scale1D(Point basePoint, Point from, Point to) { ICoordinateSystemEntity host = CoordinateSystemEntity.Scale1D(basePoint.PointEntity, from.PointEntity, to.PointEntity) as ICoordinateSystemEntity; return Wrap(host, true); } public CoordinateSystem Scale2D(Plane basePlane, Point from, Point to) { ICoordinateSystemEntity host = CoordinateSystemEntity.Scale2D(basePlane.PlaneEntity, from.PointEntity, to.PointEntity) as ICoordinateSystemEntity; return Wrap(host, true); } [SupressImportIntoVM] public static CoordinateSystem FromJson(string json) { return Wrap(HostFactory.Factory.CoordinateSystemFromJson(json, DesignScriptEntity.scaleFactor), true); } [SupressImportIntoVM] public string ToJson() { return HostImpl.ToJson(DesignScriptEntity.scaleFactor); } } }