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); }
/// <summary> /// Create Xml from a PipeSegment /// </summary> /// <param name="pipeSegment"></param> /// <returns></returns> private XElement CreateXmlFromPipeSegment(PipeSegment pipeSegment) { XElement xPipeSegment = new XElement(XName.Get("PipeSegment")); string segmentName = pipeSegment.Name; xPipeSegment.Add(new XAttribute(XName.Get("pipeScheduleTypeName"), GetPipeScheduleTypeNamebyId(pipeSegment.ScheduleTypeId))); xPipeSegment.Add(new XAttribute(XName.Get("materialName"), GetMaterialNameById(pipeSegment.MaterialId))); double roughnessInDocumentUnits = Convert.ConvertValueDocumentUnits(pipeSegment.Roughness, m_document); xPipeSegment.Add(new XAttribute(XName.Get("roughness"), roughnessInDocumentUnits.ToString("r"))); foreach (MEPSize size in pipeSegment.GetSizes()) { xPipeSegment.Add(CreateXmlFromMEPSize(size, m_document)); } return(xPipeSegment); }