Dynamo automatically deletes elements of same script

Hi all,
I’m having another issue when using Dynamo. Firstly, I use dynamo to place some instances (family A type 1) at some specific location (by point). after that, I still use the same script to generate some new instances (family A type 2) at some new locations. When the new type 2 are generated, the revit automatically deletes all the instances of type 1. Anyone know what this problems come from? How to fix that?
Thanks a lot

Use Dynamo Player

1 Like

It is actually a “feature” of Dynamo, to allow easy testing. Otherwise you would have to delete every time you test a script. The easy solution is just to run the script, close the script, open the script back up and run with new inputs. But that gets very tedious pretty quickly.

thanks, btw it still happens even when i’ve already restart the computer

Can you share your graph so we can see how you’re creating the instances? The solution depends on where you are. Likely the best best involves utilizing transactions or creating the content in a different manner. Dynamo player may also be an ideal method.

1 Like

Hi Jacob, kindly take a look
pls check link for revit file
question.dyn (152.7 KB)

You can override this default behavior of Dynamo with a bit of Python script. Basically when the graph is run once, the elements created are bound together between Dynamo and Revit. An overly simplistic way to get around this is to close and re-launch Dyanmo each time and re-run the graph after changing your parameters. However, you could also use the method Element.ToDSType(True) to have new elements created every time you run your graph. A step-by-step of how this is done can be found in this Lynda.com video:

I’ll leave it to you on how to route your definition through that method. Basically after all the elements are ready in Dynamo to be ‘baked’ into Revit you can insert that Python code to trigger the override.
Let me know if that works for you!

1 Like

Hi @Tim_Halvorson
let me check it first and feedback you soon, thanks