一半君的总结纸

听话只听一半君

#35 How do I get/set the name of the scene that’s currently loaded, the current project and the default project?

Scene Name

  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 −rename flag, but you can specify it in conjunction with the −save flag.

Note: After you perform a ‘file -rename’ Maya does not update the title of Maya’s main window to reflect the change. It only does this upon a ‘file -save’. Be careful.

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[0] + "\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

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: