TEMERITY

us.temerity.pipeline.plugin
Class MayaActionUtils

java.lang.Object
  extended by us.temerity.pipeline.Named
      extended by us.temerity.pipeline.PluginID
          extended by us.temerity.pipeline.BasePlugin
              extended by us.temerity.pipeline.BaseAction
                  extended by us.temerity.pipeline.plugin.CommonActionUtils
                      extended by us.temerity.pipeline.plugin.PythonActionUtils
                          extended by us.temerity.pipeline.plugin.MayaActionUtils
All Implemented Interfaces:
Serializable, Cloneable, Comparable<PluginID>, Glueable
Direct Known Subclasses:
EmptyFBXAction, FBXToCurvesAction, MayaAnimBuildAction, MayaBuildAction, MayaBuildAction, MayaBuildUtils, MayaCurvesExportAction, MayaCurvesExportAction, MayaCurvesExportAction, MayaCurvesExportAction, MayaDLRenderAction, MayaDLShaderExportAction, MayaExportAction, MayaExportAction, MayaFTNBuildAction, MayaFTNBuildAction, MayaFTNBuildAction, MayaIgesExportAction, MayaMakeGeoCacheAction, MayaMelAction, MayaMiExportAction, MayaMiShaderAction, MayaMiShaderAction, MayaMiShaderAction, MayaMRayRenderAction, MayaObjExportAction, MayaRenderAction, MayaRenderAction, MayaRenderAction, MayaRenderAction, MayaRenderAction, MayaRenderAction, MayaReplaceRefAction, MayaShaderExportAction, MayaShaderExportAction

public class MayaActionUtils
extends PythonActionUtils

Superclass of Action plugins which interact with Maya scenes.

This class provides convenience methods which make it easier to write Action plugins which create dynamic MEL scripts and Maya scenes.

See Also:
Serialized Form

Field Summary
static String aAngularUnits
           
static String aAnimMEL
           
static String aFinalMEL
           
static String aInitialMEL
           
static String aLinearUnits
           
static String aMayaScene
           
static String aModelMEL
           
static String aTimeUnits
           
 
Fields inherited from class us.temerity.pipeline.plugin.CommonActionUtils
aExtraOptions
 
Fields inherited from class us.temerity.pipeline.BasePlugin
pDescription
 
Fields inherited from class us.temerity.pipeline.PluginID
pVendor, pVersionID
 
Fields inherited from class us.temerity.pipeline.Named
pName
 
Constructor Summary
protected MayaActionUtils(String name, VersionID vid, String vendor, String desc)
          Construct with the given name, version, vendor and description.
 
Method Summary
protected  void addAnimMELParam()
          Adds an Anim MEL parameter to the action.
protected  void addFinalMELParam()
          Adds an Final MEL parameter to the action.
protected  void addInitalMELParam()
          Adds an Initial MEL parameter to the action.
protected  void addMayaSceneParam()
          Adds an Maya Scene parameter to the action.
protected  void addModelMELParam()
          Adds an Model MEL parameter to the action.
protected  void addUnitsParams()
          Adds Maya units parameters to the action.
protected  void addUnitsParamsToLayout(LayoutGroup layout)
          Add the parameters created by the addUnitsParams method to the given parameter layout group.
static String createMayaCommand(Path scene, File script)
          A convienence method for creating a command-line string equivalent of createMayaSubProcess suitable for inclusion in an executable script.
static String createMayaPythonLauncher(Path scene, File script)
          A convienence method for creating the Python code equivalent of createMayaSubProcess suitable for inclusion in an temporary Python script.
static String createMayaPythonLauncher(Path scene, Path script)
          A convienence method for creating the Python code equivalent of createMayaSubProcess suitable for inclusion in an temporary Python script.
 SubProcessHeavy createMayaSubProcess(Path scene, File script, boolean customShaders, ActionAgenda agenda, File outFile, File errFile)
          A convienence method for creating the SubProcessHeavy instance to be returned by the prep method for Maya scene manipulation Actions.
protected  String genUnitsMEL()
          Generate a MEL snippet which specifies the Linear, Angular and Time units for the Maya scene based on the parameters created by the addUnitsParams method.
 Path getMayaSceneSourcePath(String pname, ActionAgenda agenda)
          Get the abstract path to the single primary Maya scene file associated with a source node specified by the given parameter.
 Path getMayaSceneTargetPath(ActionAgenda agenda)
          Get the abstract path to the single primary Maya scene associated with the target node.
 String getMayaSceneType(ActionAgenda agenda)
          Get the MEL string representation of the file type of the primary Maya scene associated with the target node.
 Path getMelScriptSourcePath(String pname, ActionAgenda agenda)
          Get the abstract path to the single primary MEL script associated with a source node specified by the given parameter.
protected  String getMelSnippet(ActionAgenda agenda, String param)
          Extracts a MEL script from a file and returns it as a String.
static Map<String,String> getMiCustomShaderEnv(ActionAgenda agenda)
          Get the Toolset environment modified to include a custom mental ray shader path.
static Map<String,String> getMiCustomShaderEnv(NodeID nodeID, Map<String,String> env)
          Get the Toolset environment modified to include a custom mental ray shader path.
protected  void writeAnimMEL(ActionAgenda agenda, FileWriter out)
          Generates a mel snippet that source the anim MEL script.
protected  void writeFinalMEL(ActionAgenda agenda, FileWriter out)
          Generates a mel snippet that source the final MEL script.
protected  void writeInitialMEL(ActionAgenda agenda, FileWriter out)
          Generates a mel snippet that source the initial MEL script.
protected  void writeModelMEL(ActionAgenda agenda, FileWriter out)
          Generates a mel snippet that source the model MEL script.
 
Methods inherited from class us.temerity.pipeline.plugin.PythonActionUtils
createPythonSubProcess, createPythonSubProcess, createPythonSubProcess, getPythonFileVerify, getPythonFileVerify, getPythonFileVerify, getPythonFileVerify, getPythonFileVerify, getPythonFileVerify, getPythonIndent, getPythonLaunchHeader, getPythonLaunchPipeHeader, getPythonProgram, getPythonProgram
 
Methods inherited from class us.temerity.pipeline.plugin.CommonActionUtils
addExtraOptionsParam, addExtraOptionsParamToLayout, createScriptSubProcess, createSubProcess, createSubProcess, createSubProcess, createSubProcess, createTempCopySubProcess, createTempScript, escPath, escPath, getExtraOptionsArgs, getPrimarySourcePath, getPrimarySourcePath, getPrimarySourcePath, getPrimarySourcePaths, getPrimarySourcePaths, getPrimarySourcePaths, getPrimaryTargetPath, getPrimaryTargetPath, getPrimaryTargetPath, getPrimaryTargetPaths, getPrimaryTargetPaths, getPrimaryTargetPaths, getSecondarySourceBooleanParamValue, getSecondarySourceDoubleParamValue, getSecondarySourceDoubleParamValue, getSecondarySourceEnumParamIndex, getSecondarySourceIntegerParamValue, getSecondarySourceIntegerParamValue, getSecondarySourceLongParamValue, getSecondarySourceLongParamValue, getSecondarySourceOptionalBooleanParamValue, getSecondarySourceStringParamValue, getSecondarySourceStringParamValue, getSingleBooleanParamValue, getSingleDoubleParamValue, getSingleDoubleParamValue, getSingleEnumParamIndex, getSingleIntegerParamValue, getSingleIntegerParamValue, getSingleLongParamValue, getSingleLongParamValue, getSingleOptionalBooleanParamValue, getSingleStringParamValue, getSingleStringParamValue, getSingleTuple2dParamValue, getSingleTuple2dParamValue, getSingleTuple2dParamValue, getSingleTuple2iParamValue, getSingleTuple2iParamValue, getSingleTuple2iParamValue, getSingleTuple3dParamValue, getSingleTuple3dParamValue, getSingleTuple3dParamValue, getSingleTuple3iParamValue, getSingleTuple3iParamValue, getSingleTuple3iParamValue, getSingleTuple4dParamValue, getSingleTuple4dParamValue, getSingleTuple4dParamValue, getSourceBooleanParamValue, getSourceDoubleParamValue, getSourceDoubleParamValue, getSourceEnumParamIndex, getSourceIntegerParamValue, getSourceIntegerParamValue, getSourceLongParamValue, getSourceLongParamValue, getSourceOptionalBooleanParamValue, getSourceStringParamValue, getSourceStringParamValue, getWorkingNodeFilePath, getWorkingNodeFilePath, getWorkingNodeFilePath, getWorkingNodeFilePath, getWorkingNodeFilePaths
 
