View Full Version : Source command question

07 July 2012, 02:33 PM
Hay guys,
I'm trying to source a mel file from subfolder of scripts directory but without success.
I have a folder called "myCustomScripts", which is top level folder and I already added it to the Maya.env file. In that directory there is another folder called "Modeling". Now I'm trying to source the script from "Modeling: folder.
source ("Modeling"+"\\"+"script.mel");
orsource ("Modeling"+"/"+"script.mel");
and I get syntax error. Can't figure out what I'm doing wrong.

07 July 2012, 03:16 PM
As long you add the path of where your script is in Maya.env in the MAYA_SCRIPT_PATH environment variable, then you should be able to source your script like this:

source script.mel;


source "script.mel";

Don't need parenthesis-- I think that's why you get the syntax error.

Hope this helps!!

07 July 2012, 03:20 PM
eval(" source \"Modeling"+"/"+"script.mel\";");

Just remember to escape strings when you run commands this way, else mel won't understand what you're giving it.

07 July 2012, 04:01 PM
Thank you.
This directory is not added in the MAYA_SCRIPT_PATH variable.


Thank you! Now it works!

07 July 2012, 04:22 PM
Actually I'm building menu and the command will looks like this :
menuItem -l "Tool Name" -c ("eval(\"source\\\"Modeling\"+\"/\"+\"script.mel\\\";procedureName();\")") ;

CGTalk Moderation
07 July 2012, 04:22 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.