How to create a polygon object (such as triangle)?

Hi,

In my C# program, I have 3 points and 1 curve, I want to create a triangle object to sweep.


I’ve searched in rhino library but there is no structure or class describes a polygon (only Rhino.Display.CustomDisplay.AddPolygon(), but it isn’t necessary in my situation).

I need your help!

To get the triangle you can do this:

Dim PtList As New List(Of Geometry.Point3d)
PtList.add(point1)
PtList.add(point2)
PtList.add(point3)
PtList.add(point1)
Dim Crv As Geometry.Curve = Geometry.Curve.CreateControlPointCurve(PtList, 1)
Dim CrvGuid as guid = doc.objects.addcurve(crv)

the result is a closed curve.

next is creating a planarSrf with the curve and I think its easiest with RhinoApp.Runscript like:

doc.objects.unselectall()
doc.objects.select(CrvGuid )
RhinoApp.Runscript("_PlanarSrf",true)
Dim PlanarSrf as Guid = doc.Objects.MostRecentObject.Id

Sweep2 can possibly also be done with the rhinoscript but then you need to add -_selID and curve.id etc.

Hope I pushed you in the right direction :wink:

Yes, thank you!

I will try your way.

I see the sweep in RhinoCommon needs curves

Dim g As New Geometry.SweepOneRail
Dim B as brep = g.PerformSweep(Rail, Crv)

So you dont need the planarsrf part :wink:
In g. you can set some settings.

I tried your way and it was very good!

Thank you very much!