I’m currently working on a project in Revit and using Dynamo to automate some tasks. I’m facing a challenge with accessing specific material properties through Dynamo, which are readily available in Revit’s Material Browser. Specifically, I need to access properties like Density, Young’s Modulus, and the Thermal Expansion Coefficient for various materials in my project.
Here’s what I’ve tried so far:
I’ve used the Element.GetMaterials node to retrieve materials from selected elements.
I attempted to extract properties using Material.ParameterByName, but I’m not able to see all the properties that are visible in Revit’s Material Browser, like Density and others.
It seems like some properties are not directly accessible or perhaps not exposed in the same way through Dynamo’s standard nodes.
Could anyone suggest how to access these detailed physical properties of materials directly in Dynamo? Are there any custom nodes or packages that you would recommend? Additionally, if there’s a Python script or a more advanced method that could tap deeper into the Revit API, I would greatly appreciate learning about that as well.
These aren’t parameters but properties, and as such you’ll need specific nodes to access them, or to use the Revit API directly. I believe that the Genius Loci has some nodes to access the data.
i used Revit API but still couldn’t reach those proprieties ,using this code
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Get the current document
doc = DocumentManager.Instance.CurrentDBDocument
# Create a collector to retrieve all materials in the document
collector = FilteredElementCollector(doc).OfClass(Material)
# Dictionary to store materials information
materials_info = {}
# Iterate through all collected materials
for material in collector:
# Dictionary to store properties of a specific material
mat_props = {}
# Get the parameters of the material
params = material.Parameters
# Iterate through all parameters to retrieve the necessary ones
for param in params:
# Ensure the parameter has a value
if param.HasValue:
# Get the name and value of the parameter
paramName = param.Definition.Name
if param.StorageType == StorageType.Double:
# Convert the value to the system unit (e.g., SI)
paramValue = param.AsDouble() * 304.8 if paramName in ['Young\'s Modulus', 'Density'] else param.AsDouble()
elif param.StorageType == StorageType.Integer:
paramValue = param.AsInteger()
elif param.StorageType == StorageType.String:
paramValue = param.AsString()
else:
paramValue = "Unsupported type"
# Add the parameter name and value to the material dictionary
mat_props[paramName] = paramValue
# Add the material properties to the global dictionary with the material name as the key
materials_info[material.Name] = mat_props
# Return the materials information
OUT = materials_info
Those are parameters - you need to access the properties.
Physical properties are in the Structural asset if I recall correctly. It is accessed programmatically via this property: StructuralAssetId Property
That asset ID can be used to get the structure asset which is applied to the material. From there you can pull various properties as shown here: StructuralAsset Members
The Revit “Material” is not a single element.
It is a container which has some properties inherent to it, but also additional “Assets” that are separate objects that can be shared among multiple materials. Anything shown on the “Physique” (Physical) tab is a property of that Physical asset. (Also called Structural, though some of the Physical parameters are used in things like energy analysis) There are also Thermal and Rendering (“Appearance”) assets.
(These appear to be called “aspects” in the API: MaterialAspect Enumeration)
You will need to drill down through the objects to get the properties you are looking for.
Try the Materials.StructuralParameters Node for the information you want. I think the values in the material (that are probably blank) are holdovers from the old material behavior, before Assets were a thing.
You can see that there are nodes to grab the Assets themselves (Material.AppearanceAssetElement) As well as those that can drag the parameters from the Asset elements given only the Material (container) Object (Material.StructuralParameters and Material.AppearanceParameters)
thank u sir for your help this worked for me perfectly ,and here is the code i used :
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
# Inputs from Dynamo
element = UnwrapElement(IN[0]) # Selected Revit element
material_index = 0 # Index of the material to inspect if the element has multiple materials
# Conversion Factor for Density
kgft3_to_kgm3 = 35.3147
# Get the active document
doc = DocumentManager.Instance.CurrentDBDocument
# Retrieve the material from the selected element
material = None
if isinstance(element, FamilyInstance) or isinstance(element, Wall):
# Handle specific element types to extract the material
material_ids = element.GetMaterialIds(False)
if len(material_ids) > material_index:
material = doc.GetElement(material_ids[material_index])
if material is not None:
# Get Structural Asset Id
structural_asset_id = material.StructuralAssetId
if structural_asset_id != ElementId.InvalidElementId:
# Get Structural Asset
asset_element = doc.GetElement(structural_asset_id)
structural_asset = asset_element.GetStructuralAsset()
# Extract Density in kg/ft³
density_kgft3 = structural_asset.Density
# Convert to kg/m³
density_kgm3 = density_kgft3 * kgft3_to_kgm3
else:
density_kgm3 = "No structural asset associated with the material"
else:
density_kgm3 = "Material not found in the selected element"
OUT = density_kgm3