Block Replacement Deletes Previously Added Block on Second Run

Hello everyone. I’m creating a function where I select a block and replace it with the correct one. After the replacement, the old block is deleted.
The first time I run the routine, everything works perfectly. However, when I run it again, it deletes both the selected block and the last one that was added.
It seems like, at the end of the routine, the last inserted element remains in the selection list.

Does anyone know how I can fix this so that the routine doesn’t delete the last added element?

Are you closing and reopening the dyn between runs or are you just consecutively rerunning the same instance of your graph? Rerunning a graph will “update” the changes made, not add to them. This is due to element binding and is the expected behavior. If this still occurs after closing and reopening the file to run as new, then most likely your element binding isn’t clearing properly.

Check my post on Element Binding for more info.

Specific info for Civil 3D:

Thank you very much Nick, Jacob and Zachri! With your tips, I was able to understand what was going on, and now everything is working as expected.

thanks for the info @zachri.jensen

I’ve had a long break from Dynamo- so excuse me if it’s been covered somewhere obvious.

Is this binding behavior just for Civil3D, or can the same apply in Revit ??

I had a feeling that I worked around this (many years ago so my memory is a bit sketchy) by doing something to make each element unique for each run. Maybe assigning a parameter with now() data, or something like this

Hi @Andrew_Hannell,

Element binding (same thing, different name) is also in Revit, but the options for turning it on/off and choosing how the data is stored are unique to Civil 3D.

thanks @zachri.jensen

yes, I meant:

It would be great to have this in Revit flavoured Dynamo someday

Revit doesn’t have a way to remove at this time - best to put in a wishlist item on the Revit roadmap as the Dynamo team doesn’t own the implementation.

1 Like