Constructing Paths / Idiomatic Nested For-Loops


I’m pretty new to Grasshopper.


  • Data tree formatted as {x;y}[z], where each element is a box. Essentially, each leaf of the tree is a list of boxes representing a z-axis column.
  • A list of selected x-indices X
  • A list of selected y-indices Y
  • A list of selected z-indices Z
  • I would like to select all combinations of {x;y}[z].

Currently, my approach is to attempt to build a list of paths. I can do it in the case where the list of selected y indices is only a single element:

However, I am struggling to correctly generate the list of paths when y is more than one element.

Suppose the list of x indices is 3,4. Suppose the list of y-indices is 2,5. I would like to output a list of paths:


This feels like something that would be trivial to do in python, but I feel there must be an idiomatic way of constructing paths in Grasshopper that I am struggling to identify.

All the help appreciated!

I ended up coming up with this solution using cartesian product. A little janky. Also, Cartesian Product does not work quite the way I would expect it to… But hey this works so, cool with me.

Better yet - it turns out Cross-Reference is the operator I was looking for!

Hopefully someone in the future benefits from this post!