/// <summary> /// Creates list of cref="ICalculationObject". /// </summary> /// <param name="category">Category of the element.</param> /// <param name="material">Material of the element.</param> /// <returns>List of cref="ICalculationObject".</returns> public List <ICalculationObject> CalculationScenarioList(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material) { List <ICalculationObject> scenario = new List <ICalculationObject>(); /// <structural_toolkit_2015> switch (material) { case StructuralAssetClass.Concrete: switch (category) { case BuiltInCategory.OST_BeamAnalytical: case BuiltInCategory.OST_ColumnAnalytical: { PrepareSectionData calcObj = new PrepareSectionData(); calcObj.Type = CalculationObjectType.Section; calcObj.ErrorResponse = ErrorResponse.SkipOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_BeamAnalytical, BuiltInCategory.OST_ColumnAnalytical }; scenario.Add(calcObj); } { ModifyElementForces calcObj = new ModifyElementForces(); calcObj.Type = CalculationObjectType.Element; calcObj.ErrorResponse = ErrorResponse.SkipOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_BeamAnalytical, BuiltInCategory.OST_ColumnAnalytical }; scenario.Add(calcObj); } { CalculateSection calcObj = new CalculateSection(); calcObj.Type = CalculationObjectType.Section; calcObj.ErrorResponse = ErrorResponse.SkipOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_BeamAnalytical, BuiltInCategory.OST_ColumnAnalytical }; scenario.Add(calcObj); } { CalculateDeflection calcObj = new CalculateDeflection(); calcObj.Type = CalculationObjectType.Element; calcObj.ErrorResponse = ErrorResponse.SkipOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_BeamAnalytical }; scenario.Add(calcObj); } { FillResultData calcObj = new FillResultData(); calcObj.Type = CalculationObjectType.Element; calcObj.ErrorResponse = ErrorResponse.RunOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_BeamAnalytical, BuiltInCategory.OST_ColumnAnalytical }; scenario.Add(calcObj); } break; case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: { PrepareSectionData calcObj = new PrepareSectionData(); calcObj.Type = CalculationObjectType.Section; calcObj.ErrorResponse = ErrorResponse.SkipOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_FloorAnalytical, BuiltInCategory.OST_FoundationSlabAnalytical, BuiltInCategory.OST_WallAnalytical }; scenario.Add(calcObj); } { ModifyElementForces calcObj = new ModifyElementForces(); calcObj.Type = CalculationObjectType.Element; calcObj.ErrorResponse = ErrorResponse.SkipOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_FloorAnalytical, BuiltInCategory.OST_FoundationSlabAnalytical, BuiltInCategory.OST_WallAnalytical }; scenario.Add(calcObj); } { CalculateSection calcObj = new CalculateSection(); calcObj.Type = CalculationObjectType.Section; calcObj.ErrorResponse = ErrorResponse.SkipOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_FloorAnalytical, BuiltInCategory.OST_FoundationSlabAnalytical, BuiltInCategory.OST_WallAnalytical }; scenario.Add(calcObj); } { FillResultData calcObj = new FillResultData(); calcObj.Type = CalculationObjectType.Element; calcObj.ErrorResponse = ErrorResponse.RunOnError; calcObj.Categories = new List <BuiltInCategory>() { BuiltInCategory.OST_FloorAnalytical, BuiltInCategory.OST_FoundationSlabAnalytical, BuiltInCategory.OST_WallAnalytical }; scenario.Add(calcObj); } break; } break; } /// </structural_toolkit_2015> return(scenario); }
protected override void TrySolveInstance(IGH_DataAccess DA) { if (!Parameters.Document.GetDataOrDefault(this, DA, "Document", out var doc)) { return; } // get required input (name, class) string name = default; if (!DA.GetData("Name", ref name)) { return; } DB.StructuralAssetClass assetClass = default; if (!DA.GetData("Type", ref assetClass)) { return; } using (var transaction = NewTransaction(doc)) { try { // check naming conflicts with other asset types DB.PropertySetElement psetElement = FindPropertySetElement(doc, name); if (psetElement != null && psetElement.Id != DB.ElementId.InvalidElementId) { if (!MatchesPhysicalAssetType(psetElement)) { AddRuntimeMessage( GH_RuntimeMessageLevel.Error, $"Thermal asset with same name exists already. Use a different name for this asset" ); return; } } transaction.Start(); // delete existing matching psetelement if (psetElement != null && psetElement.Id != DB.ElementId.InvalidElementId) { doc.Delete(psetElement.Id); } // creaet asset from input data var structAsset = new DB.StructuralAsset(name, assetClass); // we need to apply the behaviour here manually // otherwise the resultant DB.PropertySetElement will be missing parameters DB.StructuralBehavior behaviour = default; if (DA.GetData("Behaviour", ref behaviour)) { structAsset.Behavior = behaviour; } else { structAsset.Behavior = DB.StructuralBehavior.Isotropic; } // set the asset on psetelement psetElement = DB.PropertySetElement.Create(doc, structAsset); // grab asset data from inputs var assetData = CreateAssetDataFromInputs(DA); UpdatePropertySetElementFromData(psetElement, assetData); // send the new asset to output DA.SetData( ComponentInfo.Name, psetElement ); } catch (Exception ex) { transaction.RollBack(); AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Revit API Error | {ex.Message}"); } transaction.Commit(); } }
/// <summary> /// Creates new instance of class with results for the element. /// </summary> /// <param name="category">Category of the element.</param> /// <param name="material">Material of the element.</param> /// <returns>User result schema object for the element.</returns> public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass CreateElementResult(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material) { switch (material) { case StructuralAssetClass.Concrete: switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return(new ResultBeam()); case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return(new ResultColumn()); } break; case StructuralAssetClass.Metal: break; } return(null); }
/// <summary> /// Reads parameters of user element label. /// </summary> /// <param name="category">Category of the element.</param> /// <param name="material">Material of the element.</param> /// <param name="label">Acces to the Revit storage with labels."</param> /// <param name="data">Acces to cref="ServiceData".</param> /// <returns>User label of the element.</returns> public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass ReadElementLabel(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material, Autodesk.Revit.DB.CodeChecking.Storage.Label label, Autodesk.Revit.DB.CodeChecking.ServiceData data) { if (label != null) { switch (material) { case StructuralAssetClass.Concrete: switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return(label.GetEntity <LabelColumn>(data.Document)); case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return(label.GetEntity <LabelBeam>(data.Document)); } break; case StructuralAssetClass.Metal: break; } } return(null); }
/// <summary> /// Creates new instance of class with results for the element. /// </summary> /// <param name="category">Category of the element.</param> /// <param name="material">Material of the element.</param> /// <returns>User result schema object for the element.</returns> public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass CreateElementResult(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material) { switch (material) { case StructuralAssetClass.Concrete: switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return(new ResultBeam()); case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return(new ResultColumn()); /// <structural_toolkit_2015> case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: return(new ResultFloor()); case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: return(new ResultFloor()); case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: return(new ResultWall()); /// </structural_toolkit_2015> } break; case StructuralAssetClass.Metal: break; } return(null); }