Methods inherited from class us.temerity.pipeline.BaseAction
addPreset, addPresetValues, addSingleParam, chmod, cleanupLater, clearAllLinkParams, clearLinkParams, clone, createTemp, createTemp, equals, equalSingleParams, equalSourceParams, fromGlue, getInitialSourceParams, getPluginType, getPresetChoices, getPresetValues, getSecondarySequences, getSecondarySourceNames, getSecondarySourceParam, getSecondarySourceParams, getSecondarySourceParamValue, getSingleLayout, getSingleParam, getSingleParams, getSingleParamValue, getSourceLayout, getSourceNames, getSourceParam, getSourceParams, getSourceParamValue, getTempDir, getTempPath, hasSecondarySourceParams, hasSingleParams, hasSourceParams, initSecondarySourceParams, initSourceParams, prep, removeAllSourceParams, removeSecondarySourceParams, removeSecondarySourceParams, removeSourceParams, setSecondarySourceParamValue, setSingleLayout, setSingleParamValue, setSingleParamValues, setSourceLayout, setSourceParamValue, setSourceParamValues, supportsSourceParams, toGlue
 
Methods inherited from class us.temerity.pipeline.BasePlugin
addSupport, compareTo, getDescription, getFullMessage, getPluginID, getResource, getResources, getResourceSize, getSupports, isUnderDevelopment, removeSupport, setSupports, supports, toString, underDevelopment
 
Methods inherited from class us.temerity.pipeline.PluginID
getVendor, getVersionID
 
Methods inherited from class us.temerity.pipeline.Named
getName
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

aLinearUnits

public static final String aLinearUnits
See Also:
Constant Field Values

aAngularUnits

public static final String aAngularUnits
See Also:
Constant Field Values

aTimeUnits

public static final String aTimeUnits
See Also:
Constant Field Values

aInitialMEL

public static final String aInitialMEL
See Also:
Constant Field Values

aModelMEL

public static final String aModelMEL
See Also:
Constant Field Values

aAnimMEL

public static final String aAnimMEL
See Also:
Constant Field Values

aFinalMEL

public static final String aFinalMEL
See Also:
Constant Field Values

aMayaScene

public static final String aMayaScene
See Also:
Constant Field Values
Constructor Detail

MayaActionUtils

protected MayaActionUtils(String name,
                          VersionID vid,
                          String vendor,
                          String desc)
Construct with the given name, version, vendor and description.

Parameters:
name - The short name of the action.
vid - The action plugin revision number.
vendor - The name of the plugin vendor.
desc - A short description of the action.
Method Detail

addMayaSceneParam

protected void addMayaSceneParam()
Adds an Maya Scene parameter to the action.

The following single valued parameters are added:

Maya Scene
The Maya scene that the Action is going to act upon.

This method should be called in the subclass constructor before specifying parameter layouts.


addInitalMELParam

protected void addInitalMELParam()
Adds an Initial MEL parameter to the action.

The following single valued parameters are added:

Initial MEL
The source node containing the MEL script to evaluate just after scene creation and before any work is done.

This method should be called in the subclass constructor before specifying parameter layouts.


addModelMELParam

protected void addModelMELParam()
Adds an Model MEL parameter to the action.

The following single valued parameters are added:

Model MEL
The source node containing the MEL script to evaluate after importing all models.

This method should be called in the subclass constructor before specifying parameter layouts.


addAnimMELParam

protected void addAnimMELParam()
Adds an Anim MEL parameter to the action.

The following single valued parameters are added:

Anim MEL
The source node containing the MEL script to evaluate after importing the animation.

This method should be called in the subclass constructor before specifying parameter layouts.


addFinalMELParam

protected void addFinalMELParam()
Adds an Final MEL parameter to the action.

