I’m having a small issue with my script.
While it does what it’s supposed to do, after a first batch of families are created, if I try and load some other families in the model, for some reason they will replace some of the existing ones.
Any ideas what I’m doing wrong?
I think that this has to do with element binding, Dynamo is created in such a way that the results of previous runs don’t stay when you’re running the code again with other inputs. There should be a way in the script to disable this, but I’m not sure how, @jacob.small probably knows how though.
Another way to prevent this is by using the Dynamo player.
I’m trying to place some family instances as selected. The UI will prompt the user to select which of the components loaded in the model to place at project base point and use in the project.
What goes wrong here is that if at a later date you plan on adding more components, the older one get replaced with the new ones.
Hope that makes sense.
The script is ran again with a new selection of families.
The original family instances get replaced with new families.
Is that correct? Do the original family instances get replaced by the newly added families? Are the newly added families the ones being selected the second time the script is run? Are you only selecting the new families on the second run or are you selecting all families that need to exist?
Yes, it works every time.
I guess it could be ok as long as I have more than before
I would also want to get to the roots of why it’s not working, it’s not good for my OCD
Yes, I agree with both statements, but wanted to make sure you at least had a workaround.
To ensure that you always have the correct outputs, you could also delete all instances of those families before placing the new ones. Then the previous selections shouldn’t matter. This is also just good practice for workflows that may be running more than once in a project and could potentially “stack up” on each other.
Otherwise I suggest looking into element binding and/or maybe looking at another way to write your graph (same logic, just different methods).
I know Player is supposed to eliminate binding. As a test, open your script in Dynamo. Disconnect the first input to make the script run without inputs and error out. Reconnect the first input and save the script without re-running it. This is basically clearing out all bindings. Then run the script in player from that point. Reason for my madness. I have a script for creating schedules. No matter what I changed the name of the schedule to, it always updated the existing schedule. So advice on another thread from @jacob.small, the steps above fixed the issue.
We also struggled with element bindings, wondering why we were losing hundreds of families again and again. It was because we had so many scripts for family placement that were copies of each other.
Now as I`m aware of the problem, I build my graphs with a function apply node, like jacob small recommended in another thread. This way no element bindings are saved in the graph.