How do I rerun my script and remove element binding (Revit)

How do I rerun my dyn on new elements without losing the old elements? How has this not been implemented in 2022

Try Monocle
It’s in the package manager
When installed there will be an option extra in the Help menu
You can also run your script on an empty Revit file (does nothing) and resave the script
Or run it on Dynamo player
There may be other options too
Correct me if i’m wrong here
@jacob.small

1 Like

Thanks for the info @Marcel_Rijsmus . I’m running it through the Dynamo player which is a bit crude but it gets the job done.

Run through player or use function passing. There are options but the default is binding because even with binding on by default there are a few dozen models I see each day that have duplicated elements (with the matching warnings) as a result of someone trying to side step bindings and putting dozens of identical elements into the model.

Does that mean things slip by in my methods? Except player?
And what is “function passing” ?
(Not on God level yet.)

Remove the longest list input from the node which creates the elements (ie: a list of points in the FamilyInstance.ByPoint node), and you will see the node goes from a dark grey color unifications it is active, to a light grey color. If you look at the data preview of this node it will return “function”. This is one of the object types which we will pass onto the next node - passing a function.

Now place a Function.Apply node on canvas. This node has two inputs, one for the function we just made, and one for the argument (Like the List.Create node it can also be expanded, but that is for another day). Now take the data you disconnected from the last node (the list of points for our FamilyInstance.ByPoint node) and connect that to the argument input. Run the graph and you will see the elements are created.

Function.Apply (and similarly List.Map) do not create bindings, so if you run the graph again tomorrow and you will wind up with duplicate instances. This can be an advantage for a few, but really the best solution is to use Player or to use bindings to your advantage.

This also suppressed all warnings. This is nice for some instances (no users being worried about the warning message), but it also hurts as bulls mixed into your data will not show up until you do a deep manual review of the results.

This is however slow by comparison. This has to do with how functions are handled under the system, but the full ‘why’ is over my head and frankly not a concern to me, suffice to say I know about it and can tell others. Perhaps we will see an improvement with that speed in 2.13 or 2.14, but I am not aware of where this is on the development teams radar.

2 Likes

Thanks @jacob.small . I read through your other detailed post about bindings. While I understand the relevance to the platform, there are many instances where the process could benefit from something similar to grasshopper’s bake process which removes all the bindings. Sometimes one wants to run the same script but on different parts of the model for instance. Thanks for your explanations though, they are very helpful.

@jacob.small on a similar note: how do I ensure that I am not filling the model with 1000s of instances? Would they be visible? Thanks!

Check your warnings and address any ‘duplicate elements. This should be done on every model 1x a week or more.

@jacob.small Can you spell out the function apply for me again? I’m missing something. Even dynamo player is keeping the element binding so I’m not sure what to do at this point…

Just to vent a little, this whole element binding defeats the point of creating a reusable script. I had to duplicate all the nodes so that I can tweak two parameters and rerun the script on a separate segment of the model.

The element bindings are necessary otherwise running Dynamo in automatic mode wouldn’t work. A work around I like is to have the script select the newly created elements at the end of the run, if I don’t want them to bind then I’ll ‘ctrl-x’ , paste-aligned. Cutting and repasting unbinds them.

Hint: set up a shortcut for paste-aligned. eg. I type ‘ctrl-x,PA’ after a script has run

2 Likes

Run the reusable script via Dynamo player after stripping out the bindings. Done this way and the bindings never come into existence.

I’ll put a graph together on Monday showing the function passing.

@jacob.small Sir, I tried something like this:

TransactionManager.Instance.TransactionTaskDone();
TransactionManager.Instance.EnsureInTransaction(doc);
//createRails = new Autodesk.Revit.DB.SubTransaction(doc);
//createRails.Start();
        //some code calling FamilyInstance.ByGeometry by Spring
//createRails.Commit();
TransactionManager.Instance.TransactionTaskDone();

And my Zero-Touch node still delete the instances created by first running:


I even tried subtransaction, as comment in my code, and it doesn’t work neither.
I’m sure it’s the last “Dynamo-51297CB5 Script” that deleted the instances created in the first running, cause when I UnDo the last additional “Dynamo-51297CB5 Script” operation, the instances created in the first running came back.
Could you please tell me what did I miss.I think I’m quite close to my purpose. Thank you very much!
BTW I’m restricted to revit 2018and no heigher version

Hi,
@john_pierson made a video about this.
Never had issues with his Zero-Touch node and element binding.
Hope this helps.

I’m restricted to Revit 2018and no heigher version. Look like Dynamo 2.5+ has the functionality shown in the vedio. And walk around please?

See this post and the linked content: Element Binding in Revit

@sascari If you want to auto-delete the element binding in your .dyn you can use my batch and powershell code from here:

Thank you sir and so much! Now I totally understand!