Traversing a MEP System is a difficult endeavor to say the least. This is why many of the Hanger and Spooling automation software tools we see today are unusable. We must know the structure of a Tree before we can automate things on it’s Branches. Given a Leaf at random, how do we find the Branch it’s connected to, the Branches connected to that Branch, and the Leaves on those Branches? The answer is simple even though the implementation is quite convoluted… RULES!
First we must define the Objects that make up the underlying structural elements of a System and the rules that they must follow. A Part, a Run, and a Branch. What is the smallest building block of a MEP Tree? At the lowest level, it’s a Part (AKA a Node). This Object must encapsulate any Part that we might find in a MEP System, be it a FabricationPart, MEPCurve, or FamilyInstance. Each Part must report it’s Connectors based on a given Traversal Direction. Each Part must have a Starting Connector. Ending Connectors are not required, though Branching Connectors cannot exist without the former. Start and End Connectors travel along the same Branch.
The next Structure in the hierarchy of Objects that make up a System Tree is a Run. A series of connected parts that travel along a single Axis, forwards or backwards. A Run can not change directions however it can include parts that do. Each Run may include one and only one Part who’s end direction does not match the direction of the Run. Anything after that Connector is a new Run on the Branch, or possibly a whole new Branch of Runs. Runs hold the Axis of Traversal, Parts report their Parents and Siblings based on the Direction we walk along this Axis.
If this were a Binary Tree as shown above, we would only care about the Branches and the Nodes between them. When working with MEP System Trees however, we care a lot about the Straight Segments of Parts that make up each Branch. Runs are how we Define Spools and Hang MEP Systems in the real world. What good are all these Points if your Automation Tools have no Tree Climbing AI to guide them?
The final Structural Component is a Branch – A collection of Runs linked together by each Run’s Start and End Point. After a Branch has been climbed, each Branch of that Branch is also climbed, recursively, until there are no more Branches on the Tree.