Cross product between a nested list

Hello everyone!

Im trying to cross product a nested list consisting a points with Line.ByStartPointEndPoint node.
the index is representing the level, so its already grouped by level height.

What im trying to do

.

This is works with simple list ( as you can see the background, its just process the lower index only)

Is there any python codes to create a lines? or is there any way to approach this objective?
Thanks

Just because you have a matching structure doesn’t necessarily mean that you can force list levels to get the exact mapping of inputs you want. Some mappings require additional levels. In this case, it seems like you’d have to duplicate each sublist for each sub-index. Remember, when in doubt, map every input with a 1-to-1 value.

Alternatively, if you will always have two sublists each, just separate them out and create your two lists of lines individually.

the thing is, that im not always having 2 sublist, it depends on level that im input. it can be 2, 1, or even 5+… but it always have the same index sublist length if i just select 3 leven then both of them is 3 sublist

You’ll need to duplicate values so you have a valid mapping of inputs then. You should be able to use List.Length and List.OfRepeatedItem to do this or a simple python script.

ahh i see, im a little bit confused what am i supposed to do with those node. can you provide me example how it works? or how am i going to use the nodes? thank you!

There are a bunch of similar topics that might be able to give you some more context, but it should look something like this:

1 Like

ahh i see, Thankyou!. ill be trying it out later, because its already 1am in my local time :grin:

If I am understanding you correctly, you want to match every item in sublist N of list 1 against every item in sublist N of list 2, and you have the same number of sublists in each list.

No need to duplicate the lists if so. In fact even if you have mismatched counts in the data set you can circumvent the duplication (which can be excessively long running on sufficiently sized data sets).

Instead transpose the second list, and use @L3 and @@L2 with cross product lacing. Then transpose the result. Looks something like this:
Cross product on sublists

2 Likes

It does Work very well with both methods @Nick_Boyts & @jacob.small , Thanks a lot ! been a days for solving this.


(it just make a lines just within its level)