コード例 #1
0
        public static BH.oM.MEP.System.WireSegment WireFromRevit(this Autodesk.Revit.DB.Electrical.Wire revitWire, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            // Reuse a BHoM duct from refObjects it it has been converted before
            BH.oM.MEP.System.WireSegment bhomWire = refObjects.GetValue <BH.oM.MEP.System.WireSegment>(revitWire.Id);
            if (bhomWire != null)
            {
                return(bhomWire);
            }

            LocationCurve locationCurve = revitWire.Location as LocationCurve;
            Curve         curve         = locationCurve.Curve;

            BH.oM.Geometry.Point startPoint = curve.GetEndPoint(0).PointFromRevit();
            BH.oM.Geometry.Point endPoint   = curve.GetEndPoint(1).PointFromRevit();
            BH.oM.Geometry.Line  line       = BH.Engine.Geometry.Create.Line(startPoint, endPoint); // BHoM line

            // Wire
            bhomWire = BH.Engine.MEP.Create.WireSegment(line);

            //Set identifiers, parameters & custom data
            bhomWire.SetIdentifiers(revitWire);
            bhomWire.CopyParameters(revitWire, settings.ParameterSettings);
            bhomWire.SetProperties(revitWire, settings.ParameterSettings);

            refObjects.AddOrReplace(revitWire.Id, bhomWire);

            return(bhomWire);
        }
コード例 #2
0
ファイル: Duct.cs プロジェクト: chuongmep/Revit_Toolkit
        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);
        }
コード例 #3
0
        public static List <BH.oM.MEP.System.Pipe> PipeFromRevit(this Autodesk.Revit.DB.Plumbing.Pipe revitPipe, 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.Pipe> bhomPipes = refObjects.GetValues <BH.oM.MEP.System.Pipe>(revitPipe.Id);

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

            List <BH.oM.Geometry.Line> queried = Query.LocationCurveMEP(revitPipe, settings);
            // Flow rate
            double flowRate = revitPipe.LookupParameterDouble(BuiltInParameter.RBS_PIPE_FLOW_PARAM); // Flow rate

            // Pipe section property
            BH.oM.MEP.System.SectionProperties.PipeSectionProperty sectionProperty = revitPipe.PipeSectionProperty(settings);

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

            refObjects.AddOrReplace(revitPipe.Id, bhomPipes);
            return(bhomPipes);
        }
コード例 #4
0
ファイル: CurveList.cs プロジェクト: chuongmep/Revit_Toolkit
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static List <Curve> ToRevitCurves(this BH.oM.Geometry.Line curve)
        {
            return(new List <Curve> {
                curve.ToRevit()
            });
        }
コード例 #5
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static Line ToRevit(this BH.oM.Geometry.Line curve)
        {
            return(Line.CreateBound(curve.Start.ToRevit(), curve.End.ToRevit()));
        }