Get Wall Face by python

Hiii, everyone…
Actually i would like create paint node by room but which requires wall faces so I’m try find the wall faces in packages but its not available and again so I’m try find GetRevitGeometry from RevitAPIdocs but don’t know which one is correct??
Anyone can help me how to get revit geometry or how to get wall faces.

```
public void Paint(
	ElementId elementId,
	Face face,
	ElementId materialId
)
```

If you are using Revit API, you can apply the .Geometry property (or attribute as called in Python - works on most elements):
https://www.revitapidocs.com/2015/d8a55a5b-2a69-d5ab-3e1f-6cf1ee43c8ec.htm

@habdirad Thanks for your reply… i found new Issue in Paint Method
image

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

#Outputs
Faces = []
Geometry = []
Painter = []
#inputs
walls = IN[0]
Mat = IN[1]
#Wall Faces
for wall in walls:
	Geo = wall.Geometry()
	Geometry.append(Geo)
	for f in Geo:
		face = f.Faces
		Faces.append(face)
#Painting
	for Paint in Faces:
		Painter = Paint(wall.Id,Paint,Mat.Id)
		Painted.append(Painter)
OUT = Painted

Okay let’s go with the code attached code.txt (934 Bytes) . Some important changes:

  • Unwrap elements to make them available to API operations
  • Paint is a method of Revit document
  • In the last post, I said Geometry was a method and it is actually a property so I fixed that
  • there is no guarantee that the paint method could paint all faces, so I added a try except structure
  • for the list of faces, I used extend, instead of append, so we end up with a flattened list of faces vs a list of nested lists of faces
  • also please avoid naming your python objects/variables with capital letter, you could mistakenly override API classes and functions
3 Likes

Very thanks @habdirad spend time to solve and explain briefly… i will correct my mistakes here after.