Error: "object expired during a solution"

I have a Python 3 script running in Grasshopper (Rhino 8.10.24228) that sets the values of other components while running. This causes the predictable problem of expiring downstream components which results in the error window: “object expired during a solution”. In previous versions of Grasshopper, I was able to get around this problem by disabling the solver in code:

Grasshopper.Kernel.GH_Document.EnableSolutions=False

This had resolved the problem in the past, but with the latest update of Rhino I’m seeing the “object expired during a solution” errors again, even though it appears the Grasshopper solver is disabled.

Screenshot 2024-08-28 143243

Is there anything else I need to do in my scripts to edit other component values without hitting this error? Thanks for any ideas.

More background info that might be helpful…

Depending on the type of component whose value I’m setting I set values like this:

panel:
component.SetUserText(str(val))
slider:
self.component.SetSliderValue(typedVal)
curve:

component.AddVolatileData(gh.Kernel.Data.GH_Path(0), int(0), Grasshopper.Kernel.Types.GH_Curve(curveId))

Rhino:
Version 8 SR10
(8.10.24228.13001, 2024-08-15)

After looking at this more. I’m wondering if I had just [safely] dismissed the error in a previous Rhino version (with the checkbox selected for “don’t show again”) and so the latest Rhino update started showing me this error message again. It still seems strange that this error could happen at all while the solver is disabled though.

@Jonathan_Garrison How are you type checking in Python 3 to determine panels and sliders? Sharing a simple script and GH definition that replicates the problem would be super handy

1 Like

Ok, I’ve created an example GH file that demonstrates the error. The demo file revealed something interesting. The “object expired” error only appears when I am disabling the solver. Not disabling the solver appears to allow the code to run just fine. My example file has two python scripts that show running with and without disabling the solver.

To answer your other question, I had been checking the component type before setting a value just by the presence of the methods that I wanted to call on components. Primitive, but it worked. If you have a better alternative, please let me know. All components in Python appear to have the type “IGH_DocumentObject”.

Thanks for thinking about this!

Set_Component_Values_SolverOptions.gh (19.2 KB)