C++ API Reference

Base class for user commands. More...

#include <MPxCommand.h>

+ Inheritance diagram for MPxCommand:

Public Types

enum  MResultType { kLong, kDouble, kString, kNoArg }
 Types of results from commands. More...
 

Public Member Functions

 MPxCommand ()
 Constructor.
 
virtual ~MPxCommand ()
 Destructor. More...
 
virtual MStatus doIt (const MArgList &args)
 This method should perform a command by setting up internal class data and then calling the redoIt method. More...
 
virtual MStatus undoIt ()
 This method should undo the work done by the redoIt method based on the internal class data only. More...
 
virtual MStatus redoIt ()
 This method should do the actual work of the command based on the internal class data only. More...
 
virtual bool isUndoable () const
 This method is used to specify whether or not the command is undoable. More...
 
virtual bool hasSyntax () const
 This method specifies whether or not the command has a syntax object. More...
 
MSyntax syntax () const
 This method is intended to be used in an MArgDataBase or MArgParser contructor when the plugin command's syntax is being initialized. More...
 
bool isHistoryOn () const
 Returns whether history is on. More...
 
MString commandString () const
 This method returns the command string that is associated with this command. More...
 
MStatus setHistoryOn (bool state)
 This method specifies if history for this command is on. More...
 
MStatus setCommandString (const MString &)
 Sets the command string that is associated with this command object. More...
 
MStatus setUndoable (bool state)
 This method is obsolete. More...
 

Static Public Member Functions

static void displayInfo (const MString &theInfo)
 This method is used to display information in the script editor. More...
 
static void displayWarning (const MString &theWarning, bool showLineNumber=false)
 This method is used to display a warning in the script editor. More...
 
static void displayError (const MString &theError, bool showLineNumber=false)
 This method is used to display an error in the script editor. More...
 
static void clearResult ()
 Initializes the place where results from Maya commands get stored.
 