The following single valued parameters are added:

Final MEL
The source node containing the MEL script to evaluate after the scene has been saved.

This method should be called in the subclass constructor before specifying parameter layouts.


writeInitialMEL

protected void writeInitialMEL(ActionAgenda agenda,
                               FileWriter out)
                        throws PipelineException,
                               IOException
Generates a mel snippet that source the initial MEL script.

Throws:
PipelineException
IOException

writeModelMEL

protected void writeModelMEL(ActionAgenda agenda,
                             FileWriter out)
                      throws PipelineException,
                             IOException
Generates a mel snippet that source the model MEL script.

Throws:
PipelineException
IOException

writeAnimMEL

protected void writeAnimMEL(ActionAgenda agenda,
                            FileWriter out)
                     throws PipelineException,
                            IOException
Generates a mel snippet that source the anim MEL script.

Throws:
PipelineException
IOException

writeFinalMEL

protected void writeFinalMEL(ActionAgenda agenda,
                             FileWriter out)
                      throws PipelineException,
                             IOException
Generates a mel snippet that source the final MEL script.

Throws:
PipelineException
IOException

getMelSnippet

protected String getMelSnippet(ActionAgenda agenda,
                               String param)
                        throws PipelineException,
                               IOException
Extracts a MEL script from a file and returns it as a String.

Useful for including actual MEL code in a generated script rather than sourcing it. Use when the MEL code needs to have access to the same local variables as the script that is calling it. See its use in MayaExportAction for an example.

Parameters:
agenda - The action's agenda.
param - The name of the link parameter that the mel script it hooked up to.
Returns:
The contents of the file or null if the parameter does not have a value
Throws:
IOException - If there is trouble opening or reading the MEL file.
PipelineException

addUnitsParams

protected void addUnitsParams()
Adds Maya units parameters to the action.

The following single valued parameters are added:

Linear Unit
The linear unit that the generated scene will use.

Angular Unit
The angular unit that the generated scene will use.

Time Unit
The unit of time and frame rate that the generated scene will use.

This method should be called in the subclass constructor before specifying parameter layouts.


addUnitsParamsToLayout

protected void addUnitsParamsToLayout(LayoutGroup layout)
Add the parameters created by the addUnitsParams method to the given parameter layout group.


genUnitsMEL

protected String genUnitsMEL()
                      throws PipelineException
Generate a MEL snippet which specifies the Linear, Angular and Time units for the Maya scene based on the parameters created by the addUnitsParams method.

Throws:
PipelineException

getMayaSceneType

public String getMayaSceneType(ActionAgenda agenda)
                        throws PipelineException
Get the MEL string representation of the file type of the primary Maya scene associated with the target node.

The value returned by this method is suitable for use with the "-type" option of the MEL "file" command.

Parameters:
agenda - The agenda to be accomplished by the action.
Returns:
Either "mayaAscii" or "mayaBinary" depending on the primary file suffix.
Throws:
PipelineException

getMayaSceneTargetPath

public Path getMayaSceneTargetPath(ActionAgenda agenda)
                            throws PipelineException
Get the abstract path to the single primary Maya scene associated with the target node.

Parameters:
agenda - The agenda to be accomplished by the action.
Returns:
The path to the target Maya scene script.
Throws:
PipelineException

getMelScriptSourcePath

public Path getMelScriptSourcePath(String pname,
                                   ActionAgenda agenda)
                            throws PipelineException
Get the abstract path to the single primary MEL script associated with a source node specified by the given parameter.

Parameters:
pname - The name of the single valued MEL parameter.
agenda - The agenda to be accomplished by the action.
Returns:
The path to the MEL script or null if none was specified.
Throws:
PipelineException

getMayaSceneSourcePath

public Path getMayaSceneSourcePath(String pname,
                                   ActionAgenda agenda)
                            throws PipelineException
Get the abstract path to the single primary Maya scene file associated with a source node specified by the given parameter.

Parameters:
pname - The name of the single valued Maya scene parameter.
agenda - The agenda to be accomplished by the action.
Returns:
The path to the Maya scene file or null if none was specified.
Throws:
PipelineException

createMayaPythonLauncher

