Joining/Unjoining Tool

Good morning everyone,
I am using dynamo in order to accelerate the process of joining elements.
I have several hundreds of structural framing, structural columns and floors that I need to join in order to avoid double concrete volumes in schedules.

In this video I have found a python script that does what I want, allowing me to join, unjoin or switch join order for a certain group of objects.

The problem is that I am dealing with a really large quantity of elements, this is why I want to apply this definition to group of elements that do not necessarily intersect. This leads to a massive amount of warnings.

Thanks to the “does intersect?” node I can get where I want in terms of lists: for example, I would have a list of n floors and a list of n sub-lists in which all the beams intersecting each floor are contained.
Obviousluy the python script won’t work with this list structure.

I know that there might be alternative solutions to my problem (like solving the warnings in a second moment or other) and I appreciate all kind of suggestions, but I really want to improve my python skills.
For this reason I would like to ask how can I adapt the scripts shown in the video in order to get there.

I think this can be useful for many people: there are several python scripts out there, they can be applied to a single set of elements but they don’t always work with sublists.

Thanks in advance!

This is the code of the video:

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)
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

elementA = UnwrapElement(IN[0])
elementB = UnwrapElement(IN[1])

doc = DocumentManager.Instance.CurrentDBDocument

results = []
TransactionManager.Instance.EnsureInTransaction(doc)

for A in elementA:
for B in elementB:
try:
result = Autodesk.Revit.DB.JoinGeometryUtils.JoinGeometry(doc,A,B)
#The function on the previous line can be replaced with SwitchJoinOrder or UnjoinGeometry.
results.append(result)
except:
pass
TransactionManager.Instance.TransactionTaskDone()

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

I haven’t used this code before so let me make sure I understand everything…
Normally you would input one list of elements to join with another list of elements. You want to input one list of elements (floors) to join with a list of sublists of elements (beams), but this doesn’t follow the same list structure.

If this is the case you just need to modify your for loops a little bit. If your floors already align with your beam sublists you can iterate through them together. Try for A,B in zip(elementA,elementB): instead of separate loops for A and B. Then you can have another for loop for each beam within the beam list B.

Try creating a custom node with the python. With minimal effort you can then make use of not only lists but also lacing and levels.

2 Likes

@jacob.small’s suggestion is definitely the easiest and most straight forward approach.
However, if you want to improve your python, it shouldn’t be too difficult to get your list structure working.

1 Like

Thanks to both of you, @jacob.small and @Nick_Boyts.
The solution proposed by Jacob works well, but I will also try with Nick’s suggestion.