Get surfaces is painted

#1

Hi guys,
I have list surfaces, i want to check what are surfaces painted ?
I search node and package for this issue but no help
I search C# Code and i get “IsPainted Method”
I think this code method can help me but i don’t understand about Code.

Who can help me use “IsPainted Method” code to solve this issue.

http://www.revitapidocs.com/2020/638f398e-bb20-53c4-55a6-454d8a0a1029.htm
Many thanks

#2

That page you linked is good, it asks for a face (surface) and an element. Can you show how your list of surfaces are set up? You will also need a list of elements that match the list of surface. So element 1 should match surface 1 and element 10 should match surface 10, etc. When you have that, we can write a quick python script that uses those lists as inputs and returns a list of booleans.

#3

Hi @kennyb6
Thank for your reply.
This is script i think i’ll use to get surfaces of elements and elements

#4

Turned out to be a bit harder than I thought. There is no way to convert the Dynamo surfaces into the correct API face class, so instead I had to take the object into Python, get the faces using the API’s geometry commands, and then use that IsPainted() method. I also added the list of faces converted back into surfaces so you can use them as you want.

ispainted.dyn (8.5 KB)

1 Like
#5

Hi @kennyb6
Thank you very much for Spend your time with my issue.
When i open your dynamo file. I get warning. Can you help me ?
Or Can you post your python code ?


Many thanks

#6

That graph appears to be formatted for Dynamo 2.x format. Likely you are using a 1.x version of Dynamo. Try upgrading to 2.0 and see if that works. Otherwise the code of the Python node can be copied by opening the dyn in a text editor, and you can rebuild the few other nodes pretty easily.

1 Like
#7

As @JacobSmall said, I made it in 2.0. Here is the Python code:

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

if isinstance(IN[0], list):elems = UnwrapElement(IN[0])
else: elems = [UnwrapElement(IN[0])]


outbool = []
outsurf = []


for e in elems:
	geom = [g for g in e.Geometry[Options()]][0]
	if not isinstance(geom, Solid):
		outsurf.append("Not a valid solid.")
		outbool.append(False)
		continue
	faces = geom.Faces
	painted = [doc.IsPainted(e.Id, f) for f in faces]
	surfs = [f.ToProtoType()[0] for f in faces]
	outsurf.append(surfs)
	outbool.append(painted)


OUT = outsurf, outbool
1 Like
#8

@JacobSmall thank for your help.
@kennyb6 Thank for your post. I test your code, seem your script only run with wall, i use framing and column is not good.
Please check your code.

Many thanks.

#9

Try this one:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

if isinstance(IN[0], list):elems = UnwrapElement(IN[0])
else: elems = [UnwrapElement(IN[0])]

def getfaces(id, s):
	faces = s.Faces
	painted = [doc.IsPainted(id, f) for f in faces]
	surfs = [f.ToProtoType()[0] for f in faces]
	return surfs, painted


outbool = []
outsurf = []


for e in elems:
	eId = e.Id
	geom = [g for g in e.Geometry[Options()] if isinstance(g, Solid)]
	if geom == []:
		outsurf.append("Not a valid solid.")
		outbool.append(False)
		continue
	for g in geom:
		gSurf, gPaint = getfaces(eId, g)
		if gSurf == []:
			continue
		else:
			outsurf.append(gSurf)
			outbool.append(gPaint)


OUT = outsurf, outbool
1 Like
#10

Hi @kennyb6
Thank for your reply. Your script run is good.
But i have new issue, when i create material parameter and assign to surfaces in family enviroment (framing and column)
Your script can’t get surfaces is painted by choose material for parameter in project enviroment.

This is last issue i hope you can help me in this topic because it is really necessary for my work.


Many thanks