For Quantification outside of Revit I would like to create a solid for each painted surface.
I can acces the faces of walls & floors, by unwrapping it…
import clr
# Import the Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import Revit Geometry Conversion
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
# Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
# Get walls and floors
walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()
floors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElements()
# Combine walls and floors into a single list
elements = []
elements.extend(walls)
elements.extend(floors)
specifiedMaterial = UnwrapElement(IN[0])
gOpts = Options()
selectedFaces = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i in elements:
geom = i.get_Geometry(gOpts)
for j in geom:
faces = j.Faces
for face in faces:
# Check if the face has the specified material
if face.MaterialElementId == specifiedMaterial.Id:
# Add the face to the list
selectedFaces.append(face.ToProtoType())
TransactionManager.Instance.TransactionTaskDone()
OUT = selectedFaces
But how do I get from faces to the curves defining it?
We went through Curve.ByPoints, PolyCurve.ByPoints, Curve.ByJoinedCurves, PolyCurve.ByJoinedCurves, but without succes.
Is there a different approach possible?
Kind regards,
Willem