Filter elements by BuiltInParameter using Python

Filter elements by BuiltInParameter using Python

andrelucashere
Participant Participant
665 Views
1 Reply
Message 1 of 2

Filter elements by BuiltInParameter using Python

andrelucashere
Participant
Participant

Hey, guys. I'm trying to select some elements where a parameter (comments) == 'something', using BuiltInParameter. 

Condition:

something_a --> comments == 'somethinga' 

something_b --> comments == 'somethingb' 

I've already code a list of elements with some different categories using ElementMultiCategoryFilter:

categories = List[BuiltInCategory]([BuiltInCategory.OST_PipeCurves,
BuiltInCategory.OST_PipeFitting,
BuiltInCategory.OST_PipeAccessory])
custom_filter = ElementMulticategoryFilter(categories)
my_elements = FilteredElementCollector(doc).WherePasses(custom_filter).WhereElementIsNotElementType().ToElements()

Any help would be greatly appreciated!

0 Likes
Accepted solutions (1)
666 Views
1 Reply
Reply (1)
Message 2 of 2

andrelucashere
Participant
Participant
Accepted solution

I've alredy solved it! 😅

categories = List[BuiltInCategory]([BuiltInCategory.OST_PipeCurves,
BuiltInCategory.OST_PipeFitting,
BuiltInCategory.OST_PipeAccessory])
custom_filter = ElementMulticategoryFilter(categories)
my_elements = FilteredElementCollector(doc).WherePasses(custom_filter).WhereElementIsNotElementType().ToElements()

recalque = []

for rec in my_elements:
if rec.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).AsString() == 'Recalque':
recalque.append(rec)