/// <summary> /// change unit weight of selected component to 14.50 kN/m3 /// </summary> public bool ChangeUnitWeight() { Autodesk.Revit.DB.Material material = GetCurrentMaterial(); if (material == null) { return(false); } Parameter weightPara = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_UNIT_WEIGHT); weightPara.Set(ChangedUnitWeight / ToMetricUnitWeight); return(true); }
/// <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 Parameter materialAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_TYPE); if (materialAttribute == null) { moreValue = i.MoveNext(); continue; } //add materials to different ArrayList according to their types switch ((MaterialType)materialAttribute.AsInteger()) { case MaterialType.Steel: { m_steels.Add(new MaterialMap(material)); break; } case MaterialType.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> /// 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> /// get current material of selected component /// </summary> private Autodesk.Revit.DB.Material GetCurrentMaterial() { if (null != m_cacheMaterial) { return(m_cacheMaterial); } int identityValue = 0; if (m_currentMaterial != null) { identityValue = m_currentMaterial.AsElementId().IntegerValue; //get the value of current material's ElementId } //material has no value if (identityValue <= 0) { return(null); } Autodesk.Revit.DB.Material material = (Autodesk.Revit.DB.Material)m_allMaterialMap[identityValue]; return(material); }
/// <summary> /// constructor /// </summary> /// <param name="material"></param> public MaterialMap(Autodesk.Revit.DB.Material material) { m_materialName = material.Name; m_material = material; }
/// <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); }