List Logic Question

I think I am not first one who is aking this question here, but any way…
I have two list containing nested lists. I need to compare first level list between enach other, but in addition each element from first list with whole second list. Expected results wrote in code block highlighted in green.

List comparision question.dyn (9.9 KB)

you could do that.

1 Like

@Alien thank you, but this method doesn’t work with more 2 lists. Moreover I would like to keep list structure like this.

You could split the lists and do them separately.

So list 1 is only checked against list 1 and list 2 against list 2.

@denisyukj ,


Right, it also depends of number of input lists. Unfortunately, I can’t predict this number so I need some common solution.

You can split using a count…

So count the number of lists… split into that number…
Match each against each.

Hmmm… actually my idea is far easier using a bit of Python.


Do a count… then create a range from 0 to number…

Then use the code block i[0][0] but feeding in the range…

That should work.

(a<1><1>) == (b<1><2>);


@Vikram_Subbaiah, thanks a lot! It works perfefct.

1 Like

Hi, @Alien
As you propose I did a python script to handle this issue. Thank you for idea.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

lst_to_plus = IN[0]
lst_to_plus_to = IN[1]

# Place your code below this line

output_lst = []
for i in range(len(lst_to_plus)):
    nested_lst_lev_1 = []
    for ii in range(len(lst_to_plus[i])):
        nested_lst_lev_2 = []
        for item in lst_to_plus_to[i]:
            nested_lst_lev_2.append(item + lst_to_plus[i][ii])

# Assign your output to the OUT variable.
OUT = output_lst
1 Like