Get Paint Material face from wall

Hi all,

See the below script from attached snip( My results right now all faces of wall )

I want a Python script for paint material face from wall, out put results should be only painted face with wall.
As a newcomers in Python language I can’t find out the solution, need assist.

Thank You


I see you already have the Faces. The Face Class in The Revit API has a MaterialId property. I think this will return the paint material for that specific face.

I know that but i can’t understand, how to get MaterialId Property.

I see why you dont get the materiaId of the faces. This is because you are working with Dynamo Faces and not Revit API Faces. When you want to get access to the API properties of an object in Python you have to Unwrap that element. From that I wrote a method which gets the Geometry of the Element (In your case the walls) and I use that to get the Faces. When you have the Revit API Faces, you can get their MaterialId. If they are painted, it will give you the paint material, if they are not painted you will get the core material. (Code below)

import clr

#Import the Revit Services
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Import the Revit Nodes
import Revit

#Import the Revit API
import Autodesk
from Autodesk.Revit.DB import *

def tolist(obj1):
	if hasattr(obj1,"__iter__"):
		return obj1
		return [obj1]

def ReturnSingleOrList(list):
	if len(list)==1:
		return list[0]
		return list

#This returns all the Geometries in an element
def GetElementGeometries(element):
	element = UnwrapElement(element)
	result = []
	geometries = element.Geometry[Options()]
	for geometry in geometries:
	return ReturnSingleOrList(result)

#Define Input (IN)
walls = UnwrapElement(tolist(IN[0]))
output = []

# Start Transaction

options = Options()
for wall in walls:
	wallMaterials = []
	wallGeometry = GetElementGeometries(wall)
	wallFaces = wallGeometry.Faces
	for face in wallFaces:
		materialId = face.MaterialElementId
		material = doc.GetElement(materialId)

#End Transaction

#Define Output (OUT)
OUT = output
1 Like