Exemplo n.º 1
0
        /// <summary>
        ///Using routing preferences, display found segment and fitting info from the size and pipe type specified in the dialog.
        /// </summary>
        private List <PartIdInfo> GetPreferredFittingsAndSegments()
        {
            List <PartIdInfo> partIdInfoList = new List <PartIdInfo>();

            RoutingConditions conditions = new RoutingConditions(RoutingPreferenceErrorLevel.None);


            conditions.AppendCondition(new RoutingCondition(m_mepSize));
            foreach (RoutingPreferenceRuleGroupType groupType in Enum.GetValues(typeof(RoutingPreferenceRuleGroupType)))
            {
                if (groupType == RoutingPreferenceRuleGroupType.Undefined)
                {
                    continue;
                }

                IList <ElementId> preferredTypes = new List <ElementId>();
                ElementId         preferredType  = m_routingPreferenceManager.GetMEPPartId(groupType, conditions);
                //GetMEPPartId is the main "query" method of the
                //routing preferences API that evaluates conditions and criteria and returns segment and fitting elementIds that meet
                //those criteria.

                if (groupType != RoutingPreferenceRuleGroupType.Segments)
                {
                    preferredTypes.Add(preferredType);
                }
                else  //Get all segments that support a given size, not just the first segment.
                {
                    preferredTypes = m_routingPreferenceManager.GetSharedSizes(m_mepSize, ConnectorProfileType.Round);
                }
                partIdInfoList.Add(new PartIdInfo(groupType, preferredTypes));  //Collect a PartIdInfo object for each group type.
            }

            return(partIdInfoList);
        }
Exemplo n.º 2
0
        private bool CheckSegmentForValidCoverage(RoutingPreferenceManager routingPreferenceManager, double lowerBound, double upperBound, ElementId segmentId, RoutingPreferenceRuleGroupType groupType, List <double> sizesNotCovered)
        {
            bool retval = true;

            if (segmentId == ElementId.InvalidElementId)
            {
                throw new Exception("Invalid segment ElementId");
            }

            PipeSegment segment = this.m_document.GetElement(segmentId) as PipeSegment;

            foreach (MEPSize size in segment.GetSizes())
            {
                //skip sizes outside of rp bounds
                if (size.NominalDiameter < lowerBound)
                {
                    continue;
                }
                if (size.NominalDiameter > upperBound)
                {
                    break;
                }

                RoutingConditions conditions = new RoutingConditions(RoutingPreferenceErrorLevel.None);
                conditions.AppendCondition(new RoutingCondition(size.NominalDiameter));
                ElementId foundFitting = routingPreferenceManager.GetMEPPartId(groupType, conditions);
                if (foundFitting == ElementId.InvalidElementId)
                {
                    sizesNotCovered.Add(size.NominalDiameter);
                    retval = false;
                }
            }
            return(retval);
        }