"Unhandled exception in Dynamo engine" error when using Function Compose and List.Map

I used the Function Compose node to compose about 20 functions, starting with Applications.OpenDocumentFile and end with Applications.CloseDocument (Rhythm package), then used List.Map to have the compose loop through a list of Revit docs (around 35 documents). Each function in the compose more or less creates a number of geometries, tests these geometries with some standards, then ends up creating a result text file.

I expect to have the script loop through all 35 documents, but Dynamo is just able to loop through about half of it and reported this error:

Unhandled exception in Dynamo engine.
The virtual machine that powers Dynamo is experiencing some unexpected errors internally and is likely having great difficulties pulling itself together. …

Runtime exception occured. The type of StackValue is not FunctionIndex

at ProtoCore.DSASM.StackValue.get_FunctionIndex()

at ProtoCore.DSASM.Executive.GetCurrentScope(Int32& classIndex, Int32& functionIndex)
at ProtoCore.DSASM.Executive.DEP_Handler(Instruction instruction)
at ProtoCore.DSASM.Executive.Execute(Int32 exeblock, Int32 entry, Language language)
at ProtoCore.DSASM.Executive.Execute(Int32 exeblock, Int32 entry, List1 breakpoints, Language language) at ProtoCore.DSASM.Executive.BounceUsingExecutive(Executive executive, Int32 exeblock, Int32 entry, StackFrame stackFrame, Int32 locals, Boolean fepRun, Executive exec, List1 breakpoints)
at ProtoScript.Runners.ProtoScriptRunner.ExecuteLive(Core core, RuntimeCore runtimeCore)
at ProtoScript.Runners.LiveRunner.Execute(Boolean isCodeCompiled)
at ProtoScript.Runners.LiveRunner.CompileAndExecute(List1 astList) at ProtoScript.Runners.LiveRunner.CompileAndExecuteForDeltaExecution(List1 astList)
at ProtoScript.Runners.LiveRunner.SynchronizeInternal(GraphSyncData syncData)
at ProtoScript.Runners.LiveRunner.UpdateGraph(GraphSyncData syncData)
at Dynamo.Scheduler.UpdateGraphAsyncTask.HandleTaskExecutionCore()
at Dynamo.Scheduler.AsyncTask.Execute()

Could someone tell me where the problem is and how to fix it? Thank you so much. If you need any further information about the Dynamo graph, feel free to comment.

The problem likely lies in the size of the memory cache required to execute something like this. With function passing each node you pass into a function means data has to be passed into memory from end to end - no clean break point for the page faulting to push data from RAM to the disc as you’re doing it all at once across the entire list. As a result everything has to be stored there in the file until the graph completes the function.

And since you’re using function passing to open Revit files you need to account for the RAM required to open the file. That value is 20x the size of the file + the size of all linked files available as RAM. You can go a bit beyond that in the UI, or a lot in some cases if the majority of data is not model intensive, but for bulk processing like this you can assume you’ll want to full boat. So if we assume all of your Revit files are 100 mb (very small in terms of standard projects), you’d need 70 GB of available RAM to open the files - if your system has less than 64 GB of RAM you’re already over the limit. And that is before you even take the Dynamo graph, geometry conversion from Revit to Dynamo and back again, and general data processing into consideration…

Safe to say this is likely to have stability problems as a result, and possible corruption problems if it does stay running - all of those page faults are causing some concern. It’s just asking too much in my opinion.

My general recommendation is that as soon as you get into background processing of files you need to move past one Dynamo graph and incorporate another tool. Things to look at:

  • Convert the full graph to a python function, and incorporate your own memory management by disposing data as it becomes unnecessary.
  • Set the graph up to work on just the active file, then use Dynamo Multiplayer from Bird Tools.
  • Transition from Dynamo and the desktop environment to a cloud app on Autodesk Platform Services with Design Automation for Revit.
  • Transition to a zero touch node to do the garbage collection and memory management on a per file basis.

Personally I like the Python and Multiplayer options, but I would not continue on the ‘do it all in one graph’ workflow.

3 Likes

Thank you so much for the information you provided there.

Dynamo Multiplayer is exactly what I need. You literally just blew my 2 weeks of coding on this away.

1 Like