Hello, is it possible via the API to obtain the face (Face Class) from the Reference?
Thanking you in advance
Script:
import clr
import System
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
if IN[0]:
f=uidoc.Selection.PickObject(Selection.ObjectType.Face, "Choix de la face souhaitée")
OUT = f,dir(f)
Cordially
christian.stan
Hi @christian.stan
here an example
import clr
import System
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
out = []
if IN[0]:
ref=uidoc.Selection.PickObject(ObjectType.Face, "Choix de la face souhaitée")
elem = doc.GetElement(ref)
face = elem.GetGeometryObjectFromReference(ref)
if isinstance(elem, FamilyInstance):
tf = elem.GetTotalTransform()
lst_curvLoop = face.GetEdgesAsCurveLoops()
for curveLoop in lst_curvLoop:
loop_tf = CurveLoop.CreateViaTransform(curveLoop, tf)
ds_polycurve = PolyCurve.ByJoinedCurves([c.ToProtoType() for c in loop_tf])
out.append(ds_polycurve.Patch())
else:
out.append(face.ToProtoType())
OUT = out
3 Likes
Hi, thanks to you, I understood the trick of going through the class of element to obtain part of the geometry (I should have thought of that)
you actually have a lot more than you could ask for, thanks by the way (you actually wrote the pickface system node)
I find it difficult to grasp the physical perception of the reference all the same.
Cordially
christian.stan
2 Likes