View Full Version : After I save a Mel script, do I have to restart Maya to run it?

10 October 2005, 08:40 PM
I was surprised I couldn’t find an answer to this by searching the Maya sites.
Although not clearly specified anywhere, I gather from everything I read so far that when I save a script to one of the 2 script directories - maya\scripts or \maya\7.0\scripts, Maya should be able to run the script without restarting, however I can do that only after restarting Maya.
Is this how it is suppose to work?

Also: from one reading, It was suggested that I change the Maya.env file by adding this-
C:\Documents and Settings\User\My Documents\maya\7.0\scripts ;
C:\Documents and Settings\User\My Documents\maya\scripts;

I have two Maya.env files - one in Maya and the other in 7.0 folder and I have added to both of them the above code.

Will appreciate you help a lot.

10 October 2005, 09:51 PM


into the command line and hit enter. Since Maya 6, they added in the script cache. Maya reads all of the scripts in the locations specified in your script path, and stores a cache at startup. Adding a script while Maya is running, means you need to tell Maya to rebuild the cache file, hence the rehash; command.

10 October 2005, 02:42 AM
Perfect help and perfect explanation. Thanks a lot Mhovland.

10 October 2005, 06:11 AM
Hey, thanks! Nice to know this.
That saves me from a bit of trouble next time.

10 October 2005, 02:02 PM
When I script I always have a sourcecommand on a shelfbutton + the proc to run the script.
(If it doesn't execute by sourcing) So whenever you edit this you just click the button to re-source it. Should work with new saved scripts too.

10 October 2005, 03:33 PM

Your method will work as long as the script was present at start up. If you add a script after Maya is running, you will need to do a rehash. Try it out, create a new script and save it into the script path, after Maya is running. Then try sourcing it. You will get an error that says it can't find the command for the source statement.

10 October 2005, 03:46 PM
Ok, no time to try, but I believe you :)

10 October 2005, 04:39 PM
I can vouch for that - I run maya mostly to write scripts and test them out, so I've gotten into the habit of shutting maya down and bringing it back up everytime I write a new one. I've suspected that there was some caching behavior under the hood somewhere, but didn't know what to do about it until now - thanks mhovland (^_^)!

Now I just need to find the command that will do the same thing when I've updated a plugin but Maya still remembers the screwed up state ...

10 October 2005, 06:46 PM

To do the same, in effect, when coding plugs, you need to write a script that wil unload the old plug, then re-load the newly compiled plug.

Here is the code to check if the Iges.mll plug is loaded, and if it is, unload and reload it, otherwise (not loaded), just load the plug. Modify for your specific plug.

if(`pluginInfo -q -l Iges.mll`)
unloadPlugin -f Iges.mll;
loadPlugin Iges.mll;
loadPlugin Iges.mll;

CGTalk Moderation
10 October 2005, 06:46 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.