Error compare two list

Hello

I have two parameters lists obtained from two elements in Revit, the first one is a wall in a local model, the second one is the same wall but obtained from linked model.

When I compared these two list, the result could be that list are equals, but the result is that two list are different.

If I use the dynamo node == the result is that both list are equal. If I use that line in a code block List1 == List2, the result is that both list are equal.

In other way, if I compared these two list in a python script node, the result is that two list are different.

If I compared an element in the list one with the same element in the list two, both are different.
if LocParList != LinParList:
CTRL = 1
if set(LocParList) != set(LinParList):
CTRL = 1
in both case the result is 1

if LocParList[23] != LinParList[23]:
CTRL = CTRL + 23
elif LocParList[26] != LinParList[26]:
CTRL = CTRL + 26
elif LocParList[1] != LinParList[1]:
CTRL = CTRL + 1
elif LocParList[2] != LinParList[2]:
CTRL = CTRL + 2
elif LocParList[21] != LinParList[21]:
CTRL = CTRL + 21
In that case, the result is the values are different.

Have you tried set.difference node?

Hello @RubenVivancos

I need to compare these two list in a design script of python, but is very strange when I compare it with some dynamo node, the result is true, but when I compare it inside the design script node with a python code, the result is false.

Answering your question, I already tried the node that you tell me, and the result is the same, true.

I am not sure where is the result false but sounds like a node checks any item of both lists and the design script code is looking to the complete list as unique, maybe changing the lacing or levels would work :grinning:

That would be my guess as well. It’s hard to tell though with just the information you’ve given. Everything in the image you’ve shown looks as expected.

Hello

Thanks both for your answers.

I resolved this problem changing each element of the list in a string. In this way, the comparison between two elements are true when both are equals.

I changed this:
if LocParList[23] != LinParList[23]:
CTRL = CTRL + 23
for that
if str(LocParList[23]) != str(LinParList[23]):
CTRL = CTRL + 23

1 Like