Line
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(ILineEntity), typeof(IGeometryFactory), new Type[] {
})]
public class Line : Curve
{
internal ILineEntity LineEntity => HostImpl as ILineEntity;
public Vector Direction => Vector.Wrap(LineEntity.get_Direction());
internal Line(ILineEntity host)
: base(host)
{
}
internal new static void InitType()
{
Geometry.RegisterHostType(typeof(ILineEntity), (IGeometryEntity host) => new Line(host as ILineEntity));
}
public static Line ByStartPointEndPoint(Point startPoint, Point endPoint)
{
return Wrap(HostFactory.Factory.LineByStartPointEndPoint(Point.Unwrap(startPoint), Point.Unwrap(endPoint)));
}
public static Line ByBestFitThroughPoints(IEnumerable<Point> bestFitPoints)
{
return Wrap(HostFactory.Factory.LineByBestFitThroughPoints(Point.Unwrap(bestFitPoints)));
}
public static Line ByTangency(Curve curve, double parameter = 0)
{
return Wrap(HostFactory.Factory.LineByTangency(Curve.Unwrap(curve), parameter));
}
public static Line ByStartPointDirectionLength(Point startPoint, Vector direction, [Scaling()] double length = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(length);
return Wrap(HostFactory.Factory.LineByStartPointDirectionLength(Point.Unwrap(startPoint), Vector.Unwrap(direction), length / DesignScriptEntity.scaleFactor));
}
internal static Line Wrap(ILineEntity host)
{
if (host != null)
return new Line(host);
return null;
}
internal static Line[] Wrap(ILineEntity[] hosts)
{
return hosts.Select(Wrap).ToArray();
}
internal static Line[][] Wrap(ILineEntity[][] hosts)
{
return hosts.Select(Wrap).ToArray();
}
internal static ILineEntity Unwrap(Line o)
{
return o.LineEntity;
}
internal static ILineEntity[] Unwrap(IEnumerable<Line> o)
{
return o.Select(Unwrap).ToArray();
}
internal static ILineEntity[] Unwrap(Line[] o)
{
return o.Select(Unwrap).ToArray();
}
internal static ILineEntity[][] Unwrap(Line[][] o)
{
return o.Select(Unwrap).ToArray();
}
public override string ToString()
{
StringBuilder builder = DesignScriptEntity.GetBuilder();
AppendTo(builder);
return builder.ToString();
}
internal override void AppendTo(StringBuilder builder)
{
builder.Add("Line(StartPoint = ", StartPoint).Add(", EndPoint = ", EndPoint).Add(", Direction = ", Direction)
.Append(")");
}
}
}