MEL How-To #35
How do I get/set the name of the scene that's currently loaded, the current project and the default project?
string $fileName = `file -q -sceneName`; // Result: C:/projects/default/scenes/untitled.mb //
Note: If the scene has just been cleared, querying the sceneName will return an empty string.
If you want to change the name of the scene, you can use:
file -rename "newSceneName"; // Result: C:/projects/default/scenes/newSceneName.mb //
Maya will use the current scene type (mayaBinary or mayaAscii) and the current path by default.
file -rename "C:/projects/toy_story/woody"; // Result: C:/projects/toy_story/woody.mb //
Here Maya will use the specified filepath and keep the current scene type (mayaBinary or mayaAscii). At this point Maya doesn't care if the path exists.
file -rename "C:/projects/toy_story/woody.ma"; // Result: C:/projects/toy_story/woody.mb //
If the scene type is "mayaBinary" Maya will ignore the extension and keep the name "woody.mb".
file -type "mayaAscii"; // Result: C:/projects/toy_story/woody.ma //
Maya changes the filetype.
You cannot specify the filetype in conjunction with the
Note: After you perform a ‘
Project (a.k.a. Workspace)
The current Workspace can by queried using:
string $workspace = `workspace -q -fullName`; // Result: D:/AW/projects/hulk //
If you intend to use this result as the folder for the "getFileList" command then you'll need to ensure a slash is specified as the last character. A variation which includes this trailing slash is the '-dir' flag.
string $workspace = `workspace -q -dir`; // Result: D:/AW/projects/hulk/ // getFileList -fld $workspace; // Result: scenes sourceImages workspace.mel //
The default Workspace may be determined using:
string $workspaces = `workspace -q -listFullWorkspaces`; print ( "Default workspace is: " + $workspaces + "\n" );
Note: This is a bit of assumption on my part that the default Workspace will always be the first item in this array.
15 Sep 2004
|Copyright ©2005 by Bryan Ewert, email@example.com|
Maya is a Registered Trademark of Alias