Element (ID) from a surface

Hey,

is it possible to get the Element of a surface? For example when I pick “Select Face” the ID of the element is written in there, but I do not know how to extract it…

grafik

thx

interesting question.

I can’t see an obvious way (to get the parent elementID from a face of that element), although you’d think it must be possible as the node displays it

Being lazy, I’d probably work around it by using a select element node rather than a select face

1 Like

Hello
the output of OOTB node ‘Select Face’ is a geometry surface, the reference is missing
an alternative with the RevitAPIUI

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *

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

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

clr.AddReference("RevitNodes")
import Revit
# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

TaskDialog.Show('Selection','Select a face')
ref = uidoc.Selection.PickObject(ObjectType.Face, 'select a face')
elemId = ref.ElementId
element = doc.GetElement(ref.ElementId)
dynSurface = doc.GetElement(ref).GetGeometryObjectFromReference(ref).ToProtoType()

OUT = elemId, element, dynSurface

3 Likes

This works perfect. I am a real begginer in Python, but looks like I should learn more about it
thank you

It’s so nice @c.poupin !!! Is there any way for multiple faces? Thanks

@brenofilipe Please start new topic. This topic has already solution.

1 Like