Script path

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  11 November 2011
Script path

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 [];
	string $path;

	tokenize $allPath "\;" $tokPath;
	string $buffer [];
	tokenize $tokPath[1] "\/" $buffer; //index 0 is default project, 1 is scripts

	for ($i = 0 ; $i < size ($buffer); $i++)
		$scriptPathArray [$i] = $buffer [$i];

	$path = stringArrayToString ($scriptPathArray, "\\\\");

	return $path;

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 November 2011
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 November 2011
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"; )

Last edited by depakeen : 11 November 2011 at 09:03 AM.
  11 November 2011
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).
  11 November 2011
Have you considered

internalVar -usd
  11 November 2011
This is just what I was looking for! Thanks a lot!!
  11 November 2011
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 04:07 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.