Point Coordinate list - Return only Y value


I have a list of point coordinates and I want to create new a list containing only the Y axis value. Is there a rhino script method to return only the Y axis value of a point coordinate? Or should I use something like slice to modify the existing list?

If your list is of 3d point objects - say called "pts", then you can do this:

y_coords=[pt.Y for pt in pts]

That will give you a list of all the Y coordinates in order.

If you have a list of numbers that represent coordinates, say a list of tuples (X,Y,Z) called "pt_coords" then you can do this:

y_coords=[coord[1] for coord in pt_coords]

For more info on this type of shortcut, called a “list comprehension”, have a look at the python online docs…

HTH, --Mitch

1 Like

Thank you Mitch that was very helpful. Where does the “.Y” Method reside? Is there a good resource to learn more about these types of methods? I am new to this so I am trying to find good learning/reference material.

.X, .Y, and .Z are properties of a 3d point object. Rhino/Python is based on a library called RhinoCommon, which gives access to core Rhino functions. Python is object oriented, so all the different geometric entities in Rhino are represented as RhinoCommon objects and thus have both properties and methods. Getting a good grasp of this is a bit difficult at first, as the Help (online SDK) is a bit sparse for the compared to the completeness of the Rhino or Rhinoscriptsyntax help - if you don’t know what you are looking for, it may be hard to find.

You can find a tree view of the same documentation in the left hand panel of the python editor if you are using Windows Rhino. (I can’t remember if Atom on Mac Rhino has the same)

HTH, --Mitch

1 Like

I see… I had stumbled across the Point3D properties in my search, but I didn’t know how to implement them. Now I do! Thanks so much for the help Mitch!