I had a function set up to automatically collect all the electrical equipment in the project. However, it's also collecting some DirectShape elements that are on the Electrical Equipment category, and this is problematic since I'm calling .MEPModel to access the electrical system on these elements. DirectShapes don't have this component, so I want to exclude them.
I tried adding a class filter but I can't manage to get it to work, since ElectricalEquipment is not a subtype of Element, but a subtype of MEPObject. It makes sense that this might throw an error since I'm using a filtered element collector, but it's also confusing, because you can still collect the electrical equipment if you just use the category filter without the class filter.
def get_electrical_equipment(sort_by_name = False):
elements = DB.FilteredElementCollector(doc)\
.OfCategory(DB.BuiltInCategory.OST_ElectricalEquipment)\
.OfClass(DB.Electrical.ElectricalEquipment)\
.WhereElementIsNotElementType()
if sort_by_name:
elements = list(elements)
elements.sort(key=lambda x: x.Name)
return elements
Solved! Go to Solution.
Solved by mhannonQ65N2. Go to Solution.
You should use OfClass(DB.FamilyInstance) since family instances have the MEPModel property you are looking for.
Can't find what you're looking for? Ask the community or share your knowledge.