Get Element id from Face

Hi everyone
This is code python get Element id from Face but not active
so somebody can help me fix it this python
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
faces = UnwrapElement(IN[0])
elementlist = list()
for face in faces:
	try:
		ref = face.Tags.LookupTag("RevitFaceReference")
		elem = doc.GetElement(ref)
		elementlist.append(elem)
	except:
		elementlist.append(list())
OUT = elementlist

You only need to change the list() for empty list

Load the Python Standard and DesignScript Libraries

import sys
import clr
clr.AddReference(‘ProtoGeometry’)
clr.AddReference(“RevitServices”)
from Autodesk.DesignScript.Geometry import *
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

The inputs to this node will be stored as a list in the IN variables.

faces = UnwrapElement(IN[0])
elementlist =
for face in faces:
ref = face.Tags.LookupTag(“RevitFaceReference”)
elem = doc.GetElement(ref)
elementlist.append(elem)

Assign your output to the OUT variable.

OUT = elementlist

1 Like