View Full Version : Question on Sourcing scripts
I'm trying to call in my main script a global proc I've created in a external file located in the Maya script Folder.
In Maya's help, as I've understand, you just have to call a glob proc with the name of the file, then maya will search in its script path and then source it..but...it doesn't work, I have to source the file with the source function add the beginning of my main script..is that the correct way to do this ?
For the file path of the source function, I've to put the full path to Maya's script folder for Maya to find my .mel file...I do'nt know the variable or a string shortcut to maya's directory..I found the pwd function but is that the simpliest way ?
Sorry for all these noob questions and thanks for helping...
01-09-2008, 05:04 PM
do you know the userSetup.mel file? this is a script file which is executed when maya starts up. you can write in this file a command which sources your other script file (i would copy it to the same folder). then your command is available without problems.
if your userSetup.mel file doesn't exist yet you can create one yourself but it needs to be in your scripts folder. in my case my file is located at: "C:\Dokumente und Einstellungen\Patrik Hadorn\maya\scripts\userSetup.mel"
so on windows it is: %USERPROFILE%\maya\scripts\userSetup.mel
if there are still any questions please ask
hey thanX Gravedigger, I did'nt know that userSetup.mel, pretty cool to Source all my little tools...but...actually my problem here is for a tool I'm writing for everybody, so people will have to install my script in their script folder, going to be 1 main script and 1 files containing global proc I wrote for the main script. I don't think I can use the userSetup.mel in this case, more a function for me and my personal procedure. Actually I think the main script will have to source the global proc script for everything to work fine...but still I not sure it's the best way to do it...and I don't know a function to get the path of the script folder directly
01-12-2008, 04:16 PM
Put this in your main script
string $scriptDir = `internalVar -userScriptDir`; //Maya scripts directory
string $scriptName = "data.mel"; //file containing your global procs
eval("source \"" + $scriptDir + $scriptName + "\"");
01-14-2008, 09:45 AM
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.