/// <summary> /// Update or create the properties of a Nucleus section family from a GWA string /// </summary> /// <param name="gwa"></param> /// <param name="model"></param> /// <param name="context"></param> public void ReadSection(string gwa, Model.Model model, GSAConversionContext context) { // PROP_SEC | num | name | colour | mat | desc | principal | type | cost | // is_prop { | area | I11 | I22 | J | K1 | K2 } | // is_mod { | area_to_by | area_m | I11_to_by | I11_m | I22_to_by | I22_m | J_to_by | J_m | K1_to_by | K1_m | K2_to_by | K2_m | mass | stress } | // plate_type | calc_J var tr = new TokenReader(gwa); tr.Next(); // PROP_SEC string gsaID = tr.Next(); // num var sec = context.IDMap.GetModelObject <SectionFamily>(model, gsaID); if (sec == null) { sec = model.Create.SectionFamily(); } sec.Name = tr.Next(); // name tr.Next(); // colour string matID = tr.Next(); // mat var material = context.IDMap.GetModelObject <Material>(model, matID); //TODO: profile description SectionProfile profile = ReadProfile(tr.Next(), context); //desc if (profile != null) { profile.Material = material; sec.Profile = profile; } context.IDMap.Add(sec, gsaID); }
public static BH.oM.MEP.System.SectionProperties.PipeSectionProperty PipeSectionProperty(this Autodesk.Revit.DB.Plumbing.Pipe pipe, RevitSettings settings = null) { settings = settings.DefaultIfNull(); IProfile profile = pipe.Profile(settings); double liningThickness = pipe.LookupParameterDouble(BuiltInParameter.RBS_REFERENCE_LINING_THICKNESS); // Extract the lining thk from Duct element if (liningThickness == double.NaN) { liningThickness = 0; } double insulationThickness = pipe.LookupParameterDouble(BuiltInParameter.RBS_REFERENCE_INSULATION_THICKNESS); // Extract the lining thk from Duct element if (insulationThickness == double.NaN) { insulationThickness = 0; } SectionProfile sectionProfile = BH.Engine.MEP.Create.SectionProfile((TubeProfile)profile, liningThickness, insulationThickness); PipeSectionProperty result = BH.Engine.MEP.Create.PipeSectionProperty(sectionProfile); return(result); }
public override bool Execute(ExecutionInfo exInfo = null) { SectionProfile profile = SectionProfile.FromDescription(Description, Core.Instance.SectionLibrary); profile.Material = Material; Section = Model.Create.SectionFamily(Name, exInfo); Section.Profile = profile; return(true); }
public static BH.oM.MEP.System.SectionProperties.DuctSectionProperty DuctSectionProperty(this Autodesk.Revit.DB.Mechanical.Duct revitDuct, RevitSettings settings = null) { settings = settings.DefaultIfNull(); // Duct section profile SectionProfile sectionProfile = revitDuct.DuctSectionProfile(settings); // Duct section property return(BH.Engine.MEP.Create.DuctSectionProperty(sectionProfile)); }
public static BH.oM.MEP.System.SectionProperties.CableTraySectionProperty CableTraySectionProperty(this Autodesk.Revit.DB.Electrical.CableTray revitCableTray, RevitSettings settings = null) { settings = settings.DefaultIfNull(); // Cable Tray section profile SectionProfile sectionProfile = revitCableTray.CableTraySectionProfile(settings); // Cable Tray section property return(BH.Engine.MEP.Create.CableTraySectionProperty(new oM.Physical.Materials.Material(), sectionProfile)); }
public static DuctSectionProperty DuctSectionProperty(SectionProfile sectionProfile, Material ductMaterial = null, Material insulationMaterial = null, Material liningMaterial = null, string name = "") { if (sectionProfile == null) { BH.Engine.Reflection.Compute.RecordError("Cannot create a duct section property with a null section profile."); return(null); } double elementSolidArea = sectionProfile.ElementProfile.Area(); double elementVoidArea = sectionProfile.ElementProfile.VoidArea(); double liningSolidArea = 0; double liningVoidArea = double.NaN; double insulationSolidArea = 0; double insulationVoidArea = double.NaN; if (sectionProfile.LiningProfile != null) { liningSolidArea = sectionProfile.LiningProfile.Area(); liningVoidArea = sectionProfile.LiningProfile.VoidArea(); } if (sectionProfile.InsulationProfile != null) { insulationSolidArea = sectionProfile.InsulationProfile.Area(); insulationVoidArea = sectionProfile.InsulationProfile.VoidArea(); } //Duct specific properties double circularEquivalent = sectionProfile.ElementProfile.ICircularEquivalentDiameter(); double hydraulicDiameter = sectionProfile.ElementProfile.HydraulicDiameter(liningVoidArea); DuctSectionProperty property = new DuctSectionProperty(sectionProfile, elementSolidArea, liningSolidArea, insulationSolidArea, elementVoidArea, liningVoidArea, insulationVoidArea, hydraulicDiameter, circularEquivalent); property.DuctMaterial = ductMaterial; property.InsulationMaterial = insulationMaterial; property.LiningMaterial = liningMaterial; property.Name = name; if (property == null) { BH.Engine.Reflection.Compute.RecordError("Insufficient information to create a DuctSectionProperty. Please ensure you have all required inputs."); } return(property); }
public static PipeSectionProperty PipeSectionProperty(SectionProfile sectionProfile, Material pipeMaterial = null, Material insulationMaterial = null, string name = "") { if (sectionProfile == null) { BH.Engine.Reflection.Compute.RecordError("Cannot create a pipe section property with a null section profile."); return(null); } double elementSolidArea = sectionProfile.ElementProfile.Area(); double elementVoidArea = sectionProfile.ElementProfile.VoidArea(); double liningSolidArea = 0; double liningVoidArea = double.NaN; double insulationSolidArea = 0; double insulationVoidArea = double.NaN; if (sectionProfile.LiningProfile != null) { liningSolidArea = sectionProfile.LiningProfile.Area(); liningVoidArea = sectionProfile.LiningProfile.VoidArea(); } if (sectionProfile.InsulationProfile != null) { insulationSolidArea = sectionProfile.InsulationProfile.Area(); insulationVoidArea = sectionProfile.InsulationProfile.VoidArea(); } PipeSectionProperty property = new PipeSectionProperty(sectionProfile, elementSolidArea, liningSolidArea, insulationSolidArea, elementVoidArea, liningVoidArea, insulationVoidArea); property.PipeMaterial = pipeMaterial; property.InsulationMaterial = insulationMaterial; property.Name = name; if (property == null) { BH.Engine.Reflection.Compute.RecordError("Insufficient information to create a PipeSectionProperty. Please ensure you have all required inputs."); } return(property); }
private Element1D AnalyticalStickToSpeckle(AnalyticalModelStick revitStick) { if (!revitStick.IsEnabled()) { return(new Element1D()); } var speckleElement1D = new Element1D(); switch (revitStick.Category.Name) { case "Analytical Columns": speckleElement1D.type = ElementType1D.Column; break; case "Analytical Beams": speckleElement1D.type = ElementType1D.Beam; break; case "Analytical Braces": speckleElement1D.type = ElementType1D.Brace; break; default: speckleElement1D.type = ElementType1D.Other; break; } var curves = revitStick.GetCurves(AnalyticalCurveType.RigidLinkHead).ToList(); curves.AddRange(revitStick.GetCurves(AnalyticalCurveType.ActiveCurves)); curves.AddRange(revitStick.GetCurves(AnalyticalCurveType.RigidLinkTail)); if (curves.Count > 1) { speckleElement1D.baseLine = null; } else { speckleElement1D.baseLine = (Objects.Geometry.Line)CurveToSpeckle(curves[0]); } var coordinateSystem = revitStick.GetLocalCoordinateSystem(); if (coordinateSystem != null) { speckleElement1D.localAxis = new Geometry.Plane(PointToSpeckle(coordinateSystem.Origin), VectorToSpeckle(coordinateSystem.BasisZ), VectorToSpeckle(coordinateSystem.BasisX), VectorToSpeckle(coordinateSystem.BasisY)); } var startOffset = revitStick.GetOffset(AnalyticalElementSelector.StartOrBase); var endOffset = revitStick.GetOffset(AnalyticalElementSelector.EndOrTop); speckleElement1D.end1Offset = VectorToSpeckle(startOffset); speckleElement1D.end2Offset = VectorToSpeckle(endOffset); var startRelease = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_START_RELEASE_TYPE); var endRelease = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_END_RELEASE_TYPE); if (startRelease == 0) { speckleElement1D.end1Releases = new Restraint(RestraintType.Fixed); } else { var botReleaseX = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FX) == 1 ? "R" : "F"; var botReleaseY = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FY) == 1 ? "R" : "F"; var botReleaseZ = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FZ) == 1 ? "R" : "F"; var botReleaseXX = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MX) == 1 ? "R" : "F"; var botReleaseYY = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MY) == 1 ? "R" : "F"; var botReleaseZZ = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MZ) == 1 ? "R" : "F"; string botReleaseCode = botReleaseX + botReleaseY + botReleaseZ + botReleaseXX + botReleaseYY + botReleaseZZ; speckleElement1D.end1Releases = new Restraint(botReleaseCode); } if (endRelease == 0) { speckleElement1D.end2Releases = new Restraint(RestraintType.Fixed); } else { var topReleaseX = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_FX) == 1 ? "R" : "F"; var topReleaseY = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_FY) == 1 ? "R" : "F"; var topReleaseZ = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_FZ) == 1 ? "R" : "F"; var topReleaseXX = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_MX) == 1 ? "R" : "F"; var topReleaseYY = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_MY) == 1 ? "R" : "F"; var topReleaseZZ = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_MZ) == 1 ? "R" : "F"; string topReleaseCode = topReleaseX + topReleaseY + topReleaseZ + topReleaseXX + topReleaseYY + topReleaseZZ; speckleElement1D.end2Releases = new Restraint(topReleaseCode); } var prop = new Property1D(); var stickFamily = (Autodesk.Revit.DB.FamilyInstance)Doc.GetElement(revitStick.GetElementId()); var section = stickFamily.Symbol.GetStructuralSection(); var speckleSection = new SectionProfile(); speckleSection.name = section.StructuralSectionShapeName; switch (section.StructuralSectionGeneralShape) { case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralI: // Double T structural sections var ISection = new ISection(); ISection.name = section.StructuralSectionShapeName; ISection.shapeType = Structural.ShapeType.I; ISection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("Height").GetValue(section); ISection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("Width").GetValue(section); ISection.webThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("WebThickness").GetValue(section); ISection.flangeThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("FlangeThickness").GetValue(section); ISection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("SectionArea").GetValue(section); ISection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("NominalWeight").GetValue(section); ISection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); ISection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); ISection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = ISection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralT: // Tees structural sections var teeSection = new Tee(); teeSection.name = section.StructuralSectionShapeName; teeSection.shapeType = Structural.ShapeType.I; teeSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("Height").GetValue(section); teeSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("Width").GetValue(section); teeSection.webThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("WebThickness").GetValue(section); teeSection.flangeThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("FlangeThickness").GetValue(section); teeSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("SectionArea").GetValue(section); teeSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("NominalWeight").GetValue(section); teeSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); teeSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); teeSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = teeSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralH: // Rectangular Pipe structural sections var rectSection = new Rectangular(); rectSection.name = section.StructuralSectionShapeName; rectSection.shapeType = Structural.ShapeType.I; rectSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("Height").GetValue(section); rectSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("Width").GetValue(section); var wallThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("WallNominalThickness").GetValue(section); rectSection.webThickness = wallThickness; rectSection.flangeThickness = wallThickness; rectSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("SectionArea").GetValue(section); rectSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("NominalWeight").GetValue(section); rectSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); rectSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); rectSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = rectSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralR: // Pipe structural sections var circSection = new Circular(); circSection.name = section.StructuralSectionShapeName; circSection.shapeType = Structural.ShapeType.Circular; circSection.radius = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("Diameter").GetValue(section) / 2; circSection.wallThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("WallNominalThickness").GetValue(section); circSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("SectionArea").GetValue(section); circSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("NominalWeight").GetValue(section); circSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); circSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); circSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = circSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralF: // Flat Bar structural sections var flatRectSection = new Rectangular(); flatRectSection.name = section.StructuralSectionShapeName; flatRectSection.shapeType = Structural.ShapeType.I; flatRectSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("Height").GetValue(section); flatRectSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("Width").GetValue(section); flatRectSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("SectionArea").GetValue(section); flatRectSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("NominalWeight").GetValue(section); flatRectSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); flatRectSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); flatRectSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = flatRectSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralS: // Round Bar structural sections var flatCircSection = new Circular(); flatCircSection.name = section.StructuralSectionShapeName; flatCircSection.shapeType = Structural.ShapeType.Circular; flatCircSection.radius = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("Diameter").GetValue(section) / 2; flatCircSection.wallThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("WallNominalThickness").GetValue(section); flatCircSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("SectionArea").GetValue(section); flatCircSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("NominalWeight").GetValue(section); flatCircSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); flatCircSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); flatCircSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = flatCircSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralW: // Angle structural sections var angleSection = new Angle(); angleSection.name = section.StructuralSectionShapeName; angleSection.shapeType = Structural.ShapeType.Angle; angleSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("Height").GetValue(section); angleSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("Width").GetValue(section); angleSection.webThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("WebThickness").GetValue(section); angleSection.flangeThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("FlangeThickness").GetValue(section); angleSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("SectionArea").GetValue(section); angleSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("NominalWeight").GetValue(section); angleSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); angleSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); angleSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = angleSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralU: // Channel structural sections var channelSection = new Channel(); channelSection.name = section.StructuralSectionShapeName; channelSection.shapeType = Structural.ShapeType.Channel; channelSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("Height").GetValue(section); channelSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("Width").GetValue(section); channelSection.webThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("WebThickness").GetValue(section); channelSection.flangeThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("FlangeThickness").GetValue(section); channelSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("SectionArea").GetValue(section); channelSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("NominalWeight").GetValue(section); channelSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); channelSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); channelSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = channelSection; break; default: speckleSection.name = section.StructuralSectionShapeName; break; } var materialType = stickFamily.StructuralMaterialType; var structMat = (DB.Material)Doc.GetElement(stickFamily.StructuralMaterialId); if (structMat == null) { structMat = (DB.Material)Doc.GetElement(stickFamily.Symbol.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM).AsElementId()); } var materialAsset = ((PropertySetElement)Doc.GetElement(structMat.StructuralAssetId)).GetStructuralAsset(); Structural.Materials.Material speckleMaterial = null; switch (materialType) { case StructuralMaterialType.Concrete: var concreteMaterial = new Concrete { name = Doc.GetElement(stickFamily.StructuralMaterialId).Name, //type = Structural.MaterialType.Concrete, grade = null, designCode = null, codeYear = null, elasticModulus = materialAsset.YoungModulus.X, compressiveStrength = materialAsset.ConcreteCompression, tensileStrength = 0, flexuralStrength = 0, maxCompressiveStrain = 0, maxTensileStrain = 0, maxAggregateSize = 0, lightweight = materialAsset.Lightweight, poissonsRatio = materialAsset.PoissonRatio.X, shearModulus = materialAsset.ShearModulus.X, density = materialAsset.Density, thermalExpansivity = materialAsset.ThermalExpansionCoefficient.X, dampingRatio = 0 }; speckleMaterial = concreteMaterial; break; case StructuralMaterialType.Steel: var steelMaterial = new Steel { name = Doc.GetElement(stickFamily.StructuralMaterialId).Name, //type = Structural.MaterialType.Steel, grade = materialAsset.Name, designCode = null, codeYear = null, elasticModulus = materialAsset.YoungModulus.X, // Newtons per foot meter yieldStrength = materialAsset.MinimumYieldStress, // Newtons per foot meter ultimateStrength = materialAsset.MinimumTensileStrength, // Newtons per foot meter maxStrain = 0, poissonsRatio = materialAsset.PoissonRatio.X, shearModulus = materialAsset.ShearModulus.X, // Newtons per foot meter density = materialAsset.Density, // kilograms per cubed feet thermalExpansivity = materialAsset.ThermalExpansionCoefficient.X, // inverse Kelvin dampingRatio = 0 }; speckleMaterial = steelMaterial; break; case StructuralMaterialType.Wood: var timberMaterial = new Timber { name = Doc.GetElement(structMat.StructuralAssetId).Name, //type = Structural.MaterialType.Timber, grade = materialAsset.WoodGrade, designCode = null, codeYear = null, elasticModulus = materialAsset.YoungModulus.X, // Newtons per foot meter poissonsRatio = materialAsset.PoissonRatio.X, shearModulus = materialAsset.ShearModulus.X, // Newtons per foot meter density = materialAsset.Density, // kilograms per cubed feet thermalExpansivity = materialAsset.ThermalExpansionCoefficient.X, // inverse Kelvin species = materialAsset.WoodSpecies, dampingRatio = 0 }; timberMaterial["bendingStrength"] = materialAsset.WoodBendingStrength; timberMaterial["parallelCompressionStrength"] = materialAsset.WoodParallelCompressionStrength; timberMaterial["parallelShearStrength"] = materialAsset.WoodParallelShearStrength; timberMaterial["perpendicularCompressionStrength"] = materialAsset.WoodPerpendicularCompressionStrength; timberMaterial["perpendicularShearStrength"] = materialAsset.WoodPerpendicularShearStrength; speckleMaterial = timberMaterial; break; default: var defaultMaterial = new Objects.Structural.Materials.Material { name = Doc.GetElement(stickFamily.StructuralMaterialId).Name }; speckleMaterial = defaultMaterial; break; } prop.profile = speckleSection; prop.material = speckleMaterial; prop.name = Doc.GetElement(revitStick.GetElementId()).Name; var structuralElement = Doc.GetElement(revitStick.GetElementId()); var mark = GetParamValue <string>(structuralElement, BuiltInParameter.ALL_MODEL_MARK); if (revitStick is AnalyticalModelColumn) { speckleElement1D.type = ElementType1D.Column; //prop.memberType = MemberType.Column; var locationMark = GetParamValue <string>(structuralElement, BuiltInParameter.COLUMN_LOCATION_MARK); if (locationMark == null) { speckleElement1D.name = mark; } else { speckleElement1D.name = locationMark; } } else { prop.memberType = MemberType.Beam; speckleElement1D.name = mark; } speckleElement1D.property = prop; GetAllRevitParamsAndIds(speckleElement1D, revitStick); speckleElement1D.displayMesh = GetElementDisplayMesh(Doc.GetElement(revitStick.GetElementId())); return(speckleElement1D); }
/***************************************************/ /**** 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); }
public SectionProfile SectionToSpeckle(string property) { var speckleSectionProfile = new SectionProfile(); eFramePropType propType = eFramePropType.I; string catalogue = ""; string matProp = ""; string sectionPropertyName = ""; int s = Model.PropFrame.GetNameInPropFile(property, ref sectionPropertyName, ref catalogue, ref matProp, ref propType); if (s == 0) { string[] arrayCatPath = catalogue.Split('\\'); catalogue = arrayCatPath.Last(); arrayCatPath = catalogue.Split('.'); catalogue = arrayCatPath[0]; switch (propType) { case eFramePropType.SD: speckleSectionProfile = new Explicit(); break; default: speckleSectionProfile = new Catalogue(property, catalogue, propType.ToString(), sectionPropertyName); break; } return(speckleSectionProfile); } double T3 = 0; double T2 = 0; int color = 0; string notes = ""; string GUID = ""; string FileName = ""; s = Model.PropFrame.GetRectangle(property, ref FileName, ref matProp, ref T3, ref T2, ref color, ref notes, ref GUID); if (s == 0) { speckleSectionProfile = new Rectangular(property, T3, T2); } double Tf = 0; double TwF = 0; double Twt = 0; double Tw = 0; bool mirrorAbout3 = false; s = Model.PropFrame.GetConcreteTee(property, ref FileName, ref matProp, ref T3, ref T2, ref Tf, ref TwF, ref Twt, ref mirrorAbout3, ref color, ref notes, ref GUID); if (s == 0) { speckleSectionProfile = new Tee(property, T3, T2, TwF, Tf); } s = Model.PropFrame.GetCircle(property, ref FileName, ref matProp, ref T3, ref color, ref notes, ref GUID); if (s == 0) { speckleSectionProfile = new Circular(property, T3 / 2); } s = Model.PropFrame.GetAngle(property, ref FileName, ref matProp, ref T3, ref T2, ref Tf, ref Tw, ref color, ref notes, ref GUID); if (s == 0) { speckleSectionProfile = new Angle(property, T3, T2, Tw, Tf); return(speckleSectionProfile); } s = Model.PropFrame.GetChannel(property, ref FileName, ref matProp, ref T3, ref T2, ref Tf, ref Tw, ref color, ref notes, ref GUID); if (s == 0) { speckleSectionProfile = new Channel(property, T3, T2, Tw, Tf); return(speckleSectionProfile); } s = Model.PropFrame.GetTube(property, ref FileName, ref matProp, ref T3, ref T2, ref Tf, ref Tw, ref color, ref notes, ref GUID); if (s == 0) { speckleSectionProfile = new Rectangular(property, T3, T2, Tw, Tf); return(speckleSectionProfile); } s = Model.PropFrame.GetPipe(property, ref FileName, ref matProp, ref T3, ref Tw, ref color, ref notes, ref GUID); if (s == 0) { speckleSectionProfile = new Circular(property, T3, Tw); return(speckleSectionProfile); } return(null); }
/***************************************************/ /**** 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); }
/***************************************************/ /**** 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 CableTraySectionProperty CableTraySectionProperty(Material material, SectionProfile sectionProfile, string name = "") { if (sectionProfile == null) { BH.Engine.Reflection.Compute.RecordError("Cannot create a cable tray section property with a null section profile."); return(null); } double elementSolidArea = sectionProfile.ElementProfile.Area(); double elementVoidArea = sectionProfile.ElementProfile.VoidArea(); CableTraySectionProperty property = new CableTraySectionProperty(material, sectionProfile, elementSolidArea, elementVoidArea); if (property == null) { BH.Engine.Reflection.Compute.RecordError("Insufficient information to create a CableTraySectionProperty. Please ensure you have all required inputs."); return(null); } property.Name = name; return(property); }