Solid
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 Solid : Topology
{
internal ISolidEntity SolidEntity => HostImpl as ISolidEntity;
[Scaling()]
public double Area {
get {
return SolidEntity.get_Area() * Math.Pow(DesignScriptEntity.scaleFactor, 2);
}
}
[Scaling()]
public double Volume {
get {
return SolidEntity.get_Volume() * Math.Pow(DesignScriptEntity.scaleFactor, 3);
}
}
internal Solid(ISolidEntity host)
: base(host)
{
}
public override string ToString()
{
return "Solid";
}
internal new static void InitType()
{
Geometry.RegisterHostType(typeof(ISolidEntity), (IGeometryEntity host) => new Solid(host as ISolidEntity));
}
internal static Solid Wrap(ISolidEntity host)
{
return Geometry.Wrap(host, null) as Solid;
}
internal static Solid[] Wrap(ISolidEntity[] hosts)
{
return (from x in hosts
select Wrap(x)).ToArray();
}
internal static Solid[][] Wrap(ISolidEntity[][] hosts)
{
return (from x in hosts
select Wrap(x)).ToArray();
}
internal static ISolidEntity[][] Unwrap(Solid[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ISolidEntity[] Unwrap(Solid[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ISolidEntity[] Unwrap(IEnumerable<Solid> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ISolidEntity Unwrap(Solid o)
{
return o.SolidEntity;
}
public static Solid ByJoinedSurfaces(IEnumerable<Surface> facesOfSolid)
{
return Wrap(HostFactory.Factory.SolidByJoinedSurfaces(Surface.Unwrap(facesOfSolid)));
}
public static Solid ByLoft(IEnumerable<Curve> crossSections)
{
return Wrap(HostFactory.Factory.SolidByLoft(Curve.Unwrap(crossSections)));
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use Solid.ByLoft(ICurveEntity[] crossSections, ICurveEntity[] guideCurves) instead")]
public static Solid ByLoft(IEnumerable<Curve> crossSections, Curve guideCurve)
{
return Wrap(HostFactory.Factory.SolidByLoft(Curve.Unwrap(crossSections), Curve.Unwrap(guideCurve)));
}
public static Solid ByLoft(IEnumerable<Curve> crossSections, IEnumerable<Curve> guideCurves)
{
return Wrap(HostFactory.Factory.SolidByLoft(Curve.Unwrap(crossSections), Curve.Unwrap(guideCurves)));
}
public static Solid ByRuledLoft(IEnumerable<PolyCurve> crossSections, bool checkAndRepair = true)
{
return Wrap(HostFactory.Factory.SolidByRuledLoft(PolyCurve.Unwrap(crossSections), checkAndRepair));
}
[IsVisibleInDynamoLibrary(false)]
[IsObsolete("solid_bysweep_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use SolidBySweep(ICurveEntity profile, ICurveEntity path, bool cutEndOff) instead")]
public static Solid BySweep(Curve profile, Curve path)
{
return Wrap(HostFactory.Factory.SolidBySweep(Curve.Unwrap(profile), Curve.Unwrap(path)));
}
public static Solid BySweep(Curve profile, Curve path, bool cutEndOff = false)
{
return Wrap(HostFactory.Factory.SolidBySweep(Curve.Unwrap(profile), Curve.Unwrap(path), cutEndOff));
}
public static Solid BySweep2Rails(Curve path, Curve guideRail, Curve profile)
{
return Wrap(HostFactory.Factory.SolidBySweep2Rails(Curve.Unwrap(path), Curve.Unwrap(guideRail), Curve.Unwrap(profile)));
}
public static Solid ByRevolve(Curve profile, [DefaultArgument("Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0)")] Point axisOrigin, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0, 0, 1)")] Vector axisDirection, double startAngle = 0, double sweepAngle = 180)
{
return Wrap(HostFactory.Factory.SolidByRevolve(Curve.Unwrap(profile), Point.Unwrap(axisOrigin), Vector.Unwrap(axisDirection), startAngle, sweepAngle));
}
public static Solid ByUnion(IEnumerable<Solid> solids)
{
return Wrap(HostFactory.Factory.SolidByUnion(Unwrap(solids)));
}
public Point Centroid()
{
return Point.Wrap(SolidEntity.Centroid());
}
public Solid Union(Solid solid)
{
return Wrap(SolidEntity.Union(Unwrap(solid)));
}
[IsObsolete("solid_unionall_deprecated", typeof(Resources))]
[Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use Solid.ByUnion instead")]
public Solid UnionAll(IEnumerable<Solid> solids)
{
return Wrap(SolidEntity.UnionAll(Unwrap(solids)));
}
public Solid Difference(Solid other)
{
return Wrap(SolidEntity.Difference(Unwrap(other)));
}
public Solid DifferenceAll(IEnumerable<Solid> others)
{
return Wrap(SolidEntity.DifferenceAll(Unwrap(others)));
}
public Solid ThinShell([Scaling()] double internalFaceThickness = 1, [Scaling()] double externalFaceThickness = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
internalFaceThickness,
externalFaceThickness
});
internalFaceThickness /= DesignScriptEntity.scaleFactor;
externalFaceThickness /= DesignScriptEntity.scaleFactor;
return Wrap(SolidEntity.ThinShell(internalFaceThickness, externalFaceThickness));
}
public Geometry[] ProjectInputOnto(Geometry geometryToProject, Vector projectDirection)
{
return Geometry.Wrap(SolidEntity.ProjectInputOnto(Geometry.Unwrap(geometryToProject), Vector.Unwrap(projectDirection)));
}
public Solid Fillet(IEnumerable<Edge> edges, [Scaling()] double radius)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
radius
});
radius /= DesignScriptEntity.scaleFactor;
return Wrap(SolidEntity.Fillet(Edge.Unwrap(edges), radius));
}
public Solid Chamfer(IEnumerable<Edge> edges, [Scaling()] double offset)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
offset
});
offset /= DesignScriptEntity.scaleFactor;
return Wrap(SolidEntity.Chamfer(Edge.Unwrap(edges), offset));
}
[AllowRankReduction]
public Solid[] Separate()
{
return Wrap(SolidEntity.Separate());
}
public Geometry Repair()
{
return Geometry.Wrap(SolidEntity.Repair(), null);
}
}
}