Element Intersection

A common question when analysing a BIM is determining whether any of its elements intersect.

This was actually surprisingly difficult to answer programmatically in Revit a few releases back, as some of the interesting uses of the FindReferencesByDirection method show, for example the FindColumns SDK sample.
Later, that method was enhanced to lead to FindReferencesWithContextByDirection.

The FindColumns sample searches for intersections between walls and columns by shooting a ray along the wall centre line, raised above the bottom level by a foot or so, and detecting any columns hit by it.
One obvious problem with this approach is its inaccuracy – any column just partially intersecting the wall may easily be missed by the ray.

A few years ago, that was the best an add-in developer could hope for, and things looked even worse before the advent of these methods.

So what is the situation today?
In short:

Question: How can I programmatically detect whether two Revit elements intersect?

Answer: You can now perform a Boolean operation on Revit element solids and determine whether they intersect using the BooleanOperationsUtils class ExecuteBooleanOperation method.

Please note that the resulting intersection solid is transient, in-memory only.
It can be used for calculation and short-term visualisation using the analysis visualisation framework AVF, but it cannot be added to the Revit database or made persistent.

This class was introduced in the Revit 2012 API, and the

associated webcast
showed
it being used impressively in a much improved version of the FindColumns SDK sample.
This version determines the exact intersection solids between all columns and walls instead of roughly approximating the intersection detection by casting a single ray, and displays them to the user through AVF.

The Boolean intersection demo is described in detail and the source can be downloaded from the discussion of a simpler derived sample

using AVF to highlight rooms
.

Another example of making use of this class is given by the GeometryCreation_BooleanOperation SDK sample.

Finally, here are two discussions on element intersection before the introduction of the BooleanOperationsUtils class, on

intersection between elements in Revit 2011
and
the

InstanceVoidCutUtils class
.

AEC Technology Update

If you are interested in a succinct summary of all the key developments in the AEC technology industry in the past couple of months, here is a potantial cancidate: the

AEC Technology Updates, Fall 2012
,
including some snippets of Autodesk related news such as Revit LT and the Vela acquisition.


Comments

2 responses to “Element Intersection”

  1. Hi Jeremy,
    Let’s say I have two famlies, and want to find all famlies that intersects with these using ElementIntersectsElementFilter, and then
    add different strings to comments depending on which of these two famlies they intersect with. However, if
    a family intersects with both of these, I need a way to determine which family “intersects more” than the other. Is there a way to do this?
    Or can I locate the insertion point of the famlies and see if that part intersect with either of the famlies?
    Cheers,
    Martin

  2. Dear Martin,
    Yes, sure you can.
    You can use the Boolean intersection utils to intersect the solids obtained from the family instances with each other and determine their volume:
    http://thebuildingcoder.typepad.com/blog/2013/03/supporting-columns.html#2
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading