Indexing a point list in python component

Hi everyone,

I am new to grasshopper.
I create a range (list) of points in GH, then input them as X into a python component.

import rhinoscriptsyntax as rs

output = rs.PointCoordinates(X)

But I found that only the XYZ component can be extracted individually.
i don’t know how to extract a certain point from the list (say the first or the last point).

Thank you so much

It would help us understand your question if you provide an example file.

Generally in python if you have a list of objects you can get the nth element in the list using square brackets. Eg my_list = (10,42,3,4,1)
Then my_list[1] will return 42

You also need to ensure that your python component has list access. Right click on the input parameter (x) and set list access (it is item by default). With list access x[0] will return the first point. With item access x[0] will return the x coordinate of each point


Thanks for the reply.
like the above fig, i would like to have the point say (2,2,2) or (10,10,10)
and save them to two variables but I failed to index them like point1 = a[0], something like that

You have to change the access of the input to List Access:

Ray (17.5 KB)


OMG. It totally solves my problem
Thanks man <3

Also X[-1] for the last item.

1 Like


As I said earlier…


Thanks all of you guys. It helps me a lot =)