Hello everybody
I’m trying to find a way to paint on the surface of a element, or node can do this
I have a surface input, I was trying to paint a layer of material on the surface, but I did not find any node to represent it. Can someone help me
Thanks
You can start with this:
# 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):
elemRef = surf.Tags.LookupTag("RevitFaceReference")
elem = doc.GetElement(elemRef)
face = elem.GetGeometryObjectFromReference(elemRef)
if not (doc.IsPainted(elem.Id, face)):
return doc.Paint(elem.Id, face, mat.Id)
TransactionManager.Instance.EnsureInTransaction(doc)
if (isinstance(surfaces, list)):
[PaintFace(j, material) for i in surfaces for j in i]
else:
PaintFace(surfaces, material)
TransactionManager.Instance.TransactionTaskDone()
Thanks. I have done as your guide. But it does not show the surface material, because I need to be able to calculate the area of the Painted.
There’s a Clockwork node which returns the area/volume of materials (think it’s called Element.Materials?), and you can choose whether or not to include paint materials as well. That should return what you’re looking for?
Thank so much. oliver green, Organon and ZJRODGERS
Hi @alibabon I am currently assigned the task of calculate formwork area so you can share the file .dyn
Thank so much @alibabon
See the related links in this post:
@Yna_Db Thanks so much!
I very like it!
Was there a DYN for this? If so, please Package and let me know keywords for search. Let me know if you need help with Package.
@Organon I am getting the following whenever I am running the workflow:
Warning:
IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 31, in
File “”, line 21, in PaintFace
TypeError: Multiple targets could match: GetElement(Reference), GetElement(str), GetElement(ElementId)
Can you help out please?
Hi @Organon could you please share PaintElements.dyn file ? I know you shared the Python script for painting surfaces but it seems to give an error “unexpected indent” which I don’t know where is coming from.
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()
I had to change the material to thousands of “structural element” ( in reality Direct Shape geometry, for this reason was impossible to apply any material to the instance or to the type)… PAINT was the only way, and thanks to your script I managed to do it automatically!
thanks a lot
Nice, Marco. I’m glad it made your life a little easier
at the end of the day, it crashes many times since the elements were too much.
Since the elements are an import from Tekla -> then IFC from a client -> than Revit, they are Brep Direct Shapes, so the material is following the Object style of the Category (Structural Framing or columns) instead of the Type/Instance Material Parameter.
Fixed
Is there a way to remove all paint applied to the elements?
Hi @J-estrada01,
I definately believe it is . I don’t know if there’s any nodes around that does the job though. Otherwise you’d have to implement this method with a bit of python.
Edit: Linked to the wrong method
Here’s a quick example:
Sorry I didn’t make a gif
Python script:
import clr
#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
elems = UnwrapElement(IN[0])
gOpts = Options()
TransactionManager.Instance.EnsureInTransaction(doc)
for i in elems:
geom = i.get_Geometry(gOpts)
for j in geom:
face = j.Faces
for f in face:
if doc.IsPainted(i.Id, f):
doc.RemovePaint(i.Id, f)
TransactionManager.Instance.TransactionTaskDone()
OUT = 0