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, @jacob.small
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!

5 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

2 Likes

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!!

Hi!
Thanks to the basis provided by @ammo (et al. :wink: I built a nice flow for automatically joining elements by category, tested and working for simple cases, which I’m sharing.

I noticed that the join operation follows Revit standard criteria for determining which element/category dominates on which (like structural columns on walls, walls on architectural columns and so on…), hence I wanted to ask around if somebody knows how to tweak this logic via script before performing the joint, without having to switch join order after that.

Like I already know/want that my architectural columns will cut trough walls instead of being merged into them, how could I explain that to big R?

Thanks!

MT

Join categories of elements.dyn (72.7 KB)

Hello @mario.trabucchi ,

Try Join.K-Join All In One script in Synthesize toolkit package in the extra folder, it works on mega sized projects, and doesn’t require fetching the geometry AT ALL, also contains all the options to switch joining order for already joined elements, or for newly joined elements and much more…

There are also other variant like : Join.K-Join Two Categories or Join.K-Join Interference Check
Also, there are the same variants for Unjoining, just search for Unjoin in the extra folders too… I’d recommend you browse to that folder using Dynamo Player, they are prepared to be very much user friends and easy to use.

General more information:
One of the worst common mistakes in those kind of scripts is to fetch geometry, there are so many smarter ideas to do to avoid that… you can investigate K-Join and see how it works. it’s a python code.

1 Like

Thank you @Karam_Baki !
I tested it on an easy case and it works great, looks like a very powerful toolset!
Still a little bit complex for a user like me but definitely interesting! Are there some documents/tutorials about the package showing how nodes can be used or so?
(I am really moving my first steps into Dynamo/Python/Design Script)

Thanks a lot, I really appreciate!

1 Like

Hello @mario.trabucchi am glad you liked it. am planning to document everything hopefully soon, it will take sometime, as there are more than a 500 tools in there… and I have some clean ups to do too…

In any case I’d recommend you digest and analyze some of them in your way learning Python for Revit API, there are some really nice tricks inside, especially the ones that starts with “K-” those have some countless hours spent into creating them.

1 Like