View Full Version : Script path
11-23-2011, 02:08 PM
Maybe this question has already been asked, but I didn't find it...
I'd like to get the default script path in a string. This is how I've done :
proc string JPL_Path ()
string $scriptPathArray ;
string $allPath = (getenv ("MAYA_SCRIPT_PATH"));
string $tokPath ;
tokenize $allPath "\;" $tokPath;
string $buffer ;
tokenize $tokPath "\/" $buffer; //index 0 is default project, 1 is scripts
for ($i = 0 ; $i < size ($buffer); $i++)
$scriptPathArray [$i] = $buffer [$i];
$path = stringArrayToString ($scriptPathArray, "\\\\");
string $path = JPL_Path ();
It's a little bit long, I'm sure there is a much easier way to achieve the same thing.
By the way, I'm not sure that the order of MAYA_SCRIPT_PATH is always the same: if it's not, the index I chose may be wrong in some case...
Maybe I missed something easy and obvious, I look forward to your advice.
11-23-2011, 10:35 PM
what is the "default script path"?
I tried your code and it returned my current project path, which you can get with the slightly more concise:
string $proj = `workspace -q -o`;I'm not sure exactly what it is you're after...
11-24-2011, 08:56 AM
Thanks for your reply, NaughtyNathan!
But this only returns the project you're working in.
If you tried my script, this would mean that the getenv command doesn't return the paths in the same order... I tried on several machines (Maya 2009), and it worked (even on MacOs, Maya 2011).
What I am looking for is something like: "C:\Documents and Settings\user\My documents\Maya\(version)\scripts"
Actually, I want to insert pictures in a gui whithout having a hard coded path (it must work on any workstation, regardless of the user's name and the version of Maya).
I was wandering if there was an easier way to write this code (assuming it works...), or even if there was a way for Maya to automatically load the picture whithout explicitly giving the path (something as simple as: image -image "myPicture.bmp"; )
11-24-2011, 10:15 AM
Oh, by the way, I don't know why I've written a for loop, which writes in an array exactly the same thing as there is in the $buffer array...
I guess it was only the pleasure to write it (or my neuronal connections don't work fine).
Have you considered
11-24-2011, 10:55 AM
This is just what I was looking for! Thanks a lot!!
11-24-2011, 10:56 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.