DynamoVisualProgramming.ZeroTouchLibrary by Autodesk

<PackageReference Include="DynamoVisualProgramming.ZeroTouchLibrary" Version="4.2.0-beta5413" />

 CoordinateSystem

using Autodesk.DesignScript.Geometry.Properties; using Autodesk.DesignScript.Interfaces; using Autodesk.DesignScript.Runtime; using ProtoGeometryGenerator; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Autodesk.DesignScript.Geometry { [GenerateFromInterface(typeof(ICoordinateSystemEntity), typeof(IGeometryFactory), new Type[] { typeof(ITransformableEntity) })] 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()); [Scaling()] public Vector XAxis { get { return Vector.Wrap(CoordinateSystemEntity.get_XAxis().Scale(1 / DesignScriptEntity.scaleFactor)); } } [Scaling()] public Vector YAxis { get { return Vector.Wrap(CoordinateSystemEntity.get_YAxis().Scale(1 / DesignScriptEntity.scaleFactor)); } } [Scaling()] public Vector ZAxis { get { return Vector.Wrap(CoordinateSystemEntity.get_ZAxis().Scale(1 / DesignScriptEntity.scaleFactor)); } } 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()); public Plane YZPlane => Plane.Wrap(CoordinateSystemEntity.get_YZPlane()); public Plane ZXPlane => Plane.Wrap(CoordinateSystemEntity.get_ZXPlane()); private static CoordinateSystem Wrap(ITransformableEntity coordinateSystem) { return CoordinateSystem.Wrap(coordinateSystem as ICoordinateSystemEntity); } [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 CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemByMatrix(matrix)); } [SupressImportIntoVM] [GenerateShadowing("FromJson", new Type[] { typeof(string), typeof(double) })] public static CoordinateSystem FromJson(string json) { return CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemFromJson(json, DesignScriptEntity.scaleFactor)); } [SupressImportIntoVM] public string ToJson() { return HostImpl.ToJson(DesignScriptEntity.scaleFactor); } internal CoordinateSystem(ICoordinateSystemEntity host) : base(host) { } public CoordinateSystem Inverse() { return CoordinateSystem.Wrap(CoordinateSystemEntity.Inverse()); } public CoordinateSystem PostMultiplyBy(CoordinateSystem other) { return CoordinateSystem.Wrap(CoordinateSystemEntity.PostMultiplyBy(Unwrap(other))); } public CoordinateSystem PreMultiplyBy(CoordinateSystem other) { return CoordinateSystem.Wrap(CoordinateSystemEntity.PreMultiplyBy(Unwrap(other))); } [Scaling()] public Vector ScaleFactor() { return Vector.Wrap(CoordinateSystemEntity.ScaleFactor()).Scale(1 / DesignScriptEntity.scaleFactor); } public bool IsEqualTo(CoordinateSystem other) { return CoordinateSystemEntity.IsEqualTo(Unwrap(other)); } public CoordinateSystem Translate([Scaling()] double xTranslation = 0, [Scaling()] double yTranslation = 0, [Scaling()] double zTranslation = 0) { DesignScriptEntity.CheckArgsForAsmExtents(xTranslation, yTranslation, zTranslation); return CoordinateSystem.Wrap(CoordinateSystemEntity.Translate(xTranslation / DesignScriptEntity.scaleFactor, yTranslation / DesignScriptEntity.scaleFactor, zTranslation / DesignScriptEntity.scaleFactor)); } public CoordinateSystem Translate(Vector direction) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Translate(Vector.Unwrap(direction))); } public CoordinateSystem Translate(Vector direction, [Scaling()] double distance = 0) { DesignScriptEntity.CheckArgsForAsmExtents(distance); return CoordinateSystem.Wrap(CoordinateSystemEntity.Translate(Vector.Unwrap(direction), distance / DesignScriptEntity.scaleFactor)); } public CoordinateSystem Transform(CoordinateSystem coordinateSystem) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Transform(Unwrap(coordinateSystem))); } public CoordinateSystem Transform(CoordinateSystem targetCoordinateSystem, CoordinateSystem sourceCoordinateSystem) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Transform(Unwrap(targetCoordinateSystem), Unwrap(sourceCoordinateSystem))); } public CoordinateSystem Rotate(Point origin, Vector axis, double degrees = 0) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Rotate(Point.Unwrap(origin), Vector.Unwrap(axis), degrees)); } public CoordinateSystem Rotate(Plane basePlane, double degrees = 0) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Rotate(Plane.Unwrap(basePlane), degrees)); } public CoordinateSystem Scale(double amount = 1) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Scale(amount)); } public CoordinateSystem Scale(double xamount = 1, double yamount = 1, double zamount = 1) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Scale(xamount, yamount, zamount)); } public CoordinateSystem Scale(Plane plane, double xamount = 1, double yamount = 1, double zamount = 1) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Scale(Plane.Unwrap(plane), xamount, yamount, zamount)); } public CoordinateSystem Scale(Point basePoint, Point from, Point to) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Scale(Point.Unwrap(basePoint), Point.Unwrap(from), Point.Unwrap(to))); } public CoordinateSystem Scale1D(Point basePoint, Point from, Point to) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Scale1D(Point.Unwrap(basePoint), Point.Unwrap(from), Point.Unwrap(to))); } public CoordinateSystem Scale2D(Plane basePlane, Point from, Point to) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Scale2D(Plane.Unwrap(basePlane), Point.Unwrap(from), Point.Unwrap(to))); } public CoordinateSystem Mirror(Plane mirrorPlane) { return CoordinateSystem.Wrap(CoordinateSystemEntity.Mirror(Plane.Unwrap(mirrorPlane))); } public static CoordinateSystem Identity() { return CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemIdentity()); } public static CoordinateSystem ByOrigin([Scaling()] double x = 0, [Scaling()] double y = 0) { DesignScriptEntity.CheckArgsForAsmExtents(x, y); return CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemByOrigin(x / DesignScriptEntity.scaleFactor, y / DesignScriptEntity.scaleFactor)); } public static CoordinateSystem ByOrigin([Scaling()] double x = 0, [Scaling()] double y = 0, [Scaling()] double z = 0) { DesignScriptEntity.CheckArgsForAsmExtents(x, y, z); return CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemByOrigin(x / DesignScriptEntity.scaleFactor, y / DesignScriptEntity.scaleFactor, z / DesignScriptEntity.scaleFactor)); } public static CoordinateSystem ByOrigin([DefaultArgument("Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0)")] Point origin) { return CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemByOrigin(Point.Unwrap(origin))); } public static CoordinateSystem ByPlane([DefaultArgument("Autodesk.DesignScript.Geometry.Plane.XY()")] Plane plane) { return CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemByPlane(Plane.Unwrap(plane))); } 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 CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemByOriginVectors(Point.Unwrap(origin), Vector.Unwrap(xAxis), Vector.Unwrap(yAxis))); } 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 CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemByOriginVectors(Point.Unwrap(origin), Vector.Unwrap(xAxis), Vector.Unwrap(yAxis), Vector.Unwrap(zAxis))); } public static CoordinateSystem ByCylindricalCoordinates([DefaultArgument("Autodesk.DesignScript.Geometry.CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem cs, [Scaling()] double radius = 0, double theta = 0, [Scaling()] double height = 0) { DesignScriptEntity.CheckArgsForAsmExtents(radius, height); return CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemByCylindricalCoordinates(Unwrap(cs), radius / DesignScriptEntity.scaleFactor, theta, height / DesignScriptEntity.scaleFactor)); } public static CoordinateSystem BySphericalCoordinates([DefaultArgument("Autodesk.DesignScript.Geometry.CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem cs, [Scaling()] double radius = 0, double theta = 0, double phi = 0) { DesignScriptEntity.CheckArgsForAsmExtents(radius); return CoordinateSystem.Wrap(HostFactory.Factory.CoordinateSystemBySphericalCoordinates(Unwrap(cs), radius / DesignScriptEntity.scaleFactor, theta, phi)); } internal static CoordinateSystem Wrap(ICoordinateSystemEntity host) { if (host != null) return new CoordinateSystem(host); return null; } internal static CoordinateSystem[] Wrap(ICoordinateSystemEntity[] hosts) { return hosts.Select(Wrap).ToArray(); } internal static CoordinateSystem[][] Wrap(ICoordinateSystemEntity[][] hosts) { return hosts.Select(Wrap).ToArray(); } internal static ICoordinateSystemEntity Unwrap(CoordinateSystem o) { return o.CoordinateSystemEntity; } internal static ICoordinateSystemEntity[] Unwrap(IEnumerable<CoordinateSystem> o) { return o.Select(Unwrap).ToArray(); } internal static ICoordinateSystemEntity[] Unwrap(CoordinateSystem[] o) { return o.Select(Unwrap).ToArray(); } internal static ICoordinateSystemEntity[][] Unwrap(CoordinateSystem[][] o) { return o.Select(Unwrap).ToArray(); } protected override bool Equals(DesignScriptEntity other) { if (base.Equals(other)) return true; CoordinateSystem coordinateSystem = other as CoordinateSystem; if (coordinateSystem != null && Origin.Equals(coordinateSystem.Origin) && XAxis.Equals(coordinateSystem.XAxis) && YAxis.Equals(coordinateSystem.YAxis) && ZAxis.Equals(coordinateSystem.ZAxis)) { double num = XScaleFactor; if (num.Equals(coordinateSystem.XScaleFactor)) { num = YScaleFactor; if (num.Equals(coordinateSystem.YScaleFactor)) { num = ZScaleFactor; return num.Equals(coordinateSystem.ZScaleFactor); } } } return false; } protected override int ComputeHashCode() { return HashCode.Combine(Origin, XAxis, YAxis, ZAxis, XScaleFactor, YScaleFactor, ZScaleFactor); } public override string ToString() { StringBuilder builder = DesignScriptEntity.GetBuilder(); AppendTo(builder); return builder.ToString(); } internal override void AppendTo(StringBuilder builder) { builder.Add("CoordinateSystem(Origin = ", Origin).Add(", XAxis = ", XAxis).Add(", YAxis = ", YAxis) .Add(", ZAxis = ", ZAxis) .Add(", XScaleFactor = ", XScaleFactor) .Add(", YScaleFactor = ", YScaleFactor) .Add(", ZScaleFactor = ", ZScaleFactor) .Append(")"); } } }