Maciej Główka
Blog Games Contact

← Return to Blog Index

July 1, 2019

Efficient auto-join using Dynamo

Joining model elements in Revit can be a tedious task. Surely it is something that most of us would like to automate with Dynamo. Hopefully we can easily find some custom nodes that can join elements. We can also do it with Python using a Revit API funtion:


where doc is a current document and a and b are elements to join.

Efficiency problems will occur however, especially in case of more complex models. If we were going to create a script that eg. would try to join every possible wall with every possible floor it would take a considerate amount of time to execute and could produce numerous errors. Such a script would try to join elements that are not connected and often quite remote. This cannot be efficient

So, before we try to join elements, it is worth checking whether they intersect or not. However, objects can often have a very complex geometry and thus such a check can also be time consuming. Therefore script presented below includes one more step. A preliminary check, that can quickly determine if tested elements are close enough to potentially intersect.

Every model element in Revit has a property called BoundingBox. Exactly as the name suggests, it is a smallest box that can fit the element. It can be relatively quickly tested whether two such boxes intersect or touch. Intersections test are way quicker for boxes than for complex geometry.

The code below takes as an input two lists of elements. Then, it test every element from the first list with every element from the second list – are their BoundingBoxes intersecting or not. As a result it outputs a list of pairs of elements that have intersecting boxes.

This way we get a list of element pairs – potentially intersecting.

Below a Dynamo definition (download at the bottom) that will join all the walls and floors in the project for us:


The last node is also a custom Python piece of code joining two lists of elements:

← Finding element location by using Bounding Box in Dynamo Creating elevation views with API→