/// <summary> /// Reads from Revit selected elements identificators and collect in the list only that which has apprppriate label, material and category. /// </summary> /// <param name="server">Acces to cref="Server".</param> /// <param name="data">Acces to cref="ServiceData".</param> /// <returns>List identyficators of elements with result status.</returns> protected List <Tuple <ElementId, ResultStatus> > ReadListElementIdWithStatus(Server.Server server, Autodesk.Revit.DB.CodeChecking.ServiceData data) { Autodesk.Revit.DB.CodeChecking.Storage.StorageService service = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService(); Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(data.Document); Guid activePackageId = storageDocument.CalculationParamsManager.CalculationParams.GetInputResultPackageId(server.GetServerId()); List <Tuple <ElementId, ResultStatus> > listElementId = new List <Tuple <ElementId, ResultStatus> >(); foreach (Element element in data.Selection) { Autodesk.Revit.DB.CodeChecking.Storage.Label ccLabel = storageDocument.LabelsManager.GetLabel(element); if (ccLabel != null) { Autodesk.Revit.DB.BuiltInCategory category = (Autodesk.Revit.DB.BuiltInCategory)element.Category.Id.IntegerValue; StructuralAssetClass material = ccLabel.Material; if (server.GetSupportedMaterials().Contains(material) && server.GetSupportedCategories(material).Contains(category)) { ElementId id = new ElementId(element.Id.IntegerValue); SchemaClass label = EngineData.ReadElementLabel(category, material, ccLabel, data); ResultStatus status = new Autodesk.Revit.DB.CodeChecking.Storage.ResultStatus(Server.Server.ID, activePackageId); EngineData.VerifyElementLabel(category, material, label, ref status); listElementId.Add(new Tuple <ElementId, ResultStatus>(id, status)); } } } return(listElementId); }
/// <summary> /// Initializes a new instance of the ObjectDataBase object with list of parameters. /// </summary> /// <param name="elementId">Element identificator.</param> /// <param name="elementCategory">Element category.</param> /// <param name="elementMaterial">Element material.</param> /// <param name="elementLabel">Element label.</param> public ObjectDataBase(ElementId elementId, Autodesk.Revit.DB.BuiltInCategory elementCategory, StructuralAssetClass elementMaterial, Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass elementLabel) { category = elementCategory; material = elementMaterial; elemId = new ElementId(elementId.IntegerValue);; label = elementLabel; }
/// </structural_toolkit_2015> public override IList <BuiltInCategory> GetSupportedCategories(StructuralAssetClass material) { List <BuiltInCategory> supportedCategories = new List <BuiltInCategory>(); supportedCategories.Add(BuiltInCategory.OST_BeamAnalytical); supportedCategories.Add(BuiltInCategory.OST_ColumnAnalytical); /// <structural_toolkit_2015> supportedCategories.Add(BuiltInCategory.OST_FoundationSlabAnalytical); supportedCategories.Add(BuiltInCategory.OST_FloorAnalytical); supportedCategories.Add(BuiltInCategory.OST_WallAnalytical); /// </structural_toolkit_2015> return(supportedCategories); }
/// <structural_toolkit_2015> /// <summary> /// Gets list of elements with the given category. /// </summary> /// <param name="category">Category of the element.</param> /// <param name="material">Material of the element.</param> /// <param name="listElementData">List of elements objects</param> List <ObjectDataBase> GetListElementForCategory(BuiltInCategory category, StructuralAssetClass material, List <ObjectDataBase> listElementData) { List <ObjectDataBase> list = new List <ObjectDataBase>(); foreach (ObjectDataBase obj in listElementData) { if (obj.Category == category && obj.Material == material) { list.Add(obj); } } return(list); }
/// <summary> /// get all materials exist in current document /// </summary> /// <returns></returns> private void GetAllMaterial() { FilteredElementCollector collector = new FilteredElementCollector(m_revit.ActiveUIDocument.Document); FilteredElementIterator i = collector.OfClass(typeof(Material)).GetElementIterator(); i.Reset(); bool moreValue = i.MoveNext(); while (moreValue) { Autodesk.Revit.DB.Material material = i.Current as Autodesk.Revit.DB.Material; if (material == null) { moreValue = i.MoveNext(); continue; } //get the type of the material StructuralAssetClass materialType = GetMaterialType(material); //add materials to different ArrayList according to their types switch (materialType) { case StructuralAssetClass.Metal: { m_steels.Add(new MaterialMap(material)); break; } case StructuralAssetClass.Concrete: { m_concretes.Add(new MaterialMap(material)); break; } default: { break; } } //map between materials and their elementId m_allMaterialMap.Add(material.Id.IntegerValue, material); moreValue = i.MoveNext(); } }
/// <summary> /// Reads from Revit information about selected elements and store it in the list with elements data. /// </summary> /// <param name="data">Acces to cref="ServiceData".</param> /// <param name="listElementStatus">List identyficators of elements with result status.</param> /// <param name="parameters">Common parameters.</param> /// <returns>List of elements data.</returns> protected List <ObjectDataBase> ReadListElementData(Autodesk.Revit.DB.CodeChecking.ServiceData data, List <Tuple <ElementId, ResultStatus> > listElementStatus, CommonParametersBase parameters) { Autodesk.Revit.DB.CodeChecking.Storage.StorageService service = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService(); Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(data.Document); List <ObjectDataBase> listElementData = new List <ObjectDataBase>(); foreach (Tuple <ElementId, ResultStatus> elemStatus in listElementStatus) { Element element = data.Document.GetElement(elemStatus.Item1); if (element != null) { Autodesk.Revit.DB.CodeChecking.Storage.Label ccLabel = storageDocument.LabelsManager.GetLabel(element); if (ccLabel != null) { Autodesk.Revit.DB.BuiltInCategory category = (Autodesk.Revit.DB.BuiltInCategory)element.Category.Id.IntegerValue; StructuralAssetClass material = ccLabel.Material; Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass label = EngineData.ReadElementLabel(category, material, ccLabel, data); Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass result = EngineData.CreateElementResult(category, material); ObjectDataBase objectData = new ObjectDataBase(elemStatus.Item1, category, material, label); List <SectionDataBase> listSectionsData = new List <SectionDataBase>(); List <CalcPoint> listCalcPoints = EngineData.CreateCalcPointsForElement(data, parameters, elemStatus.Item1); foreach (CalcPoint p in listCalcPoints) { SectionDataBase sectBase = new SectionDataBase(p, objectData); SectionDataBase sectData = EngineData.CreateSectionData(sectBase); listSectionsData.Add(sectData); } ElementDataBase elemBase = new ElementDataBase(result, listCalcPoints, listSectionsData, elemStatus.Item2, data.Document, objectData); ElementDataBase elemData = EngineData.CreateElementData(elemBase); listElementData.Add(elemData); } } } return(listElementData); }
public override Entity GetDefaultLabel(Autodesk.Revit.DB.Document document, StructuralAssetClass material, BuiltInCategory category) { switch (material) { case StructuralAssetClass.Concrete: switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: { IList <ElementId> materials = RebarUtility.GetListMaterialOfRebars(document); if (materials.Count > 0) { IList <ElementId> barsIds = RebarUtility.GetListRebarForMaterial(document, materials[0]); if (barsIds.Count > 0) { LabelColumn label = new LabelColumn(); label.LongitudinalReinforcement.Material = document.GetElement(materials[0]) as Material; label.LongitudinalReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]); label.TransversalReinforcement.Material = label.LongitudinalReinforcement.Material; label.TransversalReinforcement.RebarBarType = label.LongitudinalReinforcement.RebarBarType; return(label.GetEntity()); } } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: { IList <ElementId> materials = RebarUtility.GetListMaterialOfRebars(document); if (materials.Count > 0) { IList <ElementId> barsIds = RebarUtility.GetListRebarForMaterial(document, materials[0]); if (barsIds.Count > 0) { LabelBeam label = new LabelBeam(); label.LongitudinalReinforcement.Material = document.GetElement(materials[0]) as Material; label.LongitudinalReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]); label.TransversalReinforcement.Material = label.LongitudinalReinforcement.Material; label.TransversalReinforcement.RebarBarType = label.LongitudinalReinforcement.RebarBarType; return(label.GetEntity()); } } } break; /// <structural_toolkit_2015> case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: { IList <ElementId> materials = RebarUtility.GetListMaterialOfRebars(document); if (materials.Count > 0) { IList <ElementId> barsIds = RebarUtility.GetListRebarForMaterial(document, materials[0]); if (barsIds.Count > 0) { LabelFloor label = new LabelFloor(); label.PrimaryReinforcement.Material = document.GetElement(materials[0]) as Material; label.PrimaryReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]); label.SecondaryReinforcement.Material = document.GetElement(materials[0]) as Material; label.SecondaryReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]); return(label.GetEntity()); } } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: { IList <ElementId> materials = RebarUtility.GetListMaterialOfRebars(document); if (materials.Count > 0) { IList <ElementId> barsIds = RebarUtility.GetListRebarForMaterial(document, materials[0]); if (barsIds.Count > 0) { LabelWall label = new LabelWall(); label.VerticalReinforcement.Material = document.GetElement(materials[0]) as Material; label.VerticalReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]); label.HorizontalReinforcement.Material = document.GetElement(materials[0]) as Material; label.HorizontalReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]); return(label.GetEntity()); } } } break; /// </structural_toolkit_2015> } break; } return(base.GetDefaultLabel(document, material, category)); }
/// <summary> /// get a datatable contains parameters' information of certain element /// </summary> /// <param name="o">Revit element</param> /// <param name="substanceKind">the material type of this element</param> /// <returns>datatable contains parameters' names and values</returns> public DataTable GetParameterTable(object o, StructuralAssetClass substanceKind) { //create an empty datatable DataTable parameterTable = CreateTable(); //if failed to convert object Autodesk.Revit.DB.Material material = o as Autodesk.Revit.DB.Material; if (material == null) { return(parameterTable); } Parameter temporaryAttribute = null; // hold each parameter string temporaryValue = ""; // hold each value #region Get all material element parameters //- Behavior temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_BEHAVIOR); switch (temporaryAttribute.AsInteger()) { case 0: AddDataRow(temporaryAttribute.Definition.Name, "Isotropic", parameterTable); break; case 1: AddDataRow(temporaryAttribute.Definition.Name, "Orthotropic", parameterTable); break; default: AddDataRow(temporaryAttribute.Definition.Name, "None", parameterTable); break; } //- Young's Modulus temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD1); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD2); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD3); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); // - Poisson Modulus temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD1); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD2); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_POISSON_MOD3); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); // - Shear Modulus temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD1); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD2); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_MOD3); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); //- Thermal Expansion Coefficient temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF1); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF2); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_EXP_COEFF3); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); //- Unit Weight temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_UNIT_WEIGHT); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); //- Bending Reinforcement temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_BENDING_REINFORCEMENT); if (null != temporaryAttribute) { temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); } //- Shear Reinforcement temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_REINFORCEMENT); if (null != temporaryAttribute) { temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); } //- Resistance Calc Strength temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_RESISTANCE_CALC_STRENGTH); if (null != temporaryAttribute) { temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); } // For Steel only: if (StructuralAssetClass.Metal == substanceKind) { //- Minimum Yield Stress temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_MINIMUM_YIELD_STRESS); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); //- Minimum Tensile Strength temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_MINIMUM_TENSILE_STRENGTH); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); //- Reduction Factor temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_REDUCTION_FACTOR); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); } // For Concrete only: if (StructuralAssetClass.Concrete == substanceKind) { //- Concrete Compression temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CONCRETE_COMPRESSION); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); //- Lightweight temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_LIGHT_WEIGHT); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); //- Shear Strength Reduction temporaryAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_SHEAR_STRENGTH_REDUCTION); temporaryValue = temporaryAttribute.AsValueString(); AddDataRow(temporaryAttribute.Definition.Name, temporaryValue, parameterTable); } #endregion return(parameterTable); }
/// <summary> /// Verify 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">Element label."</param> /// <param name="status">Reference to element's status".</param> public void VerifyElementLabel(Autodesk.Revit.DB.BuiltInCategory category, StructuralAssetClass material, Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass label, ref Autodesk.Revit.DB.CodeChecking.Storage.ResultStatus status) { if (label != null) { switch (material) { case StructuralAssetClass.Concrete: switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: { LabelColumn labelCol = label as LabelColumn; if (labelCol != null) { if (labelCol.EnabledInternalForces.Count == 0) { status.AddError(Resources.ResourceManager.GetString("ErrNoChosenInternalForces")); } List <string> errors = VerifySteel(labelCol.LongitudinalReinforcement, true); foreach (string s in errors) { status.AddError(s); } errors = VerifySteel(labelCol.TransversalReinforcement, false); foreach (string s in errors) { status.AddError(s); } } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: { LabelBeam labelBm = label as LabelBeam; if (labelBm != null) { if (labelBm.EnabledInternalForces.Count == 0) { status.AddError(Resources.ResourceManager.GetString("ErrNoChosenInternalForces")); } List <string> errors = VerifySteel(labelBm.LongitudinalReinforcement, true); foreach (string s in errors) { status.AddError(s); } errors = VerifySteel(labelBm.TransversalReinforcement, false); foreach (string s in errors) { status.AddError(s); } } } break; } break; case StructuralAssetClass.Metal: break; } } }