PolyCurve
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class PolyCurve : Curve
{
internal IPolyCurveEntity PolyCurveEntity => HostImpl as IPolyCurveEntity;
public int NumberOfCurves => PolyCurveEntity.get_NumberOfCurves();
internal PolyCurve(IPolyCurveEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
return "PolyCurve(NumberOfCurves = " + NumberOfCurves + ")";
}
internal new static void InitType()
{
Geometry.RegisterHostType(typeof(IPolyCurveEntity), (IGeometryEntity host, bool persist) => new PolyCurve(host as IPolyCurveEntity, persist));
}
internal static PolyCurve Wrap(IPolyCurveEntity host, bool persist = true)
{
return Geometry.Wrap(host, false, null) as PolyCurve;
}
internal static PolyCurve[] Wrap(IPolyCurveEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static PolyCurve[][] Wrap(IPolyCurveEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static IPolyCurveEntity[][] Unwrap(PolyCurve[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPolyCurveEntity[] Unwrap(PolyCurve[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPolyCurveEntity[] Unwrap(IEnumerable<PolyCurve> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPolyCurveEntity Unwrap(PolyCurve o)
{
return o.PolyCurveEntity;
}
public static PolyCurve ByJoinedCurves(IEnumerable<Curve> curves, [Scaling()] double joinTolerance = 0.001)
{
joinTolerance /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.PolyCurveByJoinedCurves(Curve.Unwrap(curves), joinTolerance), true);
}
public static PolyCurve ByPoints(IEnumerable<Point> points, bool connectLastToFirst = false)
{
return Wrap(HostFactory.Factory.PolyCurveByPoints(Point.Unwrap(points), connectLastToFirst), true);
}
public static PolyCurve ByThickeningCurve(Curve curve, [Scaling()] double thickness, Vector nor)
{
thickness /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.PolyCurveByThickeningCurve(Curve.Unwrap(curve), thickness, Vector.Unwrap(nor)), true);
}
public Curve[] Curves()
{
return Curve.Wrap(PolyCurveEntity.Curves(), true);
}
public Curve CurveAtIndex(int index = 0, bool endOrStart = false)
{
return Curve.Wrap(PolyCurveEntity.CurveAtIndex(index, endOrStart), true);
}
public Plane BasePlane()
{
return Plane.Wrap(PolyCurveEntity.BasePlane(), true);
}
public PolyCurve ExtendWithEllipse([Scaling()] double length, [Scaling()] double radius1, [Scaling()] double radius2, double endEllipseParameter, bool endOrStart)
{
length /= DesignScriptEntity.scaleFactor;
radius1 /= DesignScriptEntity.scaleFactor;
radius2 /= DesignScriptEntity.scaleFactor;
return Wrap(PolyCurveEntity.ExtendWithEllipse(length, radius1, radius2, endEllipseParameter, endOrStart), true);
}
public PolyCurve ExtendWithArc([Scaling()] double length, [Scaling()] double radius, bool endOrStart)
{
length /= DesignScriptEntity.scaleFactor;
radius /= DesignScriptEntity.scaleFactor;
return Wrap(PolyCurveEntity.ExtendWithArc(length, radius, endOrStart), true);
}
public PolyCurve CloseWithLine()
{
return Wrap(PolyCurveEntity.CloseWithLine(), true);
}
public PolyCurve CloseWithLineAndTangentArcs([Scaling()] double radiusAtStart = 1, [Scaling()] double radiusAtEnd = 1)
{
radiusAtStart /= DesignScriptEntity.scaleFactor;
radiusAtEnd /= DesignScriptEntity.scaleFactor;
return Wrap(PolyCurveEntity.CloseWithLineAndTangentArcs(radiusAtStart, radiusAtEnd), true);
}
public Curve Offset([Scaling()] double signedDistance, bool extendCircular)
{
signedDistance /= DesignScriptEntity.scaleFactor;
return Curve.Wrap(PolyCurveEntity.Offset(signedDistance, extendCircular), true);
}
public PolyCurve Fillet([Scaling()] double radius = 1, bool rightSide = true)
{
radius /= DesignScriptEntity.scaleFactor;
return Wrap(PolyCurveEntity.Fillet(radius, rightSide), true);
}
}
}