How to Iterate over elements by MEP System Name

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear all.
I want to do selection by MEP System Name. Is this possible?
If cannot, this is how i am planning to do:
- to pick one element
- get parameter of System Type and System Name
- Check all MEP element with same System Type and System Name.
Is there a better way to do this?
I have tried below codes as in
http://thebuildingcoder.typepad.com/blog/2013/02/simple-mep-system-traversal.html,
but the results seems incorrect where the number of connector/elements is different from my MEP system elements in my Revit project .
void TraverseSystems(Autodesk.Revit.DB.Document doc) {
FilteredElementCollector systems = new FilteredElementCollector(doc).OfClass(typeof(MEPSystem));
int i, n;
string s;
string[] a;
StringBuilder message = new StringBuilder();
foreach (MEPSystem system in systems) {
message.AppendLine("\n\nSystem Name: " + system.Name);
message.AppendLine("\nBase Equipment: " + system.BaseEquipment);
ConnectorSet cs = system.ConnectorManager.Connectors;
i = 0;
n = cs.Size;
a = new string[n];
s = string.Format("\n{0} element{1} in ConnectorManager: ", n, PluralSuffix(n));
foreach (Connector c in cs) {
Element e = c.Owner;
if (null != e) {
a[i++] = "\n" + e.GetType().Name + " " + e.Id.ToString();
}
}
message.AppendLine(s + string.Join(", ", a));
i = 0;
n = system.Elements.Size;
a = new string[n];
s = string.Format( "\n{0} element{1} in System: ", n, PluralSuffix(n));
foreach (Element e in system.Elements) {
a[i++] = "\n" + e.GetType().Name + " " + e.Id.ToString();
}
message.AppendLine(s + string.Join(", ", a));
}
n = systems.Count<Element>();
string caption = string.Format("Traverse {0} MEP System{1}", n, (1 == n ? "" : "s"));
TaskDialog dlg = new TaskDialog(caption);
dlg.MainContent = message.ToString();
dlg.Show();
}