Script path

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 11 November 2011   #1
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.
 
Old 11 November 2011   #2
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...
:nathaN
 
Old 11 November 2011   #3
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.
 
Old 11 November 2011   #4
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).
 
Old 11 November 2011   #5
Have you considered

internalVar -usd
 
Old 11 November 2011   #6
This is just what I was looking for! Thanks a lot!!
 
Old 11 November 2011   #7
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

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


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