static void setResult (unsigned int val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (int val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (double val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (bool val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (const char *val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (const MString &val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (const MIntArray &val)
 This method puts the given values into the return value area for a command. More...
 
static void setResult (const MDoubleArray &val)
 This method puts the given values into the return value area for a command. More...
 
static void setResult (const MStringArray &val)
 This method puts the given values into the return value area for a command. More...
 
static void appendToResult (int val)
 This method will add the given value to the end of the result array of integers. More...
 
static void appendToResult (double val)
 This method will add the given value to the end of the result array of doubles. More...
 
static void appendToResult (bool val)
 This method will add the given value to the end of the result array of integers. More...
 
static void appendToResult (const char *val)
 This method will add the given value to the end of the result array of strings. More...
 
static void appendToResult (const MString &val)
 This method will add the given value to the end of the result array of strings. More...
 
static void appendToResult (const MStringArray &val)
 This method will add the given value to the end of the result array of strings. More...
 
static bool isCurrentResultArray ()
 This method will return whether the return result for the command is an array or not. More...
 
static MResultType currentResultType ()
 This method will return the type of the current result for the command. More...
 
static MStatus getCurrentResult (int &val)
 This method is not available in Python. More...
 
static MStatus getCurrentResult (double &val)
 This method is not available in Python. More...
 
static MStatus getCurrentResult (MString &val)
 This method is not available in Python. More...
 
static MStatus getCurrentResult (MIntArray &val)
 This method gets the current node's result as an array of integers, if possible. More...
 
static MStatus getCurrentResult (MDoubleArray &val)
 This method gets the current node's result as an array of doubles, if possible. More...
 
static MStatus getCurrentResult (MStringArray &val)
 This method gets the current node's result as an array of strings, if possible. More...
 
static int currentIntResult (MStatus *ReturnStatus=NULL)
 This method gets the current node's result as a int, if possible. More...
 
static double currentDoubleResult (MStatus *ReturnStatus=NULL)
 This method gets the current node's result as a double, if possible. More...
 
static MString currentStringResult (MStatus *ReturnStatus=NULL)
 This method gets the current node's result as a MString, if possible. More...
 
static const char * className ()
 Returns the name of this class. More...
 

Detailed Description

Base class for user commands.

This is the proxy class for creating MEL commands through the API.

Each command is derived from this one, and must have a doIt method, and optionally undoIt, and redoIt methods.

The doIt method should collect whatever information is required to do the task, and store it in local class data. It should finally call redoIt to make the command happen. The redoIt method should do the actual work, using only the local class data. The undoIt method should undo the actual work, again using only the local class data.

Maya contains support for infinite levels of undo. If a command written in a plug-in changes the state of anything in Maya, it should implement undoIt and redoIt methods. As well, if the doIt method returns successfully, Maya will call the method's isUndoable method immediately afterwards. If that method returns true, the instance of this class is retained and passed to Maya's undo manager so that the undoIt and redoIt methods can be called when appropriate. If isUndoable returns false, the command instance is destroyed right away.

So, for example, if a command supports both query and edit modes, in query mode the command should set a flag so that the isUndoable method returns false to prevent that command instance from being retained by the undo manager. In edit mode, where the state of Maya is changed, isUndoable should return true to enable undo and redo.

Examples:
AbcBullet/AbcBullet.h, AbcExport/AbcExport.h, AbcImport/AbcImport.h, animInfoCmd/animInfoCmd.cpp, autoLoader/moduleLogicCmd.h, blast2Cmd/blast2Cmd.cpp, blindComplexDataCmd/blindComplexDataCmd.cpp, blindDoubleDataCmd/blindDoubleDataCmd.cpp, blindShortDataCmd/blindShortDataCmd.cpp, cameraMessageCmd/cameraMessageCmd.cpp, cameraSetSubclass/testExCameraSetCmd.h, captureViewRenderCmd/captureViewRenderCmd.cpp, cgFx/cgfxShaderCmd.h, cleanPerFaceAssignment/cleanPerFaceAssignmentCmd.h, closestPointCmd/closestPointCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.h, closestPointOnNurbsSurfaceCmd/closestPointOnNurbsSurfaceCmd.h, clusterWeightFunction/clusterWeightFunction.cpp, conditionTest/conditionTest.cpp, convertBumpCmd/convertBumpCmd.cpp, convertEdgesToFacesCmd/convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd/convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd/convertVerticesToFacesCmd.cpp, createClipCmd/createClipCmd.cpp, cvPosCmd/cvPosCmd.cpp, dagMessageCmd/dagMessageCmd.cpp, dagPoseInfoCmd/dagPoseInfoCmd.cpp, deletedMsgCmd/deletedMsgCmd.cpp, dx11Shader/dx11ShaderCmd.h, eventTest/eventTest.cpp, exportJointClusterDataCmd/exportJointClusterDataCmd.cpp, exportSkinClusterDataCmd/exportSkinClusterDataCmd.cpp, fileIOMsgCmd/fileIOMsgCmd.cpp, filteredAsciiFile/filteredAsciiFile.cpp, fluidInfoCmd/fluidInfoCmd.cpp, fragmentDumper/fragmentDumper.cpp, geometryCacheConverter/geometryCacheConverter.cpp, glslShader/GLSLShaderCmd.h, gpuCache/gpuCacheCmd.h, helix2Cmd/helix2Cmd.cpp, helixQtCmd.h, hlslShader/hlslShader.h, hwApiTextureTest/hwApiTextureTest.cpp, iffInfoCmd/iffInfoCmd.cpp, iffPixelCmd/iffPixelCmd.cpp, iffPpmCmd/iffPpmCmd.cpp, ik2Bsolver/ik2Bsolver.cpp, instanceCallbackCmd/instanceCallbackCmd.cpp, intersectCmd/intersectCmd.cpp, intersectOnNurbsSurfaceCmd/intersectOnNurbsSurfaceCmd.h, latticeNoise/latticeNoise.h, lensDistortionCallback/lensDistortionCallback.h, lockEvent/lockEvent.cpp, meshOpCmd/polyModifierCmd.h, MetadataSample/createMetadataCmd.h, MetadataSample/metadataBase.h, motionPathCmd/motionPathCmd.cpp, motionTraceCmd/motionTraceCmd.cpp, moveCurveCVsCmd/moveCurveCVsCmd.cpp, multiPlugInfoCmd/multiPlugInfoCmd.cpp, nodeCreatedCBCmd/nodeCreatedCBCmd.h, nodeIconCmd/nodeIconCmd.cpp, nodeInfoCmd/nodeInfoCmd.cpp, nodeMessageCmd/nodeMessageCmd.cpp, paintCallback/paintCallback.cpp, particlePathsCmd/particlePathsCmd.cpp, particleSystemInfoCmd/particleSystemInfoCmd.cpp, peltOverlapCmd/peltOverlapCmd.cpp, pfxInfoCmd/pfxInfoCmd.cpp, pickCmd/pickCmd.cpp, pointOnMeshInfo/pointOnMeshCmd.h, polyMessageCmd/polyMessageCmd.cpp, polyPrimitiveCmd/polyPrimitiveCmd.cpp, progressWindowCmd/progressWindowCmd.cpp, qtForms.h, referenceQueryCmd/referenceQueryCmd.cpp, renderViewInteractiveRenderCmd/renderViewInteractiveRenderCmd.cpp, renderViewRenderCmd/renderViewRenderCmd.cpp, renderViewRenderRegionCmd/renderViewRenderRegionCmd.cpp, sampleCmd/sampleCmd.cpp, sampleParticles/sampleParticles.cpp, saveSwatchesCmd.h, scanDagCmd/scanDagCmd.cpp, scanDagSyntax/scanDagSyntax.cpp, sceneAssembly/adskRepresentationCmd.h, sceneAssembly/adskSceneMetadataCmd.h, skinClusterWeights/skinClusterWeights.cpp, spiralAnimCurveCmd/spiralAnimCurveCmd.cpp, splitUVCmd/polyModifierCmd.h, surfaceCreateCmd/surfaceCreateCmd.cpp, surfaceTwistCmd/surfaceTwistCmd.cpp, testCameraSetCmd/testCameraSetCmd.cpp, translateCmd/translateCmd.cpp, undoRedoMsgCmd/undoRedoMsgCmd.cpp, userMsgCmd/userMsgCmd.cpp, viewCallbackTest/viewCallbackTest.cpp, viewMRenderOverride/viewMRenderOverride.cpp, viewRenderOverrideFrameCache/viewRenderOverrideFrameCacheMain.cpp, viewRenderOverridePostColor/viewRenderOverridePostColorCmd.h, workspaceControlCmd.h, and zoomCameraCmd/zoomCameraCmd.cpp.

Member Enumeration Documentation

Types of results from commands.

Enumerator
kLong 

 

kDouble 

 

kString 

 

kNoArg 

 

Constructor & Destructor Documentation

~MPxCommand ( )
virtual

Destructor.

Local class data should be freed here.

Member Function Documentation

MStatus doIt ( const MArgList args)
virtual

This method should perform a command by setting up internal class data and then calling the redoIt method.

The actual action performed by the command should be done in the redoIt method. This is a pure virtual method, and must be overridden in derived classes.

Parameters
[in]argsList of arguments passed to the command.
Returns
Status code
Status Codes:
  • MS::kSuccess The command was successful
  • MS::kFailure An error occured during the command

Reimplemented in MTemplateCreateNodeCommand< CommandClass, CommandName, NodeName >, MTemplateAction< ActionClass, CommandName, CommandSyntax >, MTemplateAction< CommandClass, CommandName, CommandSyntax >, MPxConstraintCommand, MPxPolyTweakUVInteractiveCommand, and MPxToolCommand.

Examples:
AbcBullet/AbcBullet.h, AbcExport/AbcExport.h, AbcImport/AbcImport.h, animInfoCmd/animInfoCmd.cpp, autoLoader/moduleLogicCmd.h, blast2Cmd/blast2Cmd.cpp, blindComplexDataCmd/blindComplexDataCmd.cpp, blindDoubleDataCmd/blindDoubleDataCmd.cpp, blindShortDataCmd/blindShortDataCmd.cpp, cameraMessageCmd/cameraMessageCmd.cpp, cameraSetSubclass/testExCameraSetCmd.h, captureViewRenderCmd/captureViewRenderCmd.cpp, cgFx/cgfxShaderCmd.h, cleanPerFaceAssignment/cleanPerFaceAssignmentCmd.h, closestPointCmd/closestPointCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.h, closestPointOnNurbsSurfaceCmd/closestPointOnNurbsSurfaceCmd.h, clusterWeightFunction/clusterWeightFunction.cpp, conditionTest/conditionTest.cpp, convertBumpCmd/convertBumpCmd.cpp, convertEdgesToFacesCmd/convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd/convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd/convertVerticesToFacesCmd.cpp, createClipCmd/createClipCmd.cpp, cvPosCmd/cvPosCmd.cpp, dagMessageCmd/dagMessageCmd.cpp, dagPoseInfoCmd/dagPoseInfoCmd.cpp, deletedMsgCmd/deletedMsgCmd.cpp, dx11Shader/dx11ShaderCmd.h, eventTest/eventTest.cpp, exportJointClusterDataCmd/exportJointClusterDataCmd.cpp, exportSkinClusterDataCmd/exportSkinClusterDataCmd.cpp, fileIOMsgCmd/fileIOMsgCmd.cpp, filteredAsciiFile/filteredAsciiFile.cpp, fluidInfoCmd/fluidInfoCmd.cpp, fragmentDumper/fragmentDumper.cpp, geometryCacheConverter/geometryCacheConverter.cpp, glslShader/GLSLShaderCmd.h, helix2Cmd/helix2Cmd.cpp, helixQtCmd.h, hlslShader/hlslShader.h, hwApiTextureTest/hwApiTextureTest.cpp, iffInfoCmd/iffInfoCmd.cpp, iffPixelCmd/iffPixelCmd.cpp, iffPpmCmd/iffPpmCmd.cpp, ik2Bsolver/ik2Bsolver.cpp, instanceCallbackCmd/instanceCallbackCmd.cpp, intersectCmd/intersectCmd.cpp, intersectOnNurbsSurfaceCmd/intersectOnNurbsSurfaceCmd.h, latticeNoise/latticeNoise.h, lensDistortionCallback/lensDistortionCallback.h, lockEvent/lockEvent.cpp, MetadataSample/createMetadataCmd.h, MetadataSample/metadataBase.h, motionPathCmd/motionPathCmd.cpp, motionTraceCmd/motionTraceCmd.cpp, moveCurveCVsCmd/moveCurveCVsCmd.cpp, multiPlugInfoCmd/multiPlugInfoCmd.cpp, nodeCreatedCBCmd/nodeCreatedCBCmd.h, nodeIconCmd/nodeIconCmd.cpp, nodeInfoCmd/nodeInfoCmd.cpp, nodeMessageCmd/nodeMessageCmd.cpp, paintCallback/paintCallback.cpp, particlePathsCmd/particlePathsCmd.cpp, particleSystemInfoCmd/particleSystemInfoCmd.cpp, peltOverlapCmd/peltOverlapCmd.cpp, pfxInfoCmd/pfxInfoCmd.cpp, pickCmd/pickCmd.cpp, pointOnMeshInfo/pointOnMeshCmd.h, polyMessageCmd/polyMessageCmd.cpp, polyPrimitiveCmd/polyPrimitiveCmd.cpp, progressWindowCmd/progressWindowCmd.cpp, qtForms.h, referenceQueryCmd/referenceQueryCmd.cpp, renderViewInteractiveRenderCmd/renderViewInteractiveRenderCmd.cpp, renderViewRenderCmd/renderViewRenderCmd.cpp, renderViewRenderRegionCmd/renderViewRenderRegionCmd.cpp, sampleCmd/sampleCmd.cpp, sampleParticles/sampleParticles.cpp, saveSwatchesCmd.h, scanDagCmd/scanDagCmd.cpp, scanDagSyntax/scanDagSyntax.cpp, sceneAssembly/adskRepresentationCmd.h, sceneAssembly/adskSceneMetadataCmd.h, skinClusterWeights/skinClusterWeights.cpp, spiralAnimCurveCmd/spiralAnimCurveCmd.cpp, surfaceCreateCmd/surfaceCreateCmd.cpp, surfaceTwistCmd/surfaceTwistCmd.cpp, testCameraSetCmd/testCameraSetCmd.cpp, translateCmd/translateCmd.cpp, undoRedoMsgCmd/undoRedoMsgCmd.cpp, userMsgCmd/userMsgCmd.cpp, viewCallbackTest/viewCallbackTest.cpp, viewMRenderOverride/viewMRenderOverride.cpp, viewRenderOverrideFrameCache/viewRenderOverrideFrameCacheMain.cpp, viewRenderOverridePostColor/viewRenderOverridePostColorCmd.h, workspaceControlCmd.h, and zoomCameraCmd/zoomCameraCmd.cpp.
MStatus undoIt ( )
virtual

This method should undo the work done by the redoIt method based on the internal class data only.

Returns
Status code
Status Codes:
  • MS::kSuccess The undo was successful
  • MS::kFailure This method is not undoable

Reimplemented in MTemplateCreateNodeCommand< CommandClass, CommandName, NodeName >, and MPxConstraintCommand.

Examples:
blindComplexDataCmd/blindComplexDataCmd.cpp, blindDoubleDataCmd/blindDoubleDataCmd.cpp, cgFx/cgfxShaderCmd.h, closestPointCmd/closestPointCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.h, closestPointOnNurbsSurfaceCmd/closestPointOnNurbsSurfaceCmd.h, convertEdgesToFacesCmd/convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd/convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd/convertVerticesToFacesCmd.cpp, createClipCmd/createClipCmd.cpp, cvPosCmd/cvPosCmd.cpp, dagPoseInfoCmd/dagPoseInfoCmd.cpp, exportJointClusterDataCmd/exportJointClusterDataCmd.cpp, exportSkinClusterDataCmd/exportSkinClusterDataCmd.cpp, helix2Cmd/helix2Cmd.cpp, helixTool/helixTool.cpp, iffInfoCmd/iffInfoCmd.cpp, iffPixelCmd/iffPixelCmd.cpp, iffPpmCmd/iffPpmCmd.cpp, intersectCmd/intersectCmd.cpp, intersectOnNurbsSurfaceCmd/intersectOnNurbsSurfaceCmd.h, listRichSelectionCmd/listRichSelectionCmd.cpp, manipOverride/manipOverride.cpp, MetadataSample/createMetadataCmd.h, MetadataSample/metadataBase.h, moveNumericTool/moveNumericTool.cpp, moveTool/moveTool.cpp, pointOnMeshInfo/pointOnMeshCmd.h, polyPrimitiveCmd/polyPrimitiveCmd.cpp, richMoveCmd/richMoveCmd.cpp, skinClusterWeights/skinClusterWeights.cpp, template/zoomCameraTemplate/zoomCameraTemplate.cpp, and zoomCameraCmd/zoomCameraCmd.cpp.
MStatus redoIt ( )
virtual

This method should do the actual work of the command based on the internal class data only.

Internal class data should be set in the doIt method.

Returns
Status code
Status Codes:
  • MS::kSuccess The redo was successful
  • MS::kFailure An error occured during the redo

Reimplemented in MTemplateCreateNodeCommand< CommandClass, CommandName, NodeName >, and MPxConstraintCommand.

Examples:
blindComplexDataCmd/blindComplexDataCmd.cpp, blindDoubleDataCmd/blindDoubleDataCmd.cpp, blindShortDataCmd/blindShortDataCmd.cpp, cgFx/cgfxShaderCmd.h, closestPointOnCurve/closestPointOnCurveCmd.h, convertEdgesToFacesCmd/convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd/convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd/convertVerticesToFacesCmd.cpp, createClipCmd/createClipCmd.cpp, cvPosCmd/cvPosCmd.cpp, dagPoseInfoCmd/dagPoseInfoCmd.cpp, exportJointClusterDataCmd/exportJointClusterDataCmd.cpp, exportSkinClusterDataCmd/exportSkinClusterDataCmd.cpp, helix2Cmd/helix2Cmd.cpp, helixTool/helixTool.cpp, iffInfoCmd/iffInfoCmd.cpp, iffPixelCmd/iffPixelCmd.cpp, iffPpmCmd/iffPpmCmd.cpp, listRichSelectionCmd/listRichSelectionCmd.cpp, manipOverride/manipOverride.cpp, MetadataSample/createMetadataCmd.h, MetadataSample/metadataBase.h, motionTraceCmd/motionTraceCmd.cpp, moveNumericTool/moveNumericTool.cpp, moveTool/moveTool.cpp, pointOnMeshInfo/pointOnMeshCmd.h, polyPrimitiveCmd/polyPrimitiveCmd.cpp, richMoveCmd/richMoveCmd.cpp, skinClusterWeights/skinClusterWeights.cpp, template/zoomCameraTemplate/zoomCameraTemplate.cpp, and zoomCameraCmd/zoomCameraCmd.cpp.
bool isUndoable ( ) const
virtual

This method is used to specify whether or not the command is undoable.

In the base class, it always returns false. If you are writing a command that might be eligible for undo, you should override this method.

After Maya executes the command's doIt method, it will call isUndoable. If isUndoable returns true, Maya will retain the instance of the class and pass it to Maya's undo manager so that the undoIt and redoIt methods can be called when appropriate. If isUndoable returns false, the command instance will be immediately destroyed.

So, for example, if a command supports both query and edit modes, in query mode the command should set a flag so that the isUndoable method returns false to prevent that command instance from being retained by the undo manager. In edit mode, where the state of Maya is changed, isUndoable should return true to enable undo and redo.

Returns
  • true This command is undoable
  • false This command is not undoable (default)

Reimplemented in MTemplateCommand< CommandClass, CommandName, CommandSyntax >, MTemplateCommand< CommandClass, CommandName, MTemplateCreateNodeCommand_newSyntax >, and MPxPolyTweakUVInteractiveCommand.

Examples:
autoLoader/moduleLogicCmd.h, blindComplexDataCmd/blindComplexDataCmd.cpp, blindDoubleDataCmd/blindDoubleDataCmd.cpp, cgFx/cgfxShaderCmd.h, closestPointCmd/closestPointCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.h, closestPointOnNurbsSurfaceCmd/closestPointOnNurbsSurfaceCmd.h, convertBumpCmd/convertBumpCmd.cpp, convertEdgesToFacesCmd/convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd/convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd/convertVerticesToFacesCmd.cpp, createClipCmd/createClipCmd.cpp, cvPosCmd/cvPosCmd.cpp, dagPoseInfoCmd/dagPoseInfoCmd.cpp, dx11Shader/dx11ShaderCmd.h, exportJointClusterDataCmd/exportJointClusterDataCmd.cpp, exportSkinClusterDataCmd/exportSkinClusterDataCmd.cpp, glslShader/GLSLShaderCmd.h, helix2Cmd/helix2Cmd.cpp, helixTool/helixTool.cpp, hlslShader/hlslShader.h, iffInfoCmd/iffInfoCmd.cpp, iffPixelCmd/iffPixelCmd.cpp, iffPpmCmd/iffPpmCmd.cpp, intersectCmd/intersectCmd.cpp, intersectOnNurbsSurfaceCmd/intersectOnNurbsSurfaceCmd.h, listRichSelectionCmd/listRichSelectionCmd.cpp, manipOverride/manipOverride.cpp, MetadataSample/createMetadataCmd.h, MetadataSample/metadataBase.h, moveNumericTool/moveNumericTool.cpp, moveTool/moveTool.cpp, pointOnMeshInfo/pointOnMeshCmd.h, polyPrimitiveCmd/polyPrimitiveCmd.cpp, referenceQueryCmd/referenceQueryCmd.cpp, richMoveCmd/richMoveCmd.cpp, skinClusterWeights/skinClusterWeights.cpp, and zoomCameraCmd/zoomCameraCmd.cpp.
bool hasSyntax ( ) const
virtual

This method specifies whether or not the command has a syntax object.

Returns
Boolean value: true if this command uses syntax objects, false otherwise.
Examples:
geometryCacheConverter/geometryCacheConverter.cpp, MetadataSample/metadataBase.h, multiPlugInfoCmd/multiPlugInfoCmd.cpp, nodeIconCmd/nodeIconCmd.cpp, and workspaceControlCmd.h.
MSyntax syntax ( ) const

This method is intended to be used in an MArgDataBase or MArgParser contructor when the plugin command's syntax is being initialized.

The user should declare and define a syntax contstructing method that must be registered with Maya by passing the function pointer as a parameter in MFnPlugin::registerCommand(). The result is that when MPxCommand::syntax() is called it returns the syntax object that the user has created in the custom syntax constructing method that was registered. To avoid conflicts it is important that the user's custom syntax defining method be given a name other than "syntax." It can have any other name as long as it corresponds with the function pointer used to register the method with Maya.

Returns
The syntax object
Examples:
captureViewRenderCmd/captureViewRenderCmd.cpp.
bool isHistoryOn ( ) const

Returns whether history is on.

Returns
Boolean value: true if history is on, false otherwise.
MString commandString ( ) const

This method returns the command string that is associated with this command.

Returns
The command string for this command object
MStatus setHistoryOn ( bool  state)

This method specifies if history for this command is on.

Parameters
[in]statetrue if history is to be on , false otherwise
Returns
Status code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::kFailure Object error
MStatus setCommandString ( const MString name)

Sets the command string that is associated with this command object.

Parameters
[in]nameThe command name to be set
Returns
Status code
Status Codes:
  • MS::kSuccess The command string was set
  • MS::kFailure Object error
void displayInfo ( const MString theInfo)
static

This method is used to display information in the script editor.

Parameters
[in]theInfoThe string to be displayed
Examples:
template/helloTemplateWorld/helloTemplateWorld.cpp.
void displayWarning ( const MString theWarning,
bool  showLineNumber = false 
)
static

This method is used to display a warning in the script editor.

NOTE: Displaying of line numbers must be enabled in the MEL editor window before the showLineNumber parameter has an affect.

Parameters
[in]theWarningThe warning string to be displayed
[in]showLineNumberSet to true if you want the line number of this command to be displayed. See NOTE above.
void displayError ( const MString theError,
bool  showLineNumber = false 
)
static

This method is used to display an error in the script editor.

NOTE: Displaying of line numbers must be enabled in the MEL editor window before the showLineNumber parameter has an affect.

Parameters
[in]theErrorThe error string to be displayed
[in]showLineNumberSet to true if you want the line number of this command to be displayed See NOTE above.
Examples:
fragmentDumper/fragmentDumper.cpp, and gpuCache/gpuCacheCmd.cpp.
void setResult ( unsigned int  val)
static

This method puts the given value into the return value area for a command.

The value is cast to an int internally because the Maya command engine does not support unsigned ints.

Parameters
[in]valThe value to be set
Examples:
AbcImport/AbcImport.cpp, convertEdgesToFacesCmd/convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd/convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd/convertVerticesToFacesCmd.cpp, cvExpandCmd/cvExpandCmd.cpp, fragmentDumper/fragmentDumper.cpp, gpuCache/gpuCacheCmd.cpp, and viewRenderOverridePostColor/viewRenderOverridePostColorCmd.cpp.
void setResult ( int  val)
static

This method puts the given value into the return value area for a command.

Parameters
[in]valThe value to be set
void setResult ( double  val)
static

This method puts the given value into the return value area for a command.

Parameters
[in]valThe value to be set
void setResult ( bool  val)
static

This method puts the given value into the return value area for a command.

Parameters
[in]valThe value to be set
void setResult ( const char *  val)
static

This method puts the given value into the return value area for a command.

Parameters
[in]valThe value to be set
void setResult ( const MString val)
static

This method puts the given value into the return value area for a command.

Parameters
[in]valThe value to be set
void setResult ( const MIntArray val)
static

This method puts the given values into the return value area for a command.

Parameters
[in]valThe value to be set
void setResult ( const MDoubleArray val)
static

This method puts the given values into the return value area for a command.

Parameters
[in]valThe value to be set
void setResult ( const MStringArray val)
static

This method puts the given values into the return value area for a command.

Parameters
[in]valThe value to be set
void appendToResult ( int  val)
static

This method will add the given value to the end of the result array of integers.

The result array can only be of a single type so this method can only be used when the result string has not been set or is already of integer type.

Note: appendToResult cannot be used in conjunction with setResult.

Parameters
[in]valThe value to be added
Examples:
nodeIconCmd/nodeIconCmd.cpp.
void appendToResult ( double  val)
static

This method will add the given value to the end of the result array of doubles.

The result array can only be of a single type so this method can only be used when the result string has not been set or is already of type double.

Note: appendToResult cannot be used in conjunction with setResult.

Parameters
[in]valThe value to be added
void appendToResult ( bool  val)
static

This method will add the given value to the end of the result array of integers.

The result array can only be of a single type so this method can only be used when the result string has not been set or is already of integer type.

Note: appendToResult cannot be used in conjunction with setResult.

Parameters
[in]valThe value to be added
void appendToResult ( const char *  val)
static

This method will add the given value to the end of the result array of strings.

The result array can only be of a single type so this method can only be used when the result string has not been set or is already of type string.

Note: appendToResult cannot be used in conjunction with setResult.

Parameters
[in]valThe value to be added
void appendToResult ( const MString val)
static

This method will add the given value to the end of the result array of strings.

The result array can only be of a single type so this method can only be used when the result string has not been set or is already of type string.

Note: appendToResult cannot be used in conjunction with setResult.

Parameters
[in]valThe value to be added
void appendToResult ( const MStringArray val)
static

This method will add the given value to the end of the result array of strings.

The result array can only be of a single type so this method can only be used when the result string has not been set or is already of type string.

Note: appendToResult cannot be used in conjunction with setResult.

Parameters
[in]valThe value to be added
bool isCurrentResultArray ( )
static

This method will return whether the return result for the command is an array or not.

Returns
  • true The command result is an array
  • false The command result is not an array
MPxCommand::MResultType currentResultType ( )
static

This method will return the type of the current result for the command.

ReturnValue

  • The result type
MStatus getCurrentResult ( int &  val)
static

This method is not available in Python.

This method gets the current node's result as a int, if possible.

Python Notes

This method is not supported in Python. Please see currentIntResult()

Parameters
[in]valStorage for the return value
Returns
Status code
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to int
MStatus getCurrentResult ( double &  val)
static

This method is not available in Python.

This method gets the current node's result as a double, if possible.

Python Notes

This method is not supported in Python. Please see currentDoubleResult()

Parameters
[in]valStorage for the return value
Returns
Status code
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to double
MStatus getCurrentResult ( MString val)
static

This method is not available in Python.

This method gets the current node's result as a string, if possible.

Python Notes

This method is not supported in Python. Please see currentStringResult()

Parameters
[in]valStorage for the return value
Returns
Status code
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to string
MStatus getCurrentResult ( MIntArray val)
static

This method gets the current node's result as an array of integers, if possible.

Parameters
[in]valStorage for the return value
Returns
Status code
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to integer array
MStatus getCurrentResult ( MDoubleArray val)
static

This method gets the current node's result as an array of doubles, if possible.

Parameters
[in]valStorage for the return value
Returns
Status code
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to double array
MStatus getCurrentResult ( MStringArray val)
static

This method gets the current node's result as an array of strings, if possible.

Parameters
[in]valStorage for the return value
Returns
Status code
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to string array
int currentIntResult ( MStatus ReturnStatus = NULL)
static

This method gets the current node's result as a int, if possible.

Parameters
[out]ReturnStatusOptional status code. See below.
Returns
The int result.
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to int
double currentDoubleResult ( MStatus ReturnStatus = NULL)
static

This method gets the current node's result as a double, if possible.

Parameters
[out]ReturnStatusOptional status code. See below.
Returns
The double result.
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to double
MString currentStringResult ( MStatus ReturnStatus = NULL)
static

This method gets the current node's result as a MString, if possible.

Parameters
[out]ReturnStatusOptional status code. See below.
Returns
The string result.
Status Codes:
  • MS:kSuccess A value was returned
  • MS:kFailure Cannot convert result to string
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.
MStatus setUndoable ( bool  state)

This method is obsolete.

[as of Maya 2019]

Deprecated:
This method has no effect any more on the undoability of a command.
Parameters
[in]state

The documentation for this class was generated from the following files: