Get vertices of polyline

I have a polyline in Rhino. How do I get all the vertices of polyline using c#? I tried with polyline class and getsegments method. I got the array of lines, but from hereon I lost. Thanks

try this:

using System.Linq;
A = crv.ToNurbsCurve().Points.Select(p => p.Location); (4.5 KB)

Use .ToArray() since Polyline inherits from Rhino.Collections.RhinoList< Point3d>.

1 Like

See attached (121.2 KB)

Thank you for suggestions. I was looking for a simple solution without using any additional libraries like @Dani_Abalde suggested. I came to his conclusion in VS environment,

Polyline iPolyline = new Polyline();
DA.GetData(1,ref iPolyline);

Line segments = iPolyline.GetSegments();

List polylineEndPoints = new List();

foreach (Line line in segments)
polylineEndPoints.Add(new Point3d(line.To));

@Dani_Abalde solution is way simpler than adding the endpoints of each segment:

 private void RunScript(Polyline pline, ref object A)
    A = pline.ToArray();

in your case something like this should work for the points:

1 Like

That’s true