Paint Material Surface

Hi @claudiubrb,

Try this slightly modified version of René’s Python Script:

# Copyright(c) René Castillo Picazo
# México 2017
# cadesigner.mex@gmail.com

import clr

clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')

import Autodesk
import RevitServices

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc =  DocumentManager.Instance.CurrentDBDocument


surfaces = IN[0]
material = UnwrapElement(IN[1])

def PaintFace(surf, mat):
	if not isinstance(surf, list):
		elemRef = surf.Tags.LookupTag('RevitFaceReference')
		elem = doc.GetElement(elemRef)
		face = elem.GetGeometryObjectFromReference(elemRef)
		if not (doc.IsPainted(elem.Id, face)):
			doc.Paint(elem.Id, face, mat.Id)
			return surf
	else:
		[PaintFace(i, mat) for i in surf]
		return surf
        

TransactionManager.Instance.EnsureInTransaction(doc)

OUT = PaintFace(surfaces, material)            

TransactionManager.Instance.TransactionTaskDone()

3 Likes