Filter elements based on family names

Hi all,

I’m trying to learn python on dynamo, and currently struggling with this simple script. Please can someone give me a pointer? Thanks a lot in advance!


Essentially I’m trying to filter elements with the using their family names (substitute List.FilterByBoolMask node) by comparing them with the given BWIC family names.

What’s being returned to you? Are you wanting to filter the elements so you have a list of included and excluded elements or do you just want the booleans?

Thanks for the prompt response. Currently I’m getting boolean true & false which then pushed into FilterByBoolMask. However I want to omit this FilterByBoolMask, to get a list of revit elements that have the complied names straight out of python node.

Great. You have the basic structure, all you need to do now is zip the element and the element name together so the two values work in parallel.

elems = UnwrapElement(IN[0])
elemNames = IN[1]
famNames = IN[2]

included = []
excluded = []

for e,elem in zip(elemNames,elems):
    if e in famNames:
        included.append(elem)
    else:
        excluded.append(elem)

OUT = included,excluded

This allows you to iterate through the elements and their names in tandem. So you check the name and then add the respective element to either the included or excluded list depending on whether it’s a matched family name or not.

1 Like

thanks a lot Nick! It works like a charm, I’ll look up zip function as this seems to be quite powerful for the future cases.

1 Like