Access elements of a list with python

Hi Guys,
I have a list of points. Points have X,Y and Z coordinates but Z can only be = 3000 or = 6000.
I would like to create a python script to extract Z coordinate = 3000 in a list and Z coordinate = 6000 in another.

I would also like to know how it is possible to access in elements of a list.

Thanks a lot in advance


There are ways to do this with OotB nodes, but to answer your question you would have to use a for loop that would say

for point in points:
     z = point.Z

This would iterate through the list of points (points) and would set z equal to the z coordinate for that specific point. You would still have to figure out the logic for creating two lists but that should get you started.

1 Like

I think you should consider looking into “if-else” statements in python, this is among the very first things you should learn to effectively use Python…

You could start here:

Anywho, I believe what you’re trying to achieve would be easier just doing with OOTB nodes (Out Of The Box).

I will second what @Jonathan.Olesen has said. This is all pretty basic python stuff. If you’re looking to learn python (great!) try some tutorials and search the web for forums and basics. If you just want to get the result you’re looking for, you could probably get it with just a few OotB nodes or a code block.

As said @Jonathan.Olesen and @Nick_Boyts , OotB nodes really seem sufficient for what you are trying to achieve. Take a look at the List.FilterByBoolMask, the Point.Z and the == nodes. (see last example in the following link)