Find overlapping elements (walls and floors), then join geometry

Hello,

I’m trying to make a script which is able to:

  1. find all elements of defined type (walls: ceramic, finishing etc.) on choosen level,
  2. find all floors of defined type on choosen level,
  3. check overlapping of those elements,
  4. join geometry of overlapping elements.

So, i made 1st and 2nd step, but I have no idea how to check “intersections” beetwen them. I think that’s necessery, because sometimes I need to join around 300 walls at one level to 8-10 floors on the same level. I read about bounding box but it seems doesn’t work in this case or I’m using it not properly.
At 4th step could be used simple Element.JoinGeometry node from Clockwork but I don’t know how to put in this node list of overlapping wall + floor combinations.

I would be thankful for any suggestion, because I stucked in this place few days ago. I’m still rookie in the World of Dynamo :wink:

My test file:

Join-unJoin walls-floors.dyn (18.9 KB)

Greetings
Piotr

Hi,
maybe is it possible to do this way, with bimorph node “Element.IntersectesElement”:

If I understand it correctly, I can get wall with index 0,1,2… and pair it with floor (or floors) from list number 0,1,2… Then this elements could be joined. Can You explain me how to make next step?
Join-unJoin walls-floors_v2.dyn (22.4 KB)

Greetings
Piotr

Hello Piotr

You are on the right way with the Bimorph node

Maybe this can help you for the next step:

DY%20PL%20Join%20Multiple%20geometry DY PL Join Multiple geometry.dyn (10.7 KB)

Thank You for Your response.
I read it, but I didn’t find a solution. If I try to create one list of walls and floors with flatten, I’m miss the sence of script. For egsample, wall with index “5” does not intersect with floor, wall with index “6” intersects two floors. After using List.Flatten it shows different data set.

Revit_2019-05-13_17-18-57

If I paste Your code directly, it doesn’t work. Can You explain me how this code block works?
image

hi!
If you want to do some preliminary check to optimize the script I would really consider checking the bounding boxes. To my understanding the API Join command will check complex geometry intersection anyway. So checking it beforehand will mean checking it twice (somebody correct me here if I am mistaken).
You can try this python piece:

import clr

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

def overlap1D(a1, a2, b1, b2):
  if a2>=b1 and b2>=a1:
    return True
  return False
  
def bbIntersect(bbA, bbB):

  return overlap1D(bbA.Min.X,bbA.Max.X,bbB.Min.X,bbB.Max.X) and overlap1D(bbA.Min.Y,bbA.Max.Y,bbB.Min.Y,bbB.Max.Y) and overlap1D(bbA.Min.Z,bbA.Max.Z,bbB.Min.Z,bbB.Max.Z)

#The inputs to this node will be stored as a list in the IN variables.
listA = UnwrapElement(IN[0])
listB = UnwrapElement(IN[1])

output = []

for a in listA:
  bbA = a.get_BoundingBox(None)
  if not bbA is None:
    for b in listB:
      bbB = b.get_BoundingBox(None)
      if not bbB is None:
        if bbIntersect(bbA,bbB):
          output.append([a,b])

#Assign your output to the OUT variable.
OUT = output

You input two lists of elements and it checks bounding box intersections for you. As a result you get a list of intersecting elements (in pairs - so it is a list of two-element lists).

obraz

5 Likes

Hi!
I tried Your script - works perfect! :smiley: I checked it on 10 elements and it seems everything is right.
Now, I would like to add SwitchJoinOrder option to the dynamo script.

I thought it could be easy so I get Join.Geometry Node from Hot Gear Package:
image
JoinGeometry.dyf (6.8 KB)

I changed the line 27 of the second python script in this node according to this topic:

Auto Join Walls and Columns - #44 by ammo

image
but without effect despite there is no warnings at stript.

After this step I’m going to check everything on a real model with more elements to join (and switch).

Thank You very much once again,

Piotr

#Edit:
I did it with this scipt:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

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

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

elements = UnwrapElement(IN[0])
count = 0
result = []
while (count < len(elements)):
	try:
		Autodesk.Revit.DB.JoinGeometryUtils.SwitchJoinOrder(doc, elements[count][0], elements[count][1])
		count = count + 1
		result.append("Seccess")
	except:
		count = count +1

TransactionManager.Instance.TransactionTaskDone()
OUT = result
2 Likes

Hello,

I’ve got a similar problem as this one, except I am trying to join all of the floors and walls visible in my view. I used the Python script above for boundingbox intersection, which seemed to work fine at first. Except I didn’t get all of the joins I expected. The number of walls and floors Dynamo lists from my view are correct and all intersecting elements found by the Python script are joined. This makes me think the Python script doesn’t find every intersection. Anyone got an idea about this?

toren_deels toren_volledg

1 Like

Hi,

sometimes there are accuracy problems in Revit, eg. when elements are barely touching. Maybe there should be added some kind of tolerance parameter to the intersection function.

Hello,
do You have any warnings in Revit after using this script. Maybe “Can’t cut joined geometry” or “Elements can’t be joined”?

Hi,
no warnings at all. Some joins just aren’t made.

join & switch geometry works good for me