How to debug 'Unhandled exception in Dynamo engine'? Arrrrg, not okay

I am working with a large workshared Revit 2022.1 model and sometimes get this popup in Dynamo. Is there a way to debug this? Any logs that might yield a clue?

Unhandled Exception

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. It is recommended that you save your work now and reload the file. Giving the Dynamo VM a new lease of life can potentially make it feel happier and behave better.

If you don’t mind, it would be helpful for you to send us your file. That will make it quicker for us to get these issues fixed.

Submit Bug To Github Arrrrg, ok

Object reference not set to an instance of an object.

at ProtoCore.DSASM.Heap.RecursiveMark(StackValue root)
at ProtoCore.DSASM.Heap.SingleStep(Boolean forceGC)
at ProtoCore.DSASM.Heap.FullGC(IEnumerable1 gcroots, Executive exe)* *at ProtoScript.Runners.LiveRunner.ApplyUpdate()* *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()

In C:\Users\[YourUsername]\AppData\Roaming\Dynamo\Dynamo Revit\2.12\Logs\dynamoLog_9c0048a1-118c-4eb8-9302-b148b36d055b.txt

The only thing I see that might be wrong is:

This graph currently contains nodes that are using the old IronPython2 (Python 2) engine which will be deprecated in later versions. A new CPython3 (Python 3) has been implemented and is accessible inside the Python editor.:
This graph currently contains python nodes that are using the old IronPython Engine which will be deprecated in later versions.Consider updating these nodes to use the new CPython 3.7 Engine.

Would Python version make that error?

And in C:\Users\[YourUsername]\AppData\Local\Autodesk\Revit\Autodesk Revit 2022\Journals\journal.0081.worker1.log
I see:

'ExceptionMessage:Sequence contains no elements
': line 216 of E:\Ship\2022_px64\RevitAdditions\Source\Addins\SteelConnections\Source\SteelConnectionsDB\SteelDwgServices.cs.

@truevis ,

in my case i try more and more using try statements to ignore Errors, so that the script can be executed.

When you have to many elements. I edit elements in Range f.e. when you have 10.000 Walls i handle 1000*10 so Revit can process it at least.

KR

Andreas

How do you implement try statements? In Python?

@truevis ,

her is an example

import clr
import sys 

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#functions
def tolist(x):
	if hasattr(x,'__iter__'): return x
	else: return [x]

#collector
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors)
all_doors = tolist(collector.WhereElementIsNotElementType().ToElements())

# GET ALL DOORS
doors_collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()
#if not doors_collector:
    #sys.exit("No doors were found in the project.")

# CREATE CONTAINERS
TUERSCHLIESSER = "TĂĽrschlieĂźer"
SCHLIESSFOLGEREGELUNG = "SchlieĂźfolgeregelung"
MAGNETKONTAKT = "Magnetkontakt"


vals = []

t = Transaction(doc,"TĂĽrschlieĂźer")
t.Start()

# LOOP THROUGH ALL DOORS
for door in doors_collector:
# GET VALUE
	try:
		if door.LookupParameter(TUERSCHLIESSER).AsString() == "TĂĽrschlieĂźer":
			vals.append(1)
		else:
			vals.append(0)
	except:
		pass

# SET PARAMETER
for d,v in zip(doors_collector,vals):
	try:
		door_out_param = d.LookupParameter(MAGNETKONTAKT).Set(v)
	except:
		pass

t.Commit()

OUT = vals
1 Like

So this gets around unknown limitations for huge projects? Might it be better to add a counter for “except:” cases to tell you how many failed? How did you know you had to use that instead of regular set parameter nodes?

@truevis ,

i tried several discussions here

KR

Andreas

1 Like

Is there any way to know which part of one’s graph caused the Arrrrg error?

Maybe I should just take 5000 elements at a time to process…

@truevis ,

yes

i do also ranges always like

x[0..1000]
x[1001..2000]
...
1 Like

I had some luck avoiding the Arrrg by restarting Revit and/or rebooting. Thus I suspect an app like CleanMem may help.

Could it be an issue with the graph itself - It looks like the conversion of an older script
If your comfortable digging into the .dyn with a text editor have a look for nulls and replace with empty lists [remembering to edit a copy]. See my comment here

1 Like