Routing prefences are accessible through the RoutingPreferenceManager class. An instance of this class is available from a property of the MEPCurveType class. Currently, only PipeType and DuctType support routing preferences.
The RoutingPreferenceManager manages all rules for selecting segment types and sizes as well as fitting types based on user selection criteria. The RoutingPreferenceRule class manages one segment or fitting preference and instances of this class can be added to the RoutingPreferenceManager. Each routing preference rule is grouped according to what type of routing item in manages. The type is represented by the RoutingPreferenceRuleGroupType and includes these options:
Member name | Description |
Undefined | Undefined group type (default initial value) |
Segments | Segment types (e.g. pipe stocks) |
Elbows | Elbow types |
Junctions | Junction types (e.g. takeoff, tee, wye, tap) |
Crosses | Cross types |
Transitions | Transition types (Note that the multi-shape transitions may have their own groups) |
Unions | Union types that connect two segments together |
MechanicalJoints | Mechanical joint types that connect fitting to fitting, segment to fitting, or segment to segment |
TransitionsRectangularToRound | Multi-shape transition from the rectangular profile to the round profile |
TransitionsRectangularToOval | Multi-shape transition from the rectangular profile to the oval profile |
TransitionsOvalToRound | Multi-shape transition from the oval profile to the round profile |
Each routing preference rule can have one or more selection criteria, represented by the RoutingCriterionBase class, and the derived type PrimarySizeCriterion. PrimarySizeCriterion selects fittings and segments based on minimum and maximum size constraints.
The RoutingConditions class holds a collection of RoutingCondition instances. The RoutingCondition class represents routing information that is used as input when determining if a routing criterion, such as minimum or maximum diameter, is met. The RoutingPreferencesManager.GetMEPPartId() method gets a fitting or segment id based on a RoutingPreferenceRuleGroupType and RoutingConditions.
The following example gets all the pipe types in the document, gets the routing preference manager for each one, then gets the sizes for each segment based on the rules in the routing preference manager.
Code Region: Using Routing Preferences |
private List<double> GetAvailablePipeSegmentSizesFromDocument(Document document) { System.Collections.Generic.HashSet<double> sizes = new HashSet<double>(); FilteredElementCollector collectorPipeType = new FilteredElementCollector(document); collectorPipeType.OfClass(typeof(PipeType)); IEnumerable<PipeType> pipeTypes = collectorPipeType.ToElements().Cast<PipeType>(); foreach (PipeType pipeType in pipeTypes) { RoutingPreferenceManager rpm = pipeType.RoutingPreferenceManager; int segmentCount = rpm.GetNumberOfRules(RoutingPreferenceRuleGroupType.Segments); for (int index = 0; index != segmentCount; ++index) { RoutingPreferenceRule segmentRule = rpm.GetRule(RoutingPreferenceRuleGroupType.Segments, index); Segment segment = document.GetElement(segmentRule.MEPPartId) as Segment; foreach (MEPSize size in segment.GetSizes()) { sizes.Add(size.NominalDiameter); //Use a hash-set to remove duplicate sizes among Segments and PipeTypes. } } } List<double> sizesSorted = sizes.ToList(); sizesSorted.Sort(); return sizesSorted; } |