How To Load A Script Again Without Restart Maya?

Hello,

when I run my Python script in Maya and expect for example an error. After I’ ve edit it I have to restart Maya because Maya doesn’t notice the modification and run the old script. How can I say Maya to load the new script without a restart? I tried to clear the History and the Input and import the script again but nothing happened.

Thanks for help

not maya issue standard python stuff, read something like:

http://www.ibm.com/developerworks/library/l-py-fly.html

should give you a idea.

let’s say you have the script myScript.py in witch you have the function doStuff()

simply do this in the maya command line:

import myScript
reload(myScript)

myScript.doStuff()

drag this in a shelf… now you simply have to edit the script in a real editor (ultraedit, wingIDE, eclipse, etc)
save the file in the external editor

press the shelf button

enjoy

Thanks a lot it works. I have not used the reload() function.

My way was:

import myScript
instanceOfClass = myScript.myScript()
instanceOfClass.doSomething()

The shelf is a verry comfortable idea .

also note that if in your main script you are importing a second script. It might be useful to import and reload both scripts in the maya shelf to be sure everything is up to date. Even when you are only calling the first script in Maya

yes I’ve noticed it.

Thank you