public static String createMayaPythonLauncher(Path scene,
                                              File script)
A convienence method for creating the Python code equivalent of createMayaSubProcess suitable for inclusion in an temporary Python script.

The returned OS level process will run Maya in batch mode to optionally load a input Maya scene and then perform some operations specified by a dynamically creatd MEL script.

The Python code generated by this method requires the "launch" method defined by PythngActionUtils.getPythonLaunchHeader. You must first include the code generate by getPythonLaunchHeader before the code generated by this method.

Parameters:
scene - The abstract path to the Maya scene to load or null to ignore.
script - The temporary MEL script file to execute.

createMayaPythonLauncher

public static String createMayaPythonLauncher(Path scene,
                                              Path script)
A convienence method for creating the Python code equivalent of createMayaSubProcess suitable for inclusion in an temporary Python script.

The returned OS level process will run Maya in batch mode to optionally load a input Maya scene and then perform some operations specified by a dynamically creatd MEL script.

The Python code generated by this method requires the "launch" method defined by PythonActionUtils.getPythonLaunchHeader. You must first include the code generate by getPythonLaunchHeaderget before the code generated by this method.

Parameters:
scene - The abstract path to the Maya scene to load or null to ignore.
script - The temporary MEL script file to execute.

getMiCustomShaderEnv

public static Map<String,String> getMiCustomShaderEnv(ActionAgenda agenda)
                                               throws PipelineException
Get the Toolset environment modified to include a custom mental ray shader path.

If the variable PIPELINE_MI_SHADER_PATH is set in the Toolset environment, then the variable MI_CUSTOM_SHADER_PATH will be added to the environment who's value is the constructed by appending the value of PIPELINE_MI_SHADER_PATH to the working area directory containing the target node's files.

Parameters:
agenda - The agenda to be accomplished by the Action.
Returns:
The modified Toolset environment.
Throws:
PipelineException

getMiCustomShaderEnv

public static Map<String,String> getMiCustomShaderEnv(NodeID nodeID,
                                                      Map<String,String> env)
Get the Toolset environment modified to include a custom mental ray shader path.

If the variable PIPELINE_MI_SHADER_PATH is set in the Toolset environment, then the variable MI_CUSTOM_SHADER_PATH will be added to the environment who's value is the constructed by appending the value of PIPELINE_MI_SHADER_PATH to the working area directory containing the target node's files.

Parameters:
nodeID - The unique working version identifier of the target node.
env - The original Toolset environment.
Returns:
The modified Toolset environment.

createMayaSubProcess

public SubProcessHeavy createMayaSubProcess(Path scene,
                                            File script,
                                            boolean customShaders,
                                            ActionAgenda agenda,
                                            File outFile,
                                            File errFile)
                                     throws PipelineException
A convienence method for creating the SubProcessHeavy instance to be returned by the prep method for Maya scene manipulation Actions.

The returned OS level process will run Maya in batch mode to optionally load a input Maya scene and then perform some operations specified by a dynamically creatd MEL script.

If the customShaders parameter is set to true and the variable PIPELINE_MI_SHADER_PATH is set in the Toolset environment, then the variable MI_CUSTOM_SHADER_PATH will be added to the environment who's value is the constructed by appending the value of PIPELINE_MI_SHADER_PATH to the working area directory containing the target node's files.

Parameters:
scene - The abstract path to the Maya scene to load or null to ignore.
script - The temporary MEL script file to execute.
customShaders - Whether to set the value of MI_CUSTOM_SHADER_PATH (see above).
agenda - The agenda to be accomplished by the Action.
outFile - The file to which all STDOUT output is redirected.
errFile - The file to which all STDERR output is redirected.
Throws:
PipelineException

createMayaCommand

public static String createMayaCommand(Path scene,
                                       File script)
A convienence method for creating a command-line string equivalent of createMayaSubProcess suitable for inclusion in an executable script.

The returned OS level process will run Maya in batch mode to optionally load a input Maya scene and then perform some operations specified by a dynamically created MEL script.

Parameters:
scene - The abstract path to the Maya scene to load or null to ignore.
script - The temporary MEL script file to execute.

TEMERITY