Auto join Elements

I have read this topic and try to create my own script.

Http://dynamobim.org/forums/topic/auto-join-walls-and-columns/#post-19845

I believe I’ve implemented everything I’ve seen in recent postings, including the Python script. But it does not work: frown:

Can someone help me find the right way?
Many Thanks!

Wände_Geschossdecke.rvt (1.7 MB)
Wände_Geschossdecke.dyn (9.0 KB)

Hi that should work for your case:
import clr
clr.AddReference(‘Protogeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitAPI")
import Autodesk

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
#Die Eingaben für diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
dataEnterningNode = IN

elementA = []
if isinstance(IN[0],list):
	for i in IN[0]:
		elementA.append(UnwrapElement(i))
else: 
	elementA.append(UnwrapElement(IN[0]))
elementB = []
if isinstance(IN[1],list):
	for i in IN[1]:
		elementB.append(UnwrapElement(i))
else: 
	elementB.append(UnwrapElement(IN[1]))
	
_Array = IN[2]

doc = DocumentManager.Instance.CurrentDBDocument
results = []
TransactionManager.Instance.EnsureInTransaction(doc)
counter = 0
for i in range(len(_Array)):
	for j in range(len(_Array[i])):
		if _Array[i][j]:
			result = Autodesk.Revit.DB.JoinGeometryUtils.JoinGeometry(doc,elementA[i],elementB[j])
			results.append(result)
TransactionManager.Instance.TransactionTaskDone()
OUT = results

It’s not the most elegant code, but it is clear in what it does.
You can see how I unwrap the elements here (you can also define an unwraping function if you want to apply it to many imputs in a clearer way)
It count’s on the structure of the inputs:

1 Like

Thank you,

it seems very good.
Now i have build four skripts,
wall - column
wall - slab
slab - collum
slab - Stairs

I started a new projekt and place all things I try to test. every skript run well.

next step i build new walls and slabs in same projekt, now the script does not work
:frowning:

import clr
clr.AddReference(‘Protogeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(“RevitAPI”)
import Autodesk

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
#Die Eingaben für diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.dataEnterningNode = IN
elementA =
if isinstance(IN[0],list):
for i in IN[0]:
elementA.append(UnwrapElement(i))
else:
elementA.append(UnwrapElement(IN[0]))
elementB =
if isinstance(IN[1],list):
for i in IN[1]:
elementB.append(UnwrapElement(i))
else:
elementB.append(UnwrapElement(IN[1]))

_Array = IN[2]

doc = DocumentManager.Instance.CurrentDBDocument
results =
TransactionManager.Instance.EnsureInTransaction(doc)
counter = 0
for i in range(len(_Array)):
for j in range(len(_Array[i])):
if _Array[i][j]:
result = Autodesk.Revit.DB.JoinGeometryUtils.JoinGeometry(doc,elementA[i],elementB[j])
results.append(result)
TransactionManager.Instance.TransactionTaskDone()
OUT = results

Summary

This text will be hidden

02.02a_Wände_Geschossdecke_Verbinden.dyn (9.9 KB)

projekt_02.rvt (1.6 MB)

next question, I try this dynamo-skript with a bigger projekt. after more then 1/2 hour revit still in waiting

could it be, that this script is not for bigger projects? I dont hope so :frowning:

Great regards

now, 45 minutes Later :frowning:
heinrich

http://www.revitapidocs.com/2017/3eaaf4f5-70b7-f7fb-63a2-0d95bab25deb.htm
You have to implement a check in the code using AreElementsJoined method. So if the elements are already joined they will be skipped.
Also extracting the geometry of large amounts of elements is slow in Dynamo and sometimes it’s not precise.
You may want to try another approach - different from extracting geometry and checking for intersections.
You can also try a bruteforce method - try to join every wall with a given floor if they’re not already joined for example.

On bigger jobs you need to reduce your dataset some and limit the number of calculations. Filter your selection to only include groupings of elements via scope boxes, levels, or other location data. You’re currently asking the CPU if that wall on the top level of the north facade intersects with the slab in the south side of the lowest basement, something you wouldn’t even bother thinking about if you were running it by hand.

After limiting your datasets you can speed things along further by running simpler tests where you can. Bounding box containment quick and helps reduce the difficult test by a good amount. Generate a bounding box on one list in the dataset (floors or walls) and element.location or a bounding box on the other (depending on element type). Is the item a partially in item b? If so then run the geometry test. If not skip it. This will limit your testing time significantly, but larger jobs may still be slow to finish.

If you find it is intolerably slow, run it when you’re heading off to a meeting, or lunch, or coffee. just remember you will take ownership of a LOT of elements with this script, so there may be some worksharing issues.

One last option to speed things along, but it may not work: try using Revit’s built in clash detection to get a list of elements which intersect, meaning you want to join them together. Depending on how you modeled things it could work very well or it could work very poorly. Either way asking dynamo to join element a to element b via the results read from an HTML file would be much faster than gathering, sorting, gross testing, fine testing, and then joining.

2 Likes

Hi @Heinrich_Boldt nrich, @JacobSmall
is there any solution for the not working after adding new walls, columns etc.? I tried to run a request first, to see if the walls are already joined, but when i draw some new walls the sript keeps telling me, the new one are also already joined.

Great regards
Ammo

For finding intersection there is a new way:

we did some tests, and it´s fast!

3 Likes

@Johannes_Meiners

the nodes are great. But i am not really sure how they work. For example: the element.intersectelement. I use it to compare the elements and afterwards look if they are already joined, but then they wont join.
2018-02-01%2008_11_18-Dynamo

and sadly the new nodes wont solve the “already joined” problem. Am i even on the right way?

Regards,
Ammo

Auto Join without Order.dyn (22.9 KB)

I might have fixed the problem with not working on new build elements. And i might be faster, if i have implemented the bimorph nodes in the right way. But i do not now how to get rid of the secound “already joined request”.

i tried a differend code with s loop for the first request, but it just says that all elemts are already joined, if i have build new (unjoined) ones.

Regards,
Ammo

1 Like

Hi Viktor,
I’ve tried your script to auto-join a set of structural columns to a structural foundation slab, but the Python Script show a message, as you can see in the attached image.


What could causing this message?
Thank you for your help!!