Compare each elment of a list with any element of another list

I am trying to create a boolean mask that check if each element in a list is present in any element of another list. l am expecting Dynamo to give me something like in the second screenshot. And then I would like to ask if all true than I can use the filter boolean to filter the list I need to filter.
I am not sure where I am making it wrong. Or if its is even possible.


HELP PLEASE

Equality comparison on Revit elements isn’t possible, as they’re unique references. You can pull the GUID or Element ID and do the method you are showing above, and use the resulting booleans to filter elements (watch the list levels or use a List.AnyTrue with correct list levels) using the List.FilterByBoolMask node.

However if you’re after items that are only in List A, items that are in both List A and List B, or a single instance of all items in List A and List B look into the nodes List.SetDifference, List.SetIntersection, and List.SetUnion. These three nodes will process WAY faster than pulling the element IDs, doing comparison tests, and then filtering things.

1 Like

yeah as Jacob say :wink: list any true should work in that case…

As shown will only work for string comparison. Swap the list so the longest one is the main one getting compared to and then use crossproduct lacing and levels to get the outcome you are looking for. However, for elements, you will have to do as what @jacob.small has stated.

1 Like

Guess we can use list.equals as well for elements

Thanks everyone for the answer.
In my case I do not want to compare elements but only values in two lists, as attached. Then I want to have a list for each element that is inequal both lists. Comparing the values and check how many times one value is present in the other list. I can see that there will be lot of comparisons to be made :slight_smile: But once that comparison is done, than I will obtain a true and fals list that allows me to filter out the elements as I need to.

Long story short, extract the values of rooms that are in a flat (Area). (the intersection of elements does not work for reasons I do not know, so please do not tell me to do that, I have tried already, this is why I am going through this complex way).

Maybe with the option that @staylor suggested I could get the values I need. But it could also freeze my laptop. LoL

This is a bigger issue then what you’re illustrating in the graphs. My gut says you’re not managing nested lists (i.e. everything @L2). However it’s almost certain there is a better way to collect what you’re after if given context of the task you’re trying to perform rather than the snapshot from the corner you’re backed into. Not addressing this risks putting yourself into a hole from which there is no escape. Doubly so if the dataset is significantly large enough.

1 Like