Ejemplo n.º 1
0
        public static List <BH.oM.MEP.System.Duct> DuctFromRevit(this Autodesk.Revit.DB.Mechanical.Duct revitDuct, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            // Reuse a BHoM duct from refObjects if it has been converted before
            List <BH.oM.MEP.System.Duct> bhomDucts = refObjects.GetValues <BH.oM.MEP.System.Duct>(revitDuct.Id);

            if (bhomDucts != null)
            {
                return(bhomDucts);
            }
            else
            {
                bhomDucts = new List <BH.oM.MEP.System.Duct>();
            }

            List <BH.oM.Geometry.Line> queried = Query.LocationCurveMEP(revitDuct, settings);

            // Flow rate
            double flowRate = revitDuct.LookupParameterDouble(BuiltInParameter.RBS_DUCT_FLOW_PARAM);

            BH.oM.MEP.System.SectionProperties.DuctSectionProperty sectionProperty = BH.Revit.Engine.Core.Query.DuctSectionProperty(revitDuct, settings);
            // Orientation angle
            double orientationAngle = revitDuct.OrientationAngle(settings); //ToDo - resolve in next issue, specific issue being raised

            for (int i = 0; i < queried.Count; i++)
            {
                BH.oM.Geometry.Line   segment     = queried[i];
                BH.oM.MEP.System.Duct thisSegment = new Duct
                {
                    StartPoint       = segment.StartPoint(),
                    EndPoint         = segment.EndPoint(),
                    FlowRate         = flowRate,
                    SectionProperty  = sectionProperty,
                    OrientationAngle = orientationAngle
                };
                //Set identifiers, parameters & custom data
                thisSegment.SetIdentifiers(revitDuct);
                thisSegment.CopyParameters(revitDuct, settings.ParameterSettings);
                thisSegment.SetProperties(revitDuct, settings.ParameterSettings);
                bhomDucts.Add(thisSegment);
            }

            refObjects.AddOrReplace(revitDuct.Id, bhomDucts);
            return(bhomDucts);
        }