Reset Python script engine

Hi
Is there a way to reset the IronPython script engine without opening the EditPythonScript window ?
I’m looking for a way to do that programmatically.

Hi Emilio,

why are you trying to do that? It’s actually a very sensitive thing to do, and scripts should not be structured to make use of it. Is it maybe because you are trying to reload one imported module?

If so, you can use the Python-native reload(module) function.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Ciao Giulio,
the idea is to store some initializing data into the script.
The user could adjust one or more parameters and the script would ‘remember’ them.
Without having to use a different file for that.
The script would be ‘monolithic’ and the user would not have to worry about other files.
I tried that with a small test script and saw that the script is able to edit it’s own source file.
But to see the effects of the editing you have to close and reopen Rhino.
I thought it would be cool not being forced to close & reopen … :smile:

OK, I think I can store things as user data and have them available immediately.

Grazie, ciao !
emilio

I see. So, the way to reload a module in Python is really the reload(module) function. Why do you think it will not work for you?

http://docs.python.org/2/library/functions.html#reload

I think storing things in user data will be better in the long term, though.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

I thought that a module could not reload itself.
Is that possible ?
I thought I had to look for a way to reset the script engine from outside IronPython
Does that make sense ?

emilio