Structural Framing output gets replaced with every run

Hi,

I’ve created a simple Dynamo script that creates curved parametric trusses between two columns. The idea is that the user can select columns at various areas to create the trusses over consecutive columns or entirely different sections.

The problem is that every time I run the Dynamo script (from player or platform), the output from the previous run is replaced and I can only ever create one truss using the one script.

Is there a way to lock the outputs of each run into Revit so I can create multiple outputs without having to pre-define the number of trusses or create multiple scripts?

So once I’ve made the truss below, the next time I run the script (pick different columns) the truss will disappear and be replaced by the new truss, even when it is at a different location.

This is the next run of the script after the first truss is made:

@Gary.iwansantoso

There were some discussion of it and some packages already tackled this.

Also, you could try this: wrap the creation segment of your graph into a python node, call ToDSType(True) deliberately to your elements, giving the ownership to Revit instead of Dynamo. If I remember it correctly, ToDSType() will do the trick.

1 Like

Thanks @jshial would you happen to have some resources/examples for the usage of ToDSType?

I’ve been trying to get into transactions and API programming, but finding it difficult to find easy-to-understand resources. The Bakery package requires me to uninstall the Rhythm package due to dependencies, which I can’t do since I have other scripts reliant on Rhythm nodes.

@Gary.iwansantoso

example.dyn (16.0 KB)

(demo model is too big, failed to upload. I just drew 2 model lines for creating walls.)

To clarify, ToDSType(True) will grant Revit the ownership of element.

In the example above, same set of data to different creation methods: OOTB node Wall.ByCruveAndHeight against Wall.Create() in the python node (https://www.revitapidocs.com/2020/0ce4c555-4cee-f5fd-2e84-43cacf34ac5c.htm) with a ToDSType(True) called.

image

curve = IN[0].ToRevitType()
wall_type = UnwrapElement(IN[1])
level = UnwrapElement(IN[2])
height = IN[3]

TransactionManager.Instance.EnsureInTransaction(doc)

wall = Wall.Create(doc, curve, wall_type.Id, level.Id, height, 0, False, False).ToDSType(True)

TransactionManager.Instance.TransactionTaskDone()

OUT = wall

Resources for later :point_down:,

https://primer.dynamobim.org/10_Custom-Nodes/10-5_Python-Revit.html

So I’ve managed to get this far and in trying to replicate the script you’ve sent gave me the error in the pic above.

When getting rid of the ToRevitType() - I come across the error of “expected XYZ, got Line”.

Does it possibly have something to do with list management issues?

@Gary.iwansantoso try this:

curves = [item.ToRevitType() for item in IN[0]]

@jshial well that fixes the RevitType error, but the “expected XYZ, got Line” error persists.

It is somehow detecting the wrong method from the Revit API Docs below:
image

It is so close :rofl:

@Gary.iwansantoso is there any chance that MBracing.ByChordPoints accidentally yield some points. Not lines exclusively?

Can you confirm there are no element bindings in play? If they are already there player will ‘update’ them but not save the new bindings.

If you aren’t sure what element bindings are, check this post: Element Binding in Revit.

There is also my AU class and associated documentation linked in there, and a if you’re just curious you can get a quick highlight starting around the 12:50 mark of the video here: Element Binding in Revit

Solved! Thanks for your help @jshial and I did remove the binding from the .txt file @jacob.small

Turns out “level.Id” does not goes into the NewFamilyInstance method and I suppose the UnwrapElement already took care of this. I was blindly following guide for it so there ya go.

I’ll leave the script below for any future reference!

1 Like