Example #1
0
        /***************************************************/

        public static TubeProfile InterpolateProfile(TubeProfile startProfile, TubeProfile endProfile, double parameter, int interpolationOrder,
                                                     double domainStart = 0, double domainEnd = 1)
        {
            return(Create.TubeProfile(
                       Interpolate(startProfile.Diameter, endProfile.Diameter, parameter, interpolationOrder, domainStart, domainEnd),
                       Interpolate(startProfile.Thickness, endProfile.Thickness, parameter, interpolationOrder, domainStart, domainEnd)));
        }
Example #2
0
        public static SectionProfile SectionProfile(TubeProfile tubeProfile, double liningThickness, double insulationThickness)
        {
            //Internal offset of original ShapeProfile
            IProfile liningProfile = null;

            if (liningThickness <= 0)
            {
                liningProfile = null;
            }
            else
            {
                liningProfile = BH.Engine.Spatial.Create.TubeProfile((((tubeProfile.Diameter / 2) - tubeProfile.Thickness) * 2), liningThickness);
            }

            //External offset of original ShapeProfile

            IProfile insulationProfile = null;

            if (insulationThickness <= 0)
            {
                insulationProfile = null;
            }
            else
            {
                insulationProfile = BH.Engine.Spatial.Create.TubeProfile((tubeProfile.Diameter + (insulationThickness * 2)), insulationThickness);
            }

            return(new SectionProfile(tubeProfile, liningProfile, insulationProfile));
        }
Example #3
0
        public static string Description(this TubeProfile profile)
        {
            if (profile == null)
            {
                return("null profile");
            }

            return($"Tube {profile.Diameter:G3} x {profile.Thickness:G3}");
        }
Example #4
0
        /***************************************************/

        private bool CreateProfile(string name, TubeProfile profile)
        {
            List <double> dimensionList = new List <double> {
                profile.Diameter, profile.Thickness
            };

            double[] dimensionArray = dimensionList.ToArray();

            //List<string> valueList = new List<string> { "D", "t" };

            int lusasType = 4;

            CreateLibrarySection(name, dimensionArray, lusasType);

            return(true);
        }
Example #5
0
 public static double Thickness(this TubeProfile tubeProfile)
 {
     return(tubeProfile.Thickness);
 }
Example #6
0
        /***************************************************/

        public static string Description(this TubeProfile profile)
        {
            return("Tube " + profile.Diameter + "x" + profile.Thickness);
        }
Example #7
0
 public static double WarpingConstant(this TubeProfile profile)
 {
     return(profile.IsNull() ? 0 : 0);
 }
 public static double WarpingConstant(this TubeProfile profile)
 {
     return(0);
 }
Example #9
0
        /***************************************************/

        private bool SetProfile(TubeProfile bhomProfile, string sectionName, string matName)
        {
            int ret = m_model.PropFrame.SetPipe(sectionName, matName, bhomProfile.Diameter, bhomProfile.Thickness);

            return(ret == 0);
        }
Example #10
0
 private static void SetSpecificDimensions(TubeProfile dimensions, string sectionName, IMaterialFragment material, cSapModel model)
 {
     model.PropFrame.SetPipe(sectionName, material.Name, dimensions.Diameter, dimensions.Thickness);
 }
Example #11
0
        /***************************************************/

        public static double TorsionalConstant(this TubeProfile profile)
        {
            return(Math.PI * (Math.Pow(profile.Diameter, 4) - Math.Pow(profile.Diameter - 2 * profile.Thickness, 4)) / 32);
        }
Example #12
0
 private (double[], int, string) GetProfileDimensions(TubeProfile profile)
 {
     return(new double[] { profile.Diameter, 0, 0, profile.Thickness, 0, 0 }, St7.bsCircularHollow, profile.Name);
 }
Example #13
0
        /***************************************************/

        private bool SetProfile(TubeProfile profile, string sectionName, IMaterialFragment material)
        {
            return(m_model.PropFrame.SetPipe(sectionName, material?.DescriptionOrName() ?? "", profile.Diameter, profile.Thickness) == 0);
        }
Example #14
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static Autodesk.Revit.DB.Plumbing.Pipe ToRevitPipe(this oM.MEP.System.Pipe pipe, Document document, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null)
        {
            if (document == null)
            {
                return(null);
            }

            // Check valid pipe object
            if (pipe == null)
            {
                return(null);
            }

            // Construct Revit Pipe
            Autodesk.Revit.DB.Plumbing.Pipe revitPipe = refObjects.GetValue <Autodesk.Revit.DB.Plumbing.Pipe>(document, pipe.BHoM_Guid);
            if (revitPipe != null)
            {
                return(revitPipe);
            }

            // Settings
            settings = settings.DefaultIfNull();

            // Pipe type
            Autodesk.Revit.DB.Plumbing.PipeType pipeType = pipe.SectionProperty.ToRevitElementType(document, new List <BuiltInCategory> {
                BuiltInCategory.OST_PipingSystem
            }, settings, refObjects) as Autodesk.Revit.DB.Plumbing.PipeType;
            if (pipeType == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No valid family has been found in the Revit model. Pipe creation requires the presence of the default Pipe Family Type.");
                return(null);
            }

            // End points
            XYZ start = pipe.StartPoint.ToRevit();
            XYZ end   = pipe.EndPoint.ToRevit();

            // Level
            Level level = document.LevelBelow(Math.Min(start.Z, end.Z), settings);

            if (level == null)
            {
                return(null);
            }

            // Default system used for now
            // TODO: in the future you could look for the existing connectors and check if any of them overlaps with start/end of this pipe - if so, use it in Pipe.Create.
            // hacky/heavy way of getting all connectors in the link below - however, i would rather filter the connecting elements out by type/bounding box first for performance reasons
            // https://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html

            Autodesk.Revit.DB.Plumbing.PipingSystemType pst = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Plumbing.PipingSystemType)).OfType <Autodesk.Revit.DB.Plumbing.PipingSystemType>().FirstOrDefault();

            if (pst == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No valid PipingSystemType can be found in the Revit model. Creating a revit Pipe requires a PipingSystemType.");
                return(null);
            }

            BH.Engine.Reflection.Compute.RecordWarning("Pipe creation will utilise the first available PipingSystemType from the Revit model.");

            SectionProfile sectionProfile = pipe.SectionProperty.SectionProfile;

            if (sectionProfile == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Pipe creation requires a SectionProfile. \n No elements created.");
                return(null);
            }

            PipeSectionProperty pipeSectionProperty = pipe.SectionProperty;

            // Create Revit Pipe
            revitPipe = Autodesk.Revit.DB.Plumbing.Pipe.Create(document, pst.Id, pipeType.Id, level.Id, start, end);
            if (revitPipe == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No Revit Pipe has been created. Please check inputs prior to push attempt.");
                return(null);
            }

            // Copy parameters from BHoM object to Revit element
            revitPipe.CopyParameters(pipe, settings);

            double flowRate = pipe.FlowRate;

            revitPipe.SetParameter(BuiltInParameter.RBS_PIPE_FLOW_PARAM, flowRate);

            // Get first available pipeLiningType from document
            Autodesk.Revit.DB.Plumbing.PipeInsulationType pit = null;
            if (sectionProfile.InsulationProfile != null)
            {
                pit = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Plumbing.PipeInsulationType)).FirstOrDefault() as Autodesk.Revit.DB.Plumbing.PipeInsulationType;
                if (pit == null)
                {
                    BH.Engine.Reflection.Compute.RecordError("Any pipe insulation type needs to be present in the Revit model in order to push pipes with insulation.\n" +
                                                             "Pipe has been created but no insulation has been applied.");
                }
            }

            // Round Pipe
            if (sectionProfile.ElementProfile is TubeProfile)
            {
                TubeProfile elementProfile = sectionProfile.ElementProfile as TubeProfile;

                // Set Element Diameter
                double diameter = elementProfile.Diameter;
                revitPipe.SetParameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM, diameter);

                // Outer and Inner Diameters
                double outDiameter = elementProfile.Diameter;
                double inDiameter  = (((outDiameter / 2) - elementProfile.Thickness) * 2);
                revitPipe.SetParameter(BuiltInParameter.RBS_PIPE_OUTER_DIAMETER, outDiameter);
                revitPipe.SetParameter(BuiltInParameter.RBS_PIPE_INNER_DIAM_PARAM, inDiameter);

                // Set InsulationProfile
                if (pit != null)
                {
                    TubeProfile insulationProfile   = sectionProfile.InsulationProfile as TubeProfile;
                    double      insulationThickness = insulationProfile.Thickness;
                    // Create pipe Insulation
                    Autodesk.Revit.DB.Plumbing.PipeInsulation pIn = Autodesk.Revit.DB.Plumbing.PipeInsulation.Create(document, revitPipe.Id, pit.Id, insulationThickness);
                }
            }

            refObjects.AddOrReplace(pipe, revitPipe);
            return(revitPipe);
        }
Example #15
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static Duct ToRevitDuct(this oM.MEP.System.Duct duct, Document document, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null)
        {
            if (document == null)
            {
                return(null);
            }

            // Check valid duct object
            if (duct == null)
            {
                return(null);
            }

            // Construct Revit Duct
            Duct revitDuct = refObjects.GetValue <Duct>(document, duct.BHoM_Guid);

            if (revitDuct != null)
            {
                return(revitDuct);
            }

            // Settings
            settings = settings.DefaultIfNull();

            // Duct type
            DuctType ductType = duct.SectionProperty.ToRevitElementType(document, new List <BuiltInCategory> {
                BuiltInCategory.OST_DuctSystem
            }, settings, refObjects) as DuctType;

            if (ductType == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No valid family has been found in the Revit model. Duct creation requires the presence of the default Duct Family Type.");
                return(null);
            }

            // End points
            XYZ start = duct.StartPoint.ToRevit();
            XYZ end   = duct.EndPoint.ToRevit();

            // Level
            Level level = document.LevelBelow(Math.Min(start.Z, end.Z), settings);

            if (level == null)
            {
                return(null);
            }

            // Default system used for now
            // TODO: in the future you could look for the existing connectors and check if any of them overlaps with start/end of this duct - if so, use it in Duct.Create.
            // hacky/heavy way of getting all connectors in the link below - however, i would rather filter the connecting elements out by type/bounding box first for performance reasons
            // https://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html

            MechanicalSystemType mst = new FilteredElementCollector(document).OfClass(typeof(MechanicalSystemType)).OfType <MechanicalSystemType>().FirstOrDefault();

            if (mst == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No valid MechanicalSystemType can be found in the Revit model. Creating a revit Duct requires a MechanicalSystemType.");
                return(null);
            }

            BH.Engine.Reflection.Compute.RecordWarning("Duct creation will utilise the first available MechanicalSystemType from the Revit model.");

            SectionProfile sectionProfile = duct.SectionProperty?.SectionProfile;

            if (sectionProfile == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Duct creation requires a valid SectionProfile.");
                return(null);
            }

            DuctSectionProperty ductSectionProperty = duct.SectionProperty;

            // Create Revit Duct
            revitDuct = Duct.Create(document, mst.Id, ductType.Id, level.Id, start, end);
            if (revitDuct == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No Revit Duct has been created. Please check inputs prior to push attempt.");
                return(null);
            }

            // Copy parameters from BHoM object to Revit element
            revitDuct.CopyParameters(duct, settings);

            double orientationAngle = duct.OrientationAngle;

            if (Math.Abs(orientationAngle) > settings.AngleTolerance)
            {
                ElementTransformUtils.RotateElement(document, revitDuct.Id, Line.CreateBound(start, end), orientationAngle);
            }

            double flowRate = duct.FlowRate;

            revitDuct.SetParameter(BuiltInParameter.RBS_DUCT_FLOW_PARAM, flowRate);

            double hydraulicDiameter = ductSectionProperty.HydraulicDiameter;

            revitDuct.SetParameter(BuiltInParameter.RBS_HYDRAULIC_DIAMETER_PARAM, hydraulicDiameter);

            DuctLiningType dlt = null;

            if (sectionProfile.LiningProfile != null)
            {
                // Get first available ductLiningType from document
                dlt = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Mechanical.DuctLiningType)).FirstOrDefault() as Autodesk.Revit.DB.Mechanical.DuctLiningType;
                if (dlt == null)
                {
                    BH.Engine.Reflection.Compute.RecordError("Any duct lining type needs to be present in the Revit model in order to push ducts with lining.\n" +
                                                             "Duct has been created but no lining has been applied.");
                }
            }

            DuctInsulationType dit = null;

            if (sectionProfile.InsulationProfile != null)
            {
                dit = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Mechanical.DuctInsulationType)).FirstOrDefault() as Autodesk.Revit.DB.Mechanical.DuctInsulationType;
                if (dit == null)
                {
                    BH.Engine.Reflection.Compute.RecordError("Any duct insulation type needs to be present in the Revit model in order to push ducts with lining.\n" +
                                                             "Duct has been created but no insulation has been applied.");
                }
            }

            // Rectangular Duct
            if (sectionProfile.ElementProfile is BoxProfile)
            {
                BoxProfile elementProfile = sectionProfile.ElementProfile as BoxProfile;

                // Set Height
                double profileHeight = elementProfile.Height;
                revitDuct.SetParameter(BuiltInParameter.RBS_CURVE_HEIGHT_PARAM, profileHeight);

                // Set Width
                double profileWidth = elementProfile.Width;
                revitDuct.SetParameter(BuiltInParameter.RBS_CURVE_WIDTH_PARAM, profileWidth);

                // Set LiningProfile
                if (dlt != null)
                {
                    BoxProfile liningProfile   = sectionProfile.LiningProfile as BoxProfile;
                    double     liningThickness = liningProfile.Thickness;
                    // Create ductLining
                    Autodesk.Revit.DB.Mechanical.DuctLining dl = Autodesk.Revit.DB.Mechanical.DuctLining.Create(document, revitDuct.Id, dlt.Id, liningThickness);
                }

                // Set InsulationProfile
                if (dit != null)
                {
                    BoxProfile insulationProfile   = sectionProfile.InsulationProfile as BoxProfile;
                    double     insulationThickness = insulationProfile.Thickness;
                    // Create ductInsulation
                    Autodesk.Revit.DB.Mechanical.DuctInsulation di = Autodesk.Revit.DB.Mechanical.DuctInsulation.Create(document, revitDuct.Id, dit.Id, insulationThickness);
                }

                // Set EquivalentDiameter
                double circularEquivalentDiameter = ductSectionProperty.CircularEquivalentDiameter;
                revitDuct.SetParameter(BuiltInParameter.RBS_EQ_DIAMETER_PARAM, circularEquivalentDiameter);
            }
            else if (sectionProfile.ElementProfile is TubeProfile)
            {
                TubeProfile elementProfile = sectionProfile.ElementProfile as TubeProfile;

                double diameter = elementProfile.Diameter;
                revitDuct.SetParameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM, diameter);

                // Set LiningProfile
                if (dlt != null)
                {
                    TubeProfile liningProfile   = sectionProfile.LiningProfile as TubeProfile;
                    double      liningThickness = liningProfile.Thickness;
                    //Create ductLining
                    Autodesk.Revit.DB.Mechanical.DuctLining dl = Autodesk.Revit.DB.Mechanical.DuctLining.Create(document, revitDuct.Id, dlt.Id, liningThickness);
                }

                // Set InsulationProfile
                if (dit != null)
                {
                    TubeProfile insulationProfile   = sectionProfile.InsulationProfile as TubeProfile;
                    double      insulationThickness = insulationProfile.Thickness;
                    // Create ductInsulation
                    Autodesk.Revit.DB.Mechanical.DuctInsulation di = Autodesk.Revit.DB.Mechanical.DuctInsulation.Create(document, revitDuct.Id, dit.Id, insulationThickness);
                }
            }

            refObjects.AddOrReplace(duct, revitDuct);
            return(revitDuct);
        }