Get solid from Paint Surface

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

hi try something and see if it could work

or probably

1 Like

@willem.creffierKCWFB ,

just to make your code more “postable” :wink:

</>

import clr
import sys
#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 = []

t = Transaction doc, "Create Solids")
t.Start()

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())

t.Commit()

OUT = selectedFaces
1 Like

Yes, thank you @sovitek

Both options give a similar result.

They do no have a “solid” feel, but I can take them from here.

Create Family instance from solid - Revit - Dynamo (dynamobim.com)

Kind regards,

Willem