コード例 #1
0
        private bool IsRuleSetToRangeNone(RoutingPreferenceManager routingPreferenceManager, RoutingPreferenceRuleGroupType groupType, int index)
        {
            if (routingPreferenceManager.GetNumberOfRules(groupType) == 0)
            {
                return(false);
            }

            RoutingPreferenceRule rule = routingPreferenceManager.GetRule(groupType, index);

            if (rule.NumberOfCriteria == 0)
            {
                return(false);
            }

            PrimarySizeCriterion psc = rule.GetCriterion(0) as PrimarySizeCriterion;

            if (psc.IsEqual(PrimarySizeCriterion.None()))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Checks to see if any segments in the routing preference manager have sizes that cannot be fitted with fittings defined in a rule group type, such as "Elbow."
        /// For example, if a segment rule defines a segment be used from sizes 2" to 12", and there are three elbows rules defined to be used from ranges
        /// 2"-4", 4"-7", and 9"-14", this method will return warning information specifying the sizes (8", 8.5", etc...) not covered by elbow fittings.
        /// </summary>
        private XElement GetSegmentRangeNotCoveredWarning(RoutingPreferenceManager routingPreferenceManager, RoutingPreferenceRuleGroupType groupType)
        {
            for (int index = 0; index != routingPreferenceManager.GetNumberOfRules(RoutingPreferenceRuleGroupType.Segments); ++index)
            {
                RoutingPreferenceRule rule = routingPreferenceManager.GetRule(RoutingPreferenceRuleGroupType.Segments, index);
                if (rule.MEPPartId == ElementId.InvalidElementId)
                {
                    continue;
                }

                if (rule.NumberOfCriteria == 0)  //double check all/none
                {
                    continue;
                }

                PrimarySizeCriterion psc = rule.GetCriterion(0) as PrimarySizeCriterion;

                PipeSegment   segment         = m_document.GetElement(rule.MEPPartId) as PipeSegment;
                List <double> sizesNotCovered = new List <double>();
                bool          isCovered       = CheckSegmentForValidCoverage(routingPreferenceManager, psc.MinimumSize, psc.MaximumSize, rule.MEPPartId, groupType, sizesNotCovered);
                if (!isCovered)
                {
                    XElement xSegmentNotCovered = new XElement(XName.Get("SegmentRangeNotCovered"));
                    xSegmentNotCovered.Add(new XAttribute(XName.Get("name"), segment.Name));
                    StringBuilder sBuilder = new StringBuilder();

                    foreach (double size in sizesNotCovered)
                    {
                        double roundedSize = Convert.ConvertValueDocumentUnits(size, m_document);

                        sBuilder.Append(roundedSize.ToString() + " ");
                    }
                    sBuilder.Remove(sBuilder.Length - 1, 1);
                    xSegmentNotCovered.Add(new XAttribute(XName.Get("sizes"), sBuilder.ToString()));
                    xSegmentNotCovered.Add(new XAttribute(XName.Get("unit"), m_document.GetUnits().GetFormatOptions(UnitType.UT_PipeSize).DisplayUnits.ToString()));
                    xSegmentNotCovered.Add(new XAttribute(XName.Get("groupType"), groupType.ToString()));


                    return(xSegmentNotCovered);
                }
            }
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Create Xml from a RoutingPreferenceRule
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="groupType"></param>
        /// <returns></returns>
        private XElement createXmlFromRoutingPreferenceRule(RoutingPreferenceRule rule, RoutingPreferenceRuleGroupType groupType)
        {
            XElement xRoutingPreferenceRule = new XElement(XName.Get("RoutingPreferenceRule"));

            xRoutingPreferenceRule.Add(new XAttribute(XName.Get("description"), rule.Description));
            xRoutingPreferenceRule.Add(new XAttribute(XName.Get("ruleGroup"), groupType.ToString()));
            if (rule.NumberOfCriteria >= 1)
            {
                PrimarySizeCriterion psc = rule.GetCriterion(0) as PrimarySizeCriterion;

                if (psc.IsEqual(PrimarySizeCriterion.All()))
                {
                    xRoutingPreferenceRule.Add(new XAttribute(XName.Get("minimumSize"), "All"));
                }
                else
                if (psc.IsEqual(PrimarySizeCriterion.None()))
                {
                    xRoutingPreferenceRule.Add(new XAttribute(XName.Get("minimumSize"), "None"));
                }
                else //Only specify "maximumSize" if not specifying "All" or "None" for minimum size, just like in the UI.
                {
                    xRoutingPreferenceRule.Add(new XAttribute(XName.Get("minimumSize"), (Convert.ConvertValueDocumentUnits(psc.MinimumSize, m_document)).ToString()));
                    xRoutingPreferenceRule.Add(new XAttribute(XName.Get("maximumSize"), (Convert.ConvertValueDocumentUnits(psc.MaximumSize, m_document)).ToString()));
                }
            }
            else
            {
                xRoutingPreferenceRule.Add(new XAttribute(XName.Get("minimumSize"), "All"));
            }

            if (groupType == RoutingPreferenceRuleGroupType.Segments)
            {
                xRoutingPreferenceRule.Add(new XAttribute(XName.Get("partName"), GetSegmentNameById(rule.MEPPartId)));
            }
            else
            {
                xRoutingPreferenceRule.Add(new XAttribute(XName.Get("partName"), GetFittingNameById(rule.MEPPartId)));
            }

            return(xRoutingPreferenceRule);
        }