Save all -> reset script-engine -> run


I’m working with different modules imported in a single main python script.
In order to run the scripts after editing them, I need to save all the scripts, reset the script-engine en only after that I can run the new scripts.

I’d like to have a single click solution: ‘save all -> reset script-engine -> run’

Does anyone have an idea how to solve this. Else I’d like to opt for such a button in the script editor.


I have been thinking about this for a while, but, please accept my current opinion… with some excuses in advance.

“Reset script engine” was a bad decision to start with.

Rhino is a single ecosystem, and destroying any previous script engine will not work well for any other client of the previous engine (for example, GhPython, or any other plug-in). If you are at a point where the previous engine absolutely cannot work, then probably there is something that needs to be fixed beyond the scope of the engine.

An option is always to arrange the workflow so that a few calls to the standard Python reload() function will make all work again. There are cases where this is a little hard, but it’s still worth it.

The reason that destroying the previous engine is deleterious, is that any type managed by the previous engine will also be invalidated and replaced by new, diffferent types. However, the old ones may well be in use (for example, they could be Grasshopper components on the Grasshopper toolbar, or a panel, some Eto UI dialog, a background thread worker, …).

If we did compartmentalize the engines (I am not sure it is even possible, but let’s say that GH has one, Rhino has another) then they could not directly share types, modules, instances… for example with the sticky variable.

So, I personally hope the “abuse” :slight_smile: of Reset script engine will not be further perpetrated.
I am sorry for this slightly unwanted answer :smiley:



Giulio Piacentino
for Robert McNeel & Associates

Hi Giulio,

I fully understand you point of view.

Reloading is indeed an option, however with a dozens of modules I don’t want to keep reloading on each run. I only use the scriptengine-resetting when developing/debugging, so I’ll have to accept the current implementation.

My main issue is that during development, when I edit a module, I either have to have build in reloads in all modules importing it, or hit a scriptengine reset.

I don’t know how other systems handle this, for instance a typical IDE will reload all modules that have changed right? Are there no smarter solutions to this problem?

Thanks for the detailed explanation of your considerations

1 Like

So you develop 12 modules all at the same time? Are you sure that Rhino is the Rhino right IDE for that?

I’m pretty sure you could structure your modules into a package and just reload that top namespace, never tested this though.

No,. But I don’t know if an alternative IDE from where I can run and debug code in Rhino. Any suggestions?

I use pycharm for managing the overall structure and do the coding that connects all modules.

I do (unit)test scripts and modules separately. However our workflow involves “parsing” many objects through a pipeline of scripts. While doing test runs I need to fix small issues that come up. The only way I currently know of is doing this in the Rhino scripteditor.


Just to share my experience: It is not always about the number of modules. Sometimes you have subclasses or modules that are using an object from another module. In those cases reloading won’t neccassary work. I end up closing Rhino and reopening it in such cases but a reset script engine in such cases can be helpful. I understand your arguments against it so …

I have done this and it won’t work in most of the cases unless you are importing all the modules in which is not considered good practice anyways.

1 Like

To add another example,

I implementated logging, however if the script crashes due to a tiny vector that didn’t get caught, I need to reset the scriptengine in order to flush any “trailing loggers”.

Note that I’m self taught so I might not handle stuff with the best practices.:wink: