Hello everyone! I’m trying to automatically split cable trays, or any element for that matter, at a certain lenght.
What I found out til now:
-previously, the FamilyInstance.Split Method wasn’t avaible from the API, so people “shortened” the element and then made copies through a splitted curve. This, however, damages the connections between the trays and the fittings, and having so many of them, this is not an option for me.
-Searching through the 2019.2 API, I found that this method now exists and can be used.
So:
Is there already a node/package that uses this method? Or other way to do what im trying?
If not, how can i build my own python script to use that method? (I’m a Python beginner)
I guess I should first get the element curve and split it, getting the points in which i would split the element
Then i would feed the script:
element=IN[0]
points=IN[1]
which libraries should I import? how should i build the code? I guess it would be something simple, but as I said, I’m a beginner at Python.
could you upload a sample file with those elements? (cable trays and connected fittings…)
I am not very familiar with MEP parts of Revit, but can try smth with Python
ok…good news and bad news…
the code to make it work is pretty easy, but it does not work with cable trays… (works with beams, columns though)…
I think you might have some chances with making a script that would first do the copy and shorten trick and reconnect necessary elements…
# Enable Python support and load DesignScript library
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# The inputs to this node will be stored as a list in the IN variables.
elements = UnwrapElement(IN[0])
params = IN[1]
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
for e,p in zip(elements,params):
e.Split(p)
TransactionManager.Instance.TransactionTaskDone()
# Assign your output to the OUT variable.
OUT = 0