Logic for touching geometry objects

Hey everyone,

Have just jumped into using pyRevit for the first time a few weeks ago and it’s been awesome to add some automation to some of my projects. I keep getting hung up one one particular problem though.

I have elements that are “stacked” on-top of each other. An element group is separated by a small gap. Each element “group” has multiple layers of walls and generic objects. I’d like to make a pyRevit script that lets me select 1 Structural Framing element from a group (the white bar at the top of these elements in the picture below) and have it do a “recursive search” to see what’s touching the Structural Framing. Then at the end, select all elements that were touching.

I had a bounding-box implementation of this working great, however that all fell apart when I started using it on walls with unique shapes.

You can see that since the wall has a unique shape with an L cut out of it, when the bounding box calculation happens, it grabs both the elements on the left and right of the corner because the BBOX is a rectangle, not the unique shape. This results in the selection spanning this entire inside corner. My first investigations into solving this problem brought me to using Revit Geometry shapes instead of bounding boxes, however that’s been a bit of a hassle. It looks like there’s no way to see what’s “touching” by using a geometry calculation. I also tried scaling the geometry object to get intersecting elements, however origin points and translations get in the way and the scaled object ends up scaling from the project origins.

My question is: does anyone have any experience or helpful tips that might assist in allowing me to do a recursive touching search with geometry instead of bounding boxes? I found some articles online in regards to similar problems but failed to implement them in a pyRevit environment. I can attach code if needed.

Been stuck on this problem for about 2 weeks now. Any help would be greatly appreciated!

Here’s some resources I was reading up on:

https://thebuildingcoder.typepad.com/blog/2012/09/filter-for-touching-beams-using-solid-intersection.html

I haven’t test this approach before but seems it should work:

You would get elements that are intersecting specific solid by using filter for FilteredElementCollector(doc).WherePasses(ElementIntersectsSolidFilter(solid))

Similar approach used at this blogpost:

https://thebuildingcoder.typepad.com/blog/2012/09/filter-for-touching-beams-using-solid-intersection.html