Dynamo fails to execute parts of the definition on subsequent runs

Hey,
Me and my colleagues that are using Dynamo have noticed that it’s sometimes required to reconnect inputs or toggle a boolean back and forth to make Dynamo run when “Run” button is pressed in manual mode. Usually everything works fine the first time a dynamo script is run but upon re-running the script sometimes nothing happnes and the solver does not even start running.

My questions are:

  1. Why does this happen?
  2. Is there any way to avoid it?
  3. and is there some command I can implement in my python-scripts to “refresh” or “retoggle” the node or file?

This behaviour of Dynamo is really annoying and makes it unreliable. If there’s no current fix, I’d say that this is a major bug that needs some attention, it really lowers the usability and user experience of Dynamo.

Best

Jakob

hi @jakob.lilliemarck
forcechildernseval from the prorubim package can help do that :

3 Likes

hi @Mostafa_El_Ayoubi,
Thanks for your reply.
Do you know what API command/commans to call in IronPython to get the same functionality? I rather not make my script rely on another dynamo packages.

Best

Jakob

I would have to see an example graph to know for sure, but I believe that this functionality is intentional and actually a feature rather than a bug. The usual reason for parts of a graph not running a second time is that no inputs have changed, so Dynamo doesn’t spend any time or resources re-calculating those results, and instead returns the previous values as they were stored in the RAM/scratch disk. This makes creating small portions of large graphs that use large datasets possible. Otherwise you would have to wait for five minutes to find out if the little bit of code you added at the end behaves as intended. This in fact makes graph creating and scripting easier, and creates a more reliable environment as its more stable to boot.

There are a few ways to force reruns, using packages such as the one noted below is one. I recall that reading a file (excel, CSV, etc) that has changed is another as Dynamo appears to check the path and the last modified date prior as the input consistency check. I find that the best method to do this is to use Dynamo player instead of Dynamo for Revit based stuff.

If you post an example graph and elaborate on what nodes you need to rerun and why you need them to I can try and provide more insight later today.

2 Likes

Hi @jacob.small
Thanks for your reply.

I must disagree, even if this is intentional it’s a temporary solution at best and should probably be assessed as of the current rather mature state of Dynamo. In manual mode one explicitly tells the solver to “RUN”, and should then be able to rely on that the script actually runs, all other outcomes would just be misleading.

If Dynamo are to make assumptions about if the graph should or shouldn’t re-run due to input changing or not, that will need to be done in a more elegant way than this. One could get inspired by Grasshopper in this regard, which works both expectedly and reliably.

For instance if i create a Python script that doesn’t take any inputs (thats the graph I have and want to run), time is one parameter that will change between the times when I press “RUN”, altough the solver will not recognize this and will not re-run the second time (unless I change some pseudo-input). The same is true also for many other occasions, such as editing a python script or wanting to re-run a batch-export script, etc.

I’ll have a look at the alternatives to force reruns.

I understand where you’re coming form, but to be honest if I had to wait for Dynamo to recreate the geometry of every guard railing in order to write the script to confirm the stair meets the required egress width than I wouldn’t bother to script it. Too time consuming to write. A re-calculate all run mode would be nice in your case though. I’ll see if I can get someone’s ear to discuss this later today.

Have you considered running the graph via Dynamo player which automatically recalculates the entire graph each time you run it?

I’m having this same issue with a graph that contains a Python node, where the graph will not recalculate even when played through Dynamo Player or a boolean is switched. The only way to get it to rerun is to actually change the Python script within Dynamo. What’s different about this case? The script I’m using is Data-Shapes’ “Export Views to Navisworks”. I just used the code so I don’t have the dependency. (See below)

There’s no issue with overwriting the exported files because when I do change the script it reruns and overwrites.

It’s not terrible that I have to change the nodes, and Dynamo Player is awesome for everything else, I just want to understand.

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import*

clr.AddReference(‘RevitServices’)
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

if isinstance(IN[0],list):
views = UnwrapElement(IN[0])
else:
views = [UnwrapElement(IN[0])]

prefix = IN[2]
for v in views:
nop = NavisworksExportOptions()
nop.ExportScope = NavisworksExportScope.View
nop.ViewId = v.Id
doc.Export(IN[1],prefix + v.Name,nop)

OUT = “Success”