By Aaron Lu
A customer asked how to create switch system, and how to know a FamilyInstance belongs to which switch systems. Unfortunately, we don't have API to create switch system and no workaround as far as I know. And no direct way to get switch systems of FamilyInstance like electrical system (i.e. FamilyInstance.MEPModel.ElectricalSystems). The good news is we have a workaround: filtering all switch systems and see if any switch system contains that family instance. Code example:
Element element = null; // the element to find switch system var categoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_SwitchSystem); FilteredElementCollector mepSystems = new FilteredElementCollector(RevitDoc); mepSystems = mepSystems .WherePasses(categoryFilter).OfClass(typeof(MEPSystem)); foreach (MEPSystem mepSystem in mepSystems) { foreach (Element member in mepSystem.Elements) { if (member.Id == element.Id) { //found break; } } }
Further questions:
1) Are MEPSystems always SwitchSystems or are there other types of MepSystems as well?
Answer: there are other types, MEPSystem is the base class of ElectricalSystem,MechanicalSystem and PipingSystem, that's why we need to use the combination of ElementClassFilter and ElementCategoryFilter.
2) Is it possible that an element in the MepSystem.Elements exists in another MepSystem as well? Or can an element only belong to one MepSystem?
Answer: An element can belong to multiple systems when it has multiple connectors used in different systems.