Autodesk.Revit.DB.PlanarFace to Face

Hi, all

how to convert Autodesk.Revit.DB.PlanarFace to Face in python.

Helps if you provide an example that creates the situation you’re in…


Watch your inputs and list cycling (your desired list structure could be different than mine).

1 Like

Here is my situation as below.

import clr
import Revit
from Revit.Elements import *

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

import Autodesk
from Autodesk.Revit.DB import *

import System
from System.Collections.Generic import *
import sys

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
adoc = doc.ActiveView

#walls = IN[0]
Mat = "Elevation Tag Face"
Faces = []
Geometry = []
output = []
gwall = []
gface = []
#for wall in walls:
#	Geo = wall.Geometry()
#	Geometry.append(Geo)
#	for f in Geo:
#		face = f.Faces
#		Faces.append(face)
#		Faces.GetEnumerator()

#Start scripting here:

walls = UnwrapElement(IN[0]) #Unwrap the wall in order to expose the API object

opt = Options() #Geometry options object. Needed when extracting geometry from a Revit element. 

wallsGeometry = []
wallFaces = []
output = [] #output list
for i in walls: #Iterate the walls
	elemId = i.Id #Get the element id, which we need to use as a parameter in the IsPainted method
	solids = i.get_Geometry(opt) #use the overloaded property get_Geometry to get the wall solids
	temp = [] #Temp container
	for j in solids: #Iterate the solids  
		faces = j.Faces #use the Faces property to get the faces
		for f in faces: #Iterate the faces
			temp.append(doc.IsPainted(elemId, f,)) #append the result to the temp container
	output.append(temp) #append the temp container to the out list
# get wall by boolean
t2 = []
for sub_lst in output:
    t1 = []
    for item in sub_lst:
        if item:
         #   t1.append(None)
# get face by boolean
t3 = []
for sub_lst in output:
    t1 = []
    for item in sub_lst:
        if item:
         #   t1.append(None)
# flattten list wall
newlist = []    
for sublist in t2:
	newlist.extend([i for i in sublist if 1 != 2])
# flatten list face
newfacelist = []    
for sublist in t3:
	newfacelist.extend([i for i in sublist if 1 != 2])

#get propreties
if isinstance(IN[0], list):walls = UnwrapElement(IN[0])
else: walls = [UnwrapElement(IN[0])]

#Get all wall IDS
elements = [UnwrapElement(i) for i in IN[0]]
IDS = List[Autodesk.Revit.DB.ElementId]()

for i in elements:

for i in elements:
# painted face off wall Get IDs
elements1 = [UnwrapElement(i) for i in (newlist)]
IDS1 = List[Autodesk.Revit.DB.ElementId]()

for i in elements1:

for i in elements1:

#filter id & get wall
outlst = []
for w in ElementIDs:
	if w == ElementIDs1:
filter = []
output = []
for i in ElementIDs1:
	for ii in ElementIDs:
		if ii == i:
	if list != []:
		filter = []
OUT =  newlist, newfacelist,output,

Looks like the code sample I gave above will do what you’re after, though it isn’t clear to me what you’re after.

I want all face of wall with paint material and only walls having paint material.(Face, Wall)

If you had that before but only to the planar faces while you wanted Dynamo surfaces, add a line to iterate over your planar face’s (the last line of my code), at the end of the relevant loop, or add .ToProtoType() in the loop which fetched the planar faces.