Read Wall's Material Layers

# -*- coding: utf-8 -*-
__title__ = "Read Wall Materials"
__doc__ = """Version = 1.0
Date    = 15.01.2024
_____________________________________________________________________
Description:
How to Read Properties and Methods from Elements?
_____________________________________________________________________
Author: Erik Frits"""

# Imports
from Autodesk.Revit.DB import *

# Variables
doc   = __revit__.ActiveUIDocument.Document #type: Document
uidoc = __revit__.ActiveUIDocument
app   = __revit__.Application

#Main

#1️⃣ Select Walls
from Autodesk.Revit.UI.Selection import Selection, ObjectType
selection = uidoc.Selection #type: Selection

# Get Current Selection
selected_el_ids = selection.GetElementIds()
selected_el     = [doc.GetElement(e_id) for e_id in selected_el_ids]

# Prompt User Selection if nothing selected
if not selected_el:
    selected_el_refs = selection.PickObjects(ObjectType.Element)
    selected_el      = [doc.GetElement(ref) for ref in selected_el_refs]

# Filter Elements
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)


#👀 READ PROPERTIES
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 # Revit API USES FEET!
        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))

⌨️ Happy Coding!
Erik Frits