Curve
using Autodesk.DesignScript.Geometry.Properties;
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class Curve : Geometry
{
internal ICurveEntity CurveEntity => HostImpl as ICurveEntity;
[Scaling()]
public double Length {
get {
return CurveEntity.get_Length() * DesignScriptEntity.scaleFactor;
}
}
public bool IsPlanar => CurveEntity.get_IsPlanar();
public bool IsClosed => CurveEntity.get_IsClosed();
public Point StartPoint => Point.Wrap(CurveEntity.get_StartPoint(), true);
public Point EndPoint => Point.Wrap(CurveEntity.get_EndPoint(), true);
[Scaling()]
public Vector Normal {
get {
return Vector.Wrap(CurveEntity.get_Normal().Scale(1 / DesignScriptEntity.scaleFactor), true);
}
}
internal Curve(ICurveEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
return "Curve(StartPoint = " + StartPoint?.ToString() + ", EndPoint = " + EndPoint?.ToString() + ")";
}
internal static void InitType()
{
Geometry.RegisterHostType(typeof(ICurveEntity), (IGeometryEntity host, bool persist) => new Curve(host as ICurveEntity, persist));
}
internal static Curve Wrap(ICurveEntity host, bool persist = true)
{
return Geometry.Wrap(host, false, null) as Curve;
}
internal static Curve[] Wrap(ICurveEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static Curve[][] Wrap(ICurveEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static ICurveEntity[][] Unwrap(Curve[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICurveEntity[] Unwrap(Curve[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICurveEntity[] Unwrap(IEnumerable<Curve> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICurveEntity Unwrap(Curve o)
{
return o.CurveEntity;
}
public static Curve ByParameterLineOnSurface(Surface baseSurface, UV startParams, UV endParams)
{
return Wrap(HostFactory.Factory.CurveByParameterLineOnSurface(Surface.Unwrap(baseSurface), UV.Unwrap(startParams), UV.Unwrap(endParams)), true);
}
public static Curve ByBlendBetweenCurves(Curve curve1, Curve curve2, bool endOrStart1 = true, bool endOrStart2 = false, bool isG2Continuous = false)
{
return Wrap(HostFactory.Factory.CurveByBlendBetweenCurves(Unwrap(curve1), Unwrap(curve2), endOrStart1, endOrStart2, isG2Continuous), true);
}
public static Curve ByIsoCurveOnSurface(Surface baseSurface, int direction = 0, double parameter = 0)
{
return Wrap(HostFactory.Factory.CurveByIsoCurveOnSurface(Surface.Unwrap(baseSurface), direction, parameter), true);
}
public Point PointAtParameter(double param = 0)
{
return Point.Wrap(CurveEntity.PointAtParameter(param), true);
}
[Scaling()]
public Vector TangentAtParameter(double param = 0)
{
return Vector.Wrap(CurveEntity.TangentAtParameter(param).Scale(1 / DesignScriptEntity.scaleFactor), true);
}
[Scaling()]
public Vector NormalAtParameter(double param = 0)
{
return Vector.Wrap(CurveEntity.NormalAtParameter(param).Scale(1 / DesignScriptEntity.scaleFactor), true);
}
[Scaling()]
public Vector NormalAtParameter(double param = 0, bool side = false)
{
return Vector.Wrap(CurveEntity.NormalAtParameter(param, side).Scale(1 / DesignScriptEntity.scaleFactor), true);
}
public CoordinateSystem CoordinateSystemAtParameter(double param = 0)
{
return CoordinateSystem.Wrap(CurveEntity.CoordinateSystemAtParameter(param), true);
}
public CoordinateSystem HorizontalFrameAtParameter(double param = 0)
{
return CoordinateSystem.Wrap(CurveEntity.HorizontalFrameAtParameter(param), true);
}
public Plane PlaneAtParameter(double param = 0)
{
return Plane.Wrap(CurveEntity.PlaneAtParameter(param), true);
}
public Point PointAtSegmentLength([Scaling()] double segmentLength = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return Point.Wrap(CurveEntity.PointAtSegmentLength(segmentLength), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use PointAtSegmentLength instead")]
public Point PointAtDistance([Scaling()] double segmentLength = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return Point.Wrap(CurveEntity.PointAtDistance(segmentLength), true);
}
public Point[] PointsAtEqualSegmentLength(int divisions = 10)
{
return Point.Wrap(CurveEntity.PointsAtEqualSegmentLength(divisions), true);
}
public Point[] PointsAtEqualChordLength(int divisions = 10)
{
return Point.Wrap(CurveEntity.PointsAtEqualChordLength(divisions), true);
}
public Point PointAtChordLength([Scaling()] double chordLength = 1, double parameterLocation = 0, bool forward = true)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
chordLength
});
chordLength /= DesignScriptEntity.scaleFactor;
return Point.Wrap(CurveEntity.PointAtChordLength(chordLength, parameterLocation, forward), true);
}
public Point[] PointsAtSegmentLengthFromPoint([DefaultArgument("Point.ByCoordinates(0, 0, 0)")] Point point, [Scaling()] double segmentLength = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return Point.Wrap(CurveEntity.PointsAtSegmentLengthFromPoint(Point.Unwrap(point), segmentLength), true);
}
public Point[] PointsAtChordLengthFromPoint([DefaultArgument("Point.ByCoordinates(0, 0, 0)")] Point point, [Scaling()] double chordLength = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
chordLength
});
chordLength /= DesignScriptEntity.scaleFactor;
return Point.Wrap(CurveEntity.PointsAtChordLengthFromPoint(Point.Unwrap(point), chordLength), true);
}
public CoordinateSystem CoordinateSystemAtSegmentLength([Scaling()] double segmentLength = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return CoordinateSystem.Wrap(CurveEntity.CoordinateSystemAtSegmentLength(segmentLength), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use CoordinateSystemAtSegmentLength instead")]
public CoordinateSystem CoordinateSystemAtDistance([Scaling()] double segmentLength = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return CoordinateSystem.Wrap(CurveEntity.CoordinateSystemAtDistance(segmentLength), true);
}
public Plane PlaneAtSegmentLength([Scaling()] double segmentLength = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return Plane.Wrap(CurveEntity.PlaneAtSegmentLength(segmentLength), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use PlaneAtSegmentLength instead")]
public Plane PlaneAtDistance([Scaling()] double segmentLength = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return Plane.Wrap(CurveEntity.PlaneAtDistance(segmentLength), true);
}
[Scaling()]
public double SegmentLengthAtParameter(double parameter = 0)
{
return CurveEntity.SegmentLengthAtParameter(parameter) * DesignScriptEntity.scaleFactor;
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use SegmentLengthAtParameter instead")]
[Scaling()]
public double DistanceAtParameter(double param = 0)
{
return CurveEntity.DistanceAtParameter(param) * DesignScriptEntity.scaleFactor;
}
public double ParameterAtSegmentLength([Scaling()] double segmentLength = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return CurveEntity.ParameterAtSegmentLength(segmentLength);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use ParameterAtSegmentLength instead")]
public double ParameterAtDistance([Scaling()] double segmentLength = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
segmentLength
});
segmentLength /= DesignScriptEntity.scaleFactor;
return CurveEntity.ParameterAtDistance(segmentLength);
}
public double ParameterAtChordLength([Scaling()] double chordLength = 0.5, double parameter = 0, bool forward = true)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
chordLength
});
chordLength /= DesignScriptEntity.scaleFactor;
return CurveEntity.ParameterAtChordLength(chordLength, parameter, forward);
}
public double StartParameter()
{
return CurveEntity.StartParameter();
}
public double EndParameter()
{
return CurveEntity.EndParameter();
}
[Scaling()]
public double SegmentLengthBetweenParameters(double startParam = 0, double endParam = 1)
{
return CurveEntity.SegmentLengthBetweenParameters(startParam, endParam) * DesignScriptEntity.scaleFactor;
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use SegmentLengthBetweenParameters instead")]
[Scaling()]
public double LengthBetweenParameters(double startParam = 0, double endParam = 1)
{
return CurveEntity.LengthBetweenParameters(startParam, endParam) * DesignScriptEntity.scaleFactor;
}
public double ParameterAtPoint(Point point)
{
return CurveEntity.ParameterAtPoint(Point.Unwrap(point));
}
public Curve Reverse()
{
return Wrap(CurveEntity.Reverse(), true);
}
[IsVisibleInDynamoLibrary(false)]
[IsObsolete("curve_offset_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use 'OffsetMany' instead.")]
public Curve Offset([Scaling()] double distance = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Wrap(CurveEntity.Offset(distance), true);
}
[AllowRankReduction]
public Curve[] OffsetMany([DefaultArgument("1")] [Scaling()] double signedDistance, [DefaultArgument("null")] Vector planeNormal)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
signedDistance
});
signedDistance /= DesignScriptEntity.scaleFactor;
return Wrap(CurveEntity.OffsetMany(signedDistance, Vector.Unwrap(planeNormal)), true);
}
public Curve PullOntoPlane(Plane plane)
{
return Wrap(CurveEntity.PullOntoPlane(Plane.Unwrap(plane)), true);
}
public Curve PullOntoSurface(Surface surface)
{
return Wrap(CurveEntity.PullOntoSurface(Surface.Unwrap(surface)), true);
}
[IsObsolete("curve_divideequally_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use 'PointsAtEqualSegmentLength' and 'SplitByPoints' instead.")]
public Curve[] DivideEqually(int divisions = 10)
{
return Wrap(CurveEntity.DivideEqually(divisions), true);
}
[IsObsolete("curve_dividebydistance_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use 'PointsAtEqualChordLength' and 'SplitByPoints' instead")]
public Curve[] DivideByDistance(int divisions = 10)
{
return Wrap(CurveEntity.DivideByDistance(divisions), true);
}
[IsObsolete("curve_dividebylengthfromparams_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use 'PointsAtSegmentLengthFromPoint' and 'SplitByPoints' instead.")]
public Curve[] DivideByLengthFromParameter([Scaling()] double length = 1, double parameter = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
length
});
length /= DesignScriptEntity.scaleFactor;
return Wrap(CurveEntity.DivideByLengthFromParameter(length, parameter), true);
}
[IsObsolete("curve_dividebydistancefromparam_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use 'PointsAtChordLengthFromPoint' and 'SplitByPoints' instead.")]
public Curve[] DivideByDistanceFromParameter([Scaling()] double distance = 1, double parameter = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Wrap(CurveEntity.DivideByDistanceFromParameter(distance, parameter), true);
}
public Curve TrimByStartParameter(double startParameter = 0)
{
return Wrap(CurveEntity.TrimByStartParameter(startParameter), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use TrimByStartParameter instead")]
public Curve ParameterTrimStart(double startParameter = 0)
{
return Wrap(CurveEntity.ParameterTrimStart(startParameter), true);
}
public Curve TrimByEndParameter(double endParameter = 1)
{
return Wrap(CurveEntity.TrimByEndParameter(endParameter), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use TrimByEndParameter instead")]
public Curve ParameterTrimEnd(double endParameter = 1)
{
return Wrap(CurveEntity.ParameterTrimEnd(endParameter), true);
}
public Curve TrimByParameter(double startParameter = 0, double endParameter = 1)
{
return Wrap(CurveEntity.TrimByParameter(startParameter, endParameter), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use TrimByParameter instead")]
public Curve ParameterTrim(double startParameter = 0, double endParameter = 1)
{
return Wrap(CurveEntity.ParameterTrim(startParameter, endParameter), true);
}
public Curve[] TrimInteriorByParameter(double startParameter = 0, double endParameter = 1)
{
return Wrap(CurveEntity.TrimInteriorByParameter(startParameter, endParameter), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use TrimInteriorByParameter instead")]
public Curve[] ParameterTrimInterior(double startParameter = 0, double endParameter = 1)
{
return Wrap(CurveEntity.ParameterTrimInterior(startParameter, endParameter), true);
}
[IsVisibleInDynamoLibrary(false)]
[IsObsolete("curve_trimsegmentsbyparam_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use Curve.TrimSegmentsByParameter(double[] parameters, bool discardEvenSegments) instead.")]
public Curve[] TrimSegmentsByParameter(double[] parameters)
{
return Wrap(CurveEntity.TrimSegmentsByParameter(parameters), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use TrimSegmentsByParameter instead")]
public Curve[] ParameterTrimSegments(double[] parameters)
{
return Wrap(CurveEntity.ParameterTrimSegments(parameters), true);
}
public Curve[] TrimSegmentsByParameter(double[] parameters, bool discardEvenSegments = true)
{
return Wrap(CurveEntity.TrimSegmentsByParameter(parameters, discardEvenSegments), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use SplitByParameter(double[] parameters) instead")]
public Curve[] SplitByParameter(double parameter = 0.5)
{
return Wrap(CurveEntity.SplitByParameter(parameter), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use SplitByParameter instead")]
public Curve[] ParameterSplit(double parameter = 0.5)
{
return Wrap(CurveEntity.ParameterSplit(parameter), true);
}
public Curve[] SplitByParameter(double[] parameters)
{
return Wrap(CurveEntity.SplitByParameter(parameters), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use SplitByParameter instead")]
public Curve[] ParameterSplit(double[] parameters)
{
return Wrap(CurveEntity.ParameterSplit(parameters), true);
}
public Curve[] SplitByPoints(IEnumerable<Point> points)
{
return Wrap(CurveEntity.SplitByPoints(Point.Unwrap(points)), true);
}
public PolyCurve Join(IEnumerable<Curve> curves)
{
return PolyCurve.Wrap(CurveEntity.Join(Unwrap(curves)), true);
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use Join(ICurveEntity[] curves) instead")]
public PolyCurve Join(Curve curve)
{
return PolyCurve.Wrap(CurveEntity.Join(Unwrap(curve)), true);
}
public Surface Extrude([Scaling()] double distance = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Surface.Wrap(CurveEntity.Extrude(distance), true);
}
public Surface Extrude([DefaultArgument("Vector.ByCoordinates(0, 0, 1)")] Vector direction)
{
return Surface.Wrap(CurveEntity.Extrude(Vector.Unwrap(direction)), true);
}
public Surface Extrude([DefaultArgument("Vector.ByCoordinates(0, 0, 1)")] Vector direction, [Scaling()] double distance = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Surface.Wrap(CurveEntity.Extrude(Vector.Unwrap(direction), distance), true);
}
public Solid ExtrudeAsSolid([Scaling()] double distance = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Solid.Wrap(CurveEntity.ExtrudeAsSolid(distance), true);
}
public Solid ExtrudeAsSolid([DefaultArgument("Vector.ByCoordinates(0, 0, 1)")] Vector direction)
{
return Solid.Wrap(CurveEntity.ExtrudeAsSolid(Vector.Unwrap(direction)), true);
}
public Solid ExtrudeAsSolid([DefaultArgument("Vector.ByCoordinates(0, 0, 1)")] Vector direction, [Scaling()] double distance = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Solid.Wrap(CurveEntity.ExtrudeAsSolid(Vector.Unwrap(direction), distance), true);
}
public Curve Extend([Scaling()] double distance, Point pickSide)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Wrap(CurveEntity.Extend(distance, Point.Unwrap(pickSide)), true);
}
public Curve ExtendStart([Scaling()] double distance = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Wrap(CurveEntity.ExtendStart(distance), true);
}
public Curve ExtendEnd([Scaling()] double distance = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
distance
});
distance /= DesignScriptEntity.scaleFactor;
return Wrap(CurveEntity.ExtendEnd(distance), true);
}
public Curve[] ApproximateWithArcAndLineSegments()
{
return Wrap(CurveEntity.ApproximateWithArcAndLineSegments(), true);
}
public NurbsCurve ToNurbsCurve()
{
return NurbsCurve.Wrap(CurveEntity.ToNurbsCurve(), true);
}
public Surface Patch()
{
return Surface.Wrap(CurveEntity.Patch(), true);
}
public Geometry[] Project(Geometry baseGeometry, Vector projectionDirection)
{
return Geometry.Wrap(CurveEntity.Project(Geometry.Unwrap(baseGeometry), Vector.Unwrap(projectionDirection)));
}
public Surface SweepAsSurface(Curve path)
{
return Surface.Wrap(CurveEntity.SweepAsSurface(Unwrap(path)), true);
}
[IsVisibleInDynamoLibrary(false)]
[IsObsolete("curve_sweepassolidsingle_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use SweepAsSolid(ICurveEntity path, bool cutEndOff) instead")]
public Solid SweepAsSolid(Curve path)
{
return Solid.Wrap(CurveEntity.SweepAsSolid(Unwrap(path)), true);
}
public Solid SweepAsSolid(Curve path, bool cutEndOff = false)
{
return Solid.Wrap(CurveEntity.SweepAsSolid(Unwrap(path), cutEndOff), true);
}
public Curve Simplify([Scaling()] double tolerance)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
tolerance
});
tolerance /= DesignScriptEntity.scaleFactor;
return Wrap(CurveEntity.Simplify(tolerance), true);
}
}
}