Hi!
I’m trying to find a way to read the Structure definition of a type Element, for example WallType.
The structure contains different layers, and for example I would like to read the Material for each layer.
I can find the Structure parameter using this code:
type_collector = FilteredElementCollector(doc).OfCategory(category).WhereElementIsElementType().ToElements()
for type in type_collector:
for para in type.GetOrderedParameters():
if para.Definition.Name == "Structure":
But now I’m having issues finding how to access the values within Structure. It doesn’t seem to be a Value, so I’m wondering if there is some method to extract the data within Structure?
Regards, Gustav
layers = wall.GetCompoundStructure().GetLayers()
for layer in layers:
fonction = layer.Function
width = layer.Width*25.4*12 #should be using UnitUtils to convert from decimal feet to mm or other units
material = doc.GetElement(layer.MaterialId).Name
print("- {}mm - {} - {}\n".format(width, fonction, material))
Hello Jean-Marc, thank you for the answer!
It seems that Walls does not have a GetCompoundStructure method.
This is the code I tried using:
walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsElementType().ToElements()
for wall in walls:
layers = wall.GetCompoundStructure().GetLayers()
for layer in layers:
material = doc.GetElement(layer.MaterialId).Name
I get the error AttributeError : ‘NoneType’ object has no attribute ‘GetLayers’
Could you advice on what I am doing wrong?
There is always a curtain wall type in any Revit project file, you cannot delete the last one
print the element Id and then select by id in revit to have a look at it
I see, that is good information to know, I’ll be careful with what information I gather.
I didn’t get wall.Kind to work, as it returned and and not WallKind.Basic, perhaps there’s a conversion to do there?
However, I got it working by sorting out the actual geometry wall elements instead, and then checking there type.
This is the code I used in the end:
dict = dict()
doc = __revit__.ActiveUIDocument.Document
walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()
for wall in walls:
#print(wall.Name, "has the materials:")
wall_type = doc.GetElement(wall.GetTypeId())
layers = wall_type.GetCompoundStructure().GetLayers()
dict[wall.Name] = layers
for layer in layers:
material = doc.GetElement(layer.MaterialId).Name
#print(material)
#print("----")
for key in dict:
print(key, "has the materials:")
for layer in dict[key]:
material = doc.GetElement(layer.MaterialId).Name
print(material)
print("---")
Thank you so much for the help. wall_type.GetCompoundStructure().GetLayers() was the code method I was looking for!
Regards, Gustav