Home milagrito.dyn (774.0 KB)
Hi everyone,
I’ve followed the instructions you shared, but I’m still unable to resolve the issues.
christian.stan, I tried your Python node, but the result doesn’t work with FamilyInstance.ByFace, and I run into the same problem when selecting multiple walls.
I’ve also explored other approaches, such as directly selecting the face I need and filtering it with a Python node (Claude helped me set this up since I’m still a beginner), but I haven’t had success with that either so far.
Could you please guide me or suggest what else I could try? I’d really appreciate your help.
import clr
clr.AddReference(‘RevitAPI’)
clr.AddReference(‘RevitServices’)
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
active_view = doc.ActiveView
TARGET_GS_ID = 267884
collector = FilteredElementCollector(doc, active_view.Id).WhereElementIsNotElementType().ToElements()
opts = Options()
opts.View = active_view
opts.ComputeReferences = True
opts.IncludeNonVisibleObjects = False
filtered_faces =
filtered_elements =
for element in collector:
try:
geom = element.get_Geometry(opts)
if geom is None:
continue
for geom_obj in geom:
solids =
if isinstance(geom_obj, Solid):
solids.append(geom_obj)
elif isinstance(geom_obj, GeometryInstance):
for obj in geom_obj.GetInstanceGeometry():
if isinstance(obj, Solid):
solids.append(obj)
for solid in solids:
if solid.Volume <= 0:
continue
for face in solid.Faces:
try:
gs_id = face.GraphicsStyleId.IntegerValue
if gs_id == TARGET_GS_ID:
filtered_faces.append(face)
filtered_elements.append(element)
except:
pass
except:
pass
OUT = filtered_faces, filtered_elements
Hi
Here’s a version that uses a flattened list of panel surfaces, so the angle between the surface normal and the wall normal is 0.
I tried it with a family installed afterward.
I had some strange placements with your family.
import sys
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
cp=UnwrapElement(IN[0])
def getSolidfromGeo(elem):
opt = Options()
opt.ComputeReferences = True
opt.IncludeNonVisibleObjects = True
geoSet = elem.get_Geometry(opt)
#
for geo in geoSet:
if isinstance(geo,DB.Solid) and geo.Volume > 0 :
return geo, "Geometry"
for geo in geoSet:
if isinstance(geo, GeometryInstance):
outSolid = []
geoSetInst = geo.GetInstanceGeometry()
for geoI in geoSetInst:
if isinstance(geoI,DB.Solid) and geoI.Volume > 0:
outSolid.append(geoI)
# Order the list by ascending volume
outSolid.sort(key = lambda x : x.Volume )
print(len(outSolid))
#Retrieve the Revit faces of the largest [-1] of the volumes
lfr=outSolid[-1].Faces
#Transform the Revit faces To Faces Dynamo
lfd=[f.ToProtoType()[0] for f in lfr if elem.Host.Orientation.ToVector().AngleWithVector(f.FaceNormal.ToVector())==0]
return lfd[0]
return None, None
OUT = [getSolidfromGeo(c) for c in cp]
rep 26_04_17.dyn (242.9 KB)
Regards, Christian Stan
I tested your script in my mock-up model, but the errors persist.
You have a model specific problem. This means the community needs a specific model to build a solution around.
To put it more directly, you’re likely going to have to share your file by posting it on the forum.
That said… why not nest the face based family in the other family and be done with it?