Grasshopper python command loop and If function

Hi there,

I have a phyton command in grasshopper that is getting a list of y coordinates and x coordinates. I am trying to make the command to loop through y and x coordinate values and check if each y coordinate value is bigger than its previous value plus 3 or if each x coordinate value is bigger than its previous value plus 3
( if y[i] > y[i-1]+3 or x[i] > x[i-1]+3 and i>0)

If so, then add A to the list.

If not, I want the script to write G1 x value y value E value (for example G1 X90.585 Y119.095 E0.52988) Or (G1 X[i] Y[i] E)

Here is an image

And here is the grasshopper file:
Question2.gh (12.5 KB)

Firstly you need to change the input type to ‘List Access’.

I added an exception for the first item in the list, and reintroduced item 0 for E. Maybe this is not what you wanted, since you seemed to remove this item.

Question2-rev1.gh (19.6 KB)

1 Like