public static SectionProfile SectionProfile(BoxProfile boxProfile, double liningThickness, double insulationThickness) { //Internal offset of original ShapeProfile IProfile liningProfile = null; if (liningThickness <= 0) { liningProfile = null; } else { liningProfile = BH.Engine.Spatial.Create.BoxProfile((boxProfile.Height - (boxProfile.Thickness * 2)), (boxProfile.Width - (boxProfile.Thickness * 2)), liningThickness, boxProfile.OuterRadius, boxProfile.InnerRadius); } //External offset of original ShapeProfile IProfile insulationProfile = null; if (insulationThickness <= 0) { insulationProfile = null; } else { insulationProfile = BH.Engine.Spatial.Create.BoxProfile((boxProfile.Height + (insulationThickness * 2)), (boxProfile.Width + (insulationThickness * 2)), insulationThickness, boxProfile.InnerRadius, boxProfile.OuterRadius); } return(new SectionProfile(boxProfile, liningProfile, insulationProfile)); }
public static string Description(this BoxProfile profile) { if (profile == null) { return("null profile"); } return($"Box {profile.Height:G3}x{profile.Width:G3}x{profile.Thickness:G3}"); }
/***************************************************/ public static BoxProfile InterpolateProfile(BoxProfile startProfile, BoxProfile endProfile, double parameter, int interpolationOrder, double domainStart = 0, double domainEnd = 1) { return(Create.BoxProfile( Interpolate(startProfile.Height, endProfile.Height, parameter, interpolationOrder, domainStart, domainEnd), Interpolate(startProfile.Width, endProfile.Width, parameter, interpolationOrder, domainStart, domainEnd), Interpolate(startProfile.Thickness, endProfile.Thickness, parameter, interpolationOrder, domainStart, domainEnd), Interpolate(startProfile.OuterRadius, endProfile.OuterRadius, parameter, interpolationOrder, domainStart, domainEnd), Interpolate(startProfile.InnerRadius, endProfile.InnerRadius, parameter, interpolationOrder, domainStart, domainEnd))); }
/***************************************************/ public static double TorsionalConstant(this BoxProfile profile) { double tf1 = profile.Thickness; double tw = profile.Thickness; double width = profile.Width; double height = profile.Height; return(2 * tf1 * tw * Math.Pow(width - tw, 2) * Math.Pow(height - tf1, 2) / (width * tw + height * tf1 - Math.Pow(tw, 2) - Math.Pow(tf1, 2))); }
public static double CircularEquivalentDiameter(this BoxProfile box) { if (box == null) { BH.Engine.Reflection.Compute.RecordError("Cannot query the circular equivalent diameter of a null box profile."); return(-1); } double a = 1000 * (box.Height - 2 * box.Thickness); double b = 1000 * (box.Width - 2 * box.Thickness); return((1.30 * Math.Pow(a * b, 0.625) / Math.Pow(a + b, 0.250)) / 1000); }
/***************************************************/ private bool CreateProfile(string name, BoxProfile profile) { List <double> dimensionList = new List <double> { profile.Width, profile.Height, profile.Thickness, profile.InnerRadius }; double[] dimensionArray = dimensionList.ToArray(); //List<string> valueList = new List<string> { "B", "D", "t", "r" }; int lusasType = 2; CreateLibrarySection(name, dimensionArray, lusasType); return(true); }
public static double TorsionalConstant(this BoxProfile profile) { if (profile.IsNull()) { return(0); } double t = profile.Thickness; double width = profile.Width; double height = profile.Height; double rc = (profile.OuterRadius + profile.InnerRadius) / 2; double h = 2 * ((width - t) + (height - t)) - 2 * rc * (4 - Math.PI); double ah = (width - t) * (height - t) - Math.Pow(rc, 2) * (4 - Math.PI); double k = 2 * ah * t / h; return(Math.Pow(t, 3) * h / 3 + 2 * k * ah); }
public static double WarpingConstant(this BoxProfile profile) { return(profile.IsNull() ? 0 : 0); }
public static double WarpingConstant(this BoxProfile profile) { return(0); }
/***************************************************/ /**** Public methods ****/ /***************************************************/ public static Autodesk.Revit.DB.Electrical.CableTray ToRevitCableTray(this oM.MEP.System.CableTray cableTray, Document document, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null) { if (document == null) { return(null); } // Check valid cableTray object if (cableTray == null) { return(null); } // Construct Revit Cable Tray Autodesk.Revit.DB.Electrical.CableTray revitTray = refObjects.GetValue <Autodesk.Revit.DB.Electrical.CableTray>(document, cableTray.BHoM_Guid); if (revitTray != null) { return(revitTray); } // Settings settings = settings.DefaultIfNull(); // CableTray type Autodesk.Revit.DB.Electrical.CableTrayType trayType = cableTray.SectionProperty.ToRevitElementType(document, new List <BuiltInCategory> { BuiltInCategory.OST_CableTrayRun }, settings, refObjects) as Autodesk.Revit.DB.Electrical.CableTrayType; if (trayType == null) { BH.Engine.Reflection.Compute.RecordError("No valid family has been found in the Revit model. CableTray creation requires the presence of the default CableTray Family Type."); return(null); } // End points XYZ start = cableTray.StartPoint.ToRevit(); XYZ end = cableTray.EndPoint.ToRevit(); // Level Level level = document.LevelBelow(Math.Min(start.Z, end.Z), settings); if (level == null) { return(null); } SectionProfile sectionProfile = cableTray.SectionProperty?.SectionProfile; BoxProfile elementProfile = sectionProfile.ElementProfile as BoxProfile; if (elementProfile == null) { return(null); } revitTray = Autodesk.Revit.DB.Electrical.CableTray.Create(document, trayType.Id, start, end, level.Id); if (revitTray == null) { BH.Engine.Reflection.Compute.RecordError("No Revit CableTray has been created. Please check inputs prior to push attempt."); return(null); } // Copy parameters from BHoM object to Revit element revitTray.CopyParameters(cableTray, settings); // Set Orientation angle double orientationAngle = cableTray.OrientationAngle; if (Math.Abs(orientationAngle) > settings.AngleTolerance) { ElementTransformUtils.RotateElement(document, revitTray.Id, Line.CreateBound(start, end), orientationAngle); } // Set Height double profileHeight = elementProfile.Height; revitTray.SetParameter(BuiltInParameter.RBS_CABLETRAY_HEIGHT_PARAM, profileHeight); // Set Width double profileWidth = elementProfile.Width; revitTray.SetParameter(BuiltInParameter.RBS_CABLETRAY_WIDTH_PARAM, profileWidth); refObjects.AddOrReplace(cableTray, revitTray); return(revitTray); }
/***************************************************/ private bool SetProfile(BoxProfile bhomProfile, string sectionName, string matName) { int ret = m_model.PropFrame.SetTube(sectionName, matName, bhomProfile.Height, bhomProfile.Width, bhomProfile.Thickness, bhomProfile.Thickness); return(ret == 0); }
private static void SetSpecificDimensions(BoxProfile dimensions, string sectionName, IMaterialFragment material, cSapModel model) { model.PropFrame.SetTube(sectionName, material.Name, dimensions.Height, dimensions.Width, dimensions.Thickness, dimensions.Thickness); }
/***************************************************/ private bool SetProfile(BoxProfile profile, string sectionName, IMaterialFragment material) { return(m_model.PropFrame.SetTube(sectionName, material?.DescriptionOrName() ?? "", profile.Height, profile.Width, profile.Thickness, profile.Thickness) == 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); }
/***************************************************/ public static string Description(this BoxProfile profile) { return("Box " + profile.Height + "x" + profile.Width + "x" + profile.Thickness); }
public static double Thickness(this BoxProfile boxProfile) { return(boxProfile.Thickness); }
private (double[], int, string) GetProfileDimensions(BoxProfile profile) { return(new double[] { profile.Width, profile.Height, 0, profile.Thickness, profile.Thickness, 0 }, St7.bsSquareHollow, profile.Name); }