Recover elements (here walls) only inside a non-rectangular poaching area

Hi
I share this.
if you have better ideas I’m interested, thank you in advance

Recover elements (here walls) only inside a non-rectangular poaching area

the solid is in m here

the 2nd output of the python script is the result of the elements included and cut with the geometry




Python script

import sys
import clr

import System
from System.Collections.Generic import List

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import XYZ,GeometryCreationUtilities,BooleanOperationsUtils,BooleanOperationsType,FilteredElementCollector,BuiltInCategory,ElementIntersectsSolidFilter

fr=UnwrapElement(IN[0])

doc=fr.Document

cl=fr.GetBoundaries()

vecZplus=XYZ(0,0,1)

bh=GeometryCreationUtilities.CreateExtrusionGeometry(cl,vecZplus,30/0.3048)

bb=GeometryCreationUtilities.CreateExtrusionGeometry(cl,vecZplus.Negate(),10/0.3048)

bigboite=BooleanOperationsUtils.ExecuteBooleanOperation(bh,bb,BooleanOperationsType.Union)

allwalls=FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()

pts=[w.Location.Curve.Evaluate(0.5,True).ToPoint() for w in allwalls]

filtre_solid = ElementIntersectsSolidFilter(bigboite)

wallsfilter = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().WherePasses(filtre_solid).ToElements()

OUT = allwalls,wallsfilter,pts,bigboite.ToProtoType()

Sincerely
christian.stan

I would think a BoundingBox is faster than a Solid and PullOntoPlane might be even faster. You could simplify a few things, but I think you’re going to be fairly similar in computation time after that.

hi,
thank you for the feedback you mean projecting on a surface the result of the center of a boundingbox of the elements

Sincerely
christian.stan

I think you’d want to do this based on the view range rather than hard coding the extrusion distances. Also extruding the form in the context of the view is good (thinking about section views).

Not going to get much quicker than this without moving to C# though… that said filled regions for this use are certainly not a best practice - a 3D mass is likely better and will be faster (ElementIntersectsElement) while ensuring they show up consistently in all views you display them in.

hi, thank you for the feedback, well seen for the sectionview and the mass
thank you
Sincerely
christian.stan