find all elements of defined type (walls: ceramic, finishing etc.) on choosen level,
find all floors of defined type on choosen level,
check overlapping of those elements,
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.
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)
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.
If I paste Your code directly, it doesn’t work. Can You explain me how this code block works?
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).
Hi!
I tried Your script - works perfect! 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’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?
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.