PDA

View Full Version : Accessing file relative to where MEL script is located


Bryan Y
06-20-2008, 07:43 PM
Title says it all...

I have a MEL script, and I'd like to use a relative path, like "subdir/myfile.whatever" which would be a location in the directory from where my script is located.

Maybe I did my test wrong, but at this point, I'm not sure the current working directory is where the script is located. Or is it? If not, can I get the path of where my script is located?

And MAYA_SCRIPT_PATH in Maya.env does not hold the answer in a general situation, because there can be multiple locations that scripts can reside.

Keilun
06-20-2008, 07:53 PM
You can use the whatIs command to retrieve a script's location:

eg.

whatIs "kaosFieldTest";
// Result: Script found in: /u/mayauser/maya/scripts/kaosFieldTest.mel //

From there, you can just parse the result string and run your file queries with that.

Bryan Y
06-20-2008, 08:02 PM
Thanks for the quick response!

CGTalk Moderation
06-20-2008, 08:02 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.