How to get an array of 3dPoints from given Polyline object in GHPython

Guys, maybe it’s to hot today, but I currently cannot figure out how to get an array of 3DPoints from a Polyline object in GHPython.

I am sure it is EXTREMELY simple… but I am currently struggling. Can you quickly help me out?

I am searching for something like .CenterPoint() but as an array of all points of the Polyline.

Try this, maybe not the most optimized code but it should do

import Rhino.Geometry as rg

# Input curve as an Item Access Polyline
# Output a

pts = []

segments = curve.GetSegments().Count

for i in range(segments+1):

a = pts

This is the same method as above

a = [curve.PointAt(i) for i in range(curve.SegmentCount+1)]
1 Like

@jordi.arcas and @Adam_M
Thank you both for your answers - that certainly works. :grinning:

However, I still wonder why there is nothing built in. I mean getting the points of a polyline seems like a standard task to me. So I was hoping that I just overlooked something.

It does seem like there should be a simpler way.

Using RhinoScriptSyntax you can do:

import rhinoscriptsyntax as rs


You can use the yourPolyline.ToArray() method. Or cast it using list(yourPolyline).


@AndersDeleuran Yes - that was the one that I overlooked. Works exactly like I expected - but just did not recognize it with that name.

Thanks a lot (marked your answer as the solution).

1 Like