__title__ = "Read Wall Materials"
__doc__ = """Version = 1.0
Date = 15.01.2024
_____________________________________________________________________
Description:
How to Read Properties and Methods from Elements?
_____________________________________________________________________
Author: Erik Frits"""
from Autodesk.Revit.DB import *
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app = __revit__.Application
from Autodesk.Revit.UI.Selection import Selection, ObjectType
selection = uidoc.Selection
selected_el_ids = selection.GetElementIds()
selected_el = [doc.GetElement(e_id) for e_id in selected_el_ids]
if not selected_el:
selected_el_refs = selection.PickObjects(ObjectType.Element)
selected_el = [doc.GetElement(ref) for ref in selected_el_refs]
selected_walls = [el for el in selected_el if type(el) == Wall]
if not selected_walls:
from pyrevit import forms
forms.alert('No walls selected. Please try again', exitscript=True)
for wall in selected_walls:
wall_type = wall.WallType
wall_type_name = Element.Name.GetValue(wall_type)
print('-'*50)
print('Wall Id: {}'.format(wall.Id))
print('WallType: {}'.format(wall_type_name))
structure = wall_type.GetCompoundStructure()
layers = structure.GetLayers()
print('Wall Materials:')
for lay in layers:
mat_id = lay.MaterialId
width_ft = lay.Width
width_cm = width_ft * 30.48
if mat_id != ElementId(-1):
mat = doc.GetElement(mat_id)
mat_name = mat.Name
else:
mat_name = 'None'
print('--- {} ({}cm)'.format(mat_name, width_cm))