Delete elements from one list of elements, that are NOT in another list of elements

Hey guys! You already helped me a ton, but I still could use some more. :slight_smile:

My problem is:
I’ve got two lists of elements (well, family types I guess). And I want to select from one list, all types, that are NOT in the other list and then delete them. It would be perfect, if I could delete the types themselves instead of all elements, and then use purge, but it would do. If somone knows how to do this, please explain it very simply, I’m pretty new with Dynamo.

Thanks in advance!

Hello,You can do it with list.intersect and then use a boolean filter !

Thanks for the reply talbiman, but I can’t seem to find a “list.intersect” node. In what package can I find it? If you got the time a screenshot of a graph would help me a lot more. :slight_smile:

See here:

1 Like

@LOESCH_PK in the BuiltIn Library it’s a native node :wink:

All native nodes should be found in the Dictionary or on DynamoNodes (Standard Nodes – Dynamo Nodes), but no List.intersect apparently…

@Yna_Db thanks for the precision but it’s a tool made for lists so forgive me if changed it’s name !

1 Like

I think you want List.ContainsItem if you’re looking to separate items.


Ok, the node talbimman suggested (and Yna_Db properly named) worked.I had to add String.Contains and the primary list again, and then it worked. I’m still frustrated by the fact that my knowledge is so low, that I have no idea why something works or not! The working graph is the lower one.

Now maybe someone knoww what is happening in the upper graph. When I try to filter two lists using list.containsItem Which i hoped would filter out the missing types), or List.FirstIndexOf Dynamo, picks two random elements that are on both lists… Funny thing is, that when I deleted two different wall types, Dynamo then picked two other wall types (from different parts of the list), that also were present on both lists! List.FirstIndexOf used to work ok, but it seemed to have a problem once I added the delete node.

1 Like

And another question. Is having assigning parameters two two lists of different Revit elements, creating new types of one family based on the types of the other, and also deleting the ones that don’t have corresponding ones in the first type two much for one Dynamo file? It’s all divided into two phases, but maybe it should be more divided? Does the order of elements from left to right influence the order of doing the commands, and is it very important? Maybe I should divide this into seperate files?

It looks like you’re getting some null values. Your List.ContainsItem has 60 items but your BoolMask is only returning 53.

It would be easier to help if we could see the inputs you’re using.

Ok, here is an example. Upper list is a list of General annotation types that use information from wall types, lower list is all used wall types beginning with “SC” in type mark. I’ve just deleted two wall types from the project Sc W9 and Sc D4. The lower graph found it correctly, the upper one seems to have just noted that there two less. On closer inspection I can see that the upper one gives a false value if “item” list gets do a deleted wall type, but assigns that not to the correct value, but the one that happens to be on the wall type list at the moment (note “false” value on 2 position in “List.ContainsItem” and FamilyType.Name" Nodes).

Anyway since I got a working graph this isn’t all that imporatant.

You’re filtering the wrong list. In the top portion you’re filtering the bottom list (incorrectly) and in the bottom portion you’re filtering the top list (correctly). That’s why the bottom works. If you look at the output from List.Contains, you have 58 booleans, but you’re masking the bottom list with only 55 items. The booleans align with the upper list (58 items) so you want to mask them.