List of Points in Python
This guide provides an overview of a rhinoscriptsyntax list of Point Geometry in Python.
Lists of Points
Many rhinoscriptsyntax functions require a list of points as an argument or return a list of Point3d structures. For example the ‘DivideCurve()’ function will return a list of points:
import rhinoscriptsyntax as rs obj = rs.GetObject("Select a curve") if obj: points = rs.DivideCurve(obj, 4) print(points)
There are a number of ways to access the information in these lists.
Use an index to access any one of the points as in the line:
print(points) # Returns a Point3d structure
With Python, it is easy to use the
for loop to walk through the list and print out the coordinates for each point,
for i in points: print i
It is also possible to use nested indexes to access a specific coordinate of a point in the list. This example will access the Y coordinate of the second point in the list:
Using the .Y property on the Point3d also would work:
To add a point to this list, first create the point3d with
CreatePoint(), then append it:
points.append(rs.CreatePoint(1.0, 2.0, 3.0)) for i in points: print i