一半君的总结纸

听话只听一半君

#70 How can I intercept a Save or Save As operation?

Along the evolution of a robust in-house toolset for Maya you will inevitably come across the need to perform a set of actions each time someone saves a scene from Maya. This could be to initiate a process to integrate the saved data into the production pipeline, or something simpler like generating a log file containing information about the scene.

I have found that the best way to reliably integrate this into Maya’s operation is to edit the “pv_performAction.mel” script; e.g.:

\AW\Maya3.0\scripts\others\pv_performAction.mel

Add your custom operation(s) at the necessary stage within the long series of ‘if..else’ statements.

For the “Save As” function this would be in or about Line 245 (using Maya v3.0.1), amongst:

if ($OKToSave) {
  if ($gv_operationMode == "SaveAs") {
  // ...
    evalEcho($cmd);
  // ...
    addRecentFile ($theSavedFile, $fileType);

// *** Add call to your MEL procedure here ***

  } else if ($gv_operationMode == "ExportActive") {

When modifying Maya’s own internal scripts, I recommend saving the modified versions in a different location, leaving the original intact. If your company’s workstations share a common drive mapping, create a “scripts” folder on this drive and save the new MEL here. Set the MAYA_SCRIPT_PATH for each workstation to include this mapped drive, specifying your folder earlier in the list than Maya’s default paths. Save the modified “pv_performAction.mel” into the mapped folder and it will conveniently override the default behaviour.

Caution: The “pv_performAction.mel” script typically changes with each version of Maya, so if you upgrade Maya you’ll want to move your custom functionality into the script applicable to the version you are running. Wrap your enhancements in big bold comments so they’re easy to spot.

Wednesday, August 29, 2001

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 博主赞过: