C++ API Reference

Syntax for Commands. More...

#include <MSyntax.h>

Public Types

enum  MArgType {
  kInvalidArgType, kNoArg, kBoolean, kLong,
  kDouble, kString, kUnsigned, kDistance,
  kAngle, kTime, kSelectionItem, kLastArgType
}
 Argument types. More...
 
enum  MObjectFormat {
  kInvalidObjectFormat, kNone, kStringObjects, kSelectionList,
  kLastObjectFormat
}
 Object list types. More...
 

Public Member Functions

 MSyntax ()
 The default class constructor.
 
 MSyntax (const MSyntax &other)
 The copy constructor. More...
 
virtual ~MSyntax ()
 The class destructor.
 
MSyntaxoperator= (const MSyntax &rhs)
 The assignment operator. More...
 
MStatus addFlag (const char *shortName, const char *longName, MArgType argType1=kNoArg, MArgType argType2=kNoArg, MArgType argType3=kNoArg, MArgType argType4=kNoArg, MArgType argType5=kNoArg, MArgType argType6=kNoArg)
 Adds a flag to the list of flags accepted for the given command. More...
 
MStatus makeFlagMultiUse (const char *flag)
 Specifies that the given flag can be used by the command multiple times in on the same command line. More...
 
MStatus makeFlagQueryWithFullArgs (const char *flag, bool queryArgsAreOptional)
 Specifies that the given flag will require all of its arguments in query mode. More...
 
MStatus addArg (MArgType arg)
 Specifies the type of one of the arguments to the command. More...
 
void useSelectionAsDefault (bool useSelectionList=false)
 Specifies that the command will use the current selection list as arguments to the command if the command requires objects and none are provided}. More...
 
MStatus setObjectType (MObjectFormat objectFormat, unsigned int minimumObjects=0)
 Specifies the representation of the objects passed to the command as either MObjects or MStrings. More...
 
MStatus setObjectType (MObjectFormat objectFormat, unsigned int minimumObjects, unsigned int maximumObjects)
 Specifies the representation of the objects passed to the command as either MObjects or MStrings. More...
 
void setMinObjects (unsigned int minimumObjectCount)
 Specifies the lower limit on the number of objects accepted by the command. More...
 
void setMaxObjects (unsigned int maximumObjectCount)
 Specifies the upper limit on the number of objects accepted by the command. More...
 
void enableQuery (bool supportsQuery=true)
 Sets whether or not the command supports the query flag ("-q"). More...
 
void enableEdit (bool supportsEdit=true)
 Sets whether or not the command supports the edit flag ("-e"). More...
 
unsigned int minObjects () const
 Returns the lower limit on the number of objects accepted by the command. More...
 
unsigned int maxObjects () const
 Returns the upper limit on the number of objects accepted by the command. More...
 
bool canQuery () const
 Returns whether or not the command supports the query flag ("-q"). More...
 
bool canEdit () const
 Returns whether or not the command supports the edit flag ("-e"). More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Detailed Description

Syntax for Commands.

This class is used to specify flags and arguments passed to commands. Once the syntax of the command has been defined by calls to the methods in this class, Maya will be able to automatically parse invocations of the command and reject syntactically invalid ones. When the doIt method of the command is invoked, the provided argument list can be parsed automatically into an instance of either the MArgDatabase class (for commands) or MArgParser class (for context commands) by passing the constructor for that class both the argument list and the syntax object for the command.

There are three type of arguments that can be specified via these syntax methods:

  • flags arguments preceded by a '-' character.
  • command arguments required parameters that follow the flags
  • objects an optional list of Maya objects or the contents of the selection list.

Note: command arguments and objects are incompatible and must not be combined in the syntax definition of a command. If an attempt is made to do so, neither command arguments or objects will be accessible via the MArgDatabase or MArgParser classes.

The addFlag method is used to add a flag argument to a command. Flags need to have a type specified for them from the list of available types in the MArgType enum and can take up to six parameters. Flags can be set as being allowed multiple times on the command line be calling the makeFlagMultiUse method.

The addArg method is used to add a command argument to a command. Such arguments must also have a type specified for them from the list of available types in the MArgType enum. If you specify an argument via this call, Maya will reject an invocation of the command as being syntactically invalid if an argument of the correct type is not provided. If the type kSelectionItem is provided, Maya will include the contents of the selection list as the argument to the command.

The setObjectType method is used to specify that the command requires an object list. Parameters to this method allow you to specify minimum and maximum numbers of objects. As well, if the useSelectionAsDefault method is used in conjunction with this, Maya will use the contents of the selection list as the objects for the command if none are specified.

The documentation for the MArgDatabase and MArgParser classes describe how to access the parsed information for a command inside the doIt method of that command.

Examples:
AbcBullet/AbcBullet.cpp, AbcBullet/AbcBullet.h, AbcExport/AbcExport.cpp, AbcExport/AbcExport.h, AbcImport/AbcImport.cpp, AbcImport/AbcImport.h, blast2Cmd/blast2Cmd.cpp, cameraMessageCmd/cameraMessageCmd.cpp, captureViewRenderCmd/captureViewRenderCmd.cpp, cgFx/cgfxShaderCmd.cpp, cgFx/cgfxShaderCmd.h, closestPointOnCurve/closestPointOnCurveCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.h, clusterWeightFunction/clusterWeightFunction.cpp, conditionTest/conditionTest.cpp, dagMessageCmd/dagMessageCmd.cpp, deletedMsgCmd/deletedMsgCmd.cpp, dx11Shader/dx11ShaderCmd.cpp, dx11Shader/dx11ShaderCmd.h, eventTest/eventTest.cpp, exampleCameraSetView/exampleCameraSetViewCmd.cpp, filteredAsciiFile/filteredAsciiFile.cpp, flipUVCmd/flipUVCmd.cpp, flipUVCmd/flipUVCmd.h, geometryCacheConverter/geometryCacheConverter.cpp, geometrySurfaceConstraint/geometrySurfaceConstraint.cpp, glslShader/GLSLShaderCmd.cpp, glslShader/GLSLShaderCmd.h, gpuCache/gpuCacheCmd.cpp, gpuCache/gpuCacheCmd.h, grabUVMain.cpp, helixTool/helixTool.cpp, hlslShader/hlslShader.cpp, hlslShader/hlslShader.h, hwApiTextureTest/hwApiTextureTest.cpp, lensDistortionCallback/lensDistortionCallback.cpp, lensDistortionCallback/lensDistortionCallback.h, lockEvent/lockEvent.cpp, MetadataSample/createMetadataCmd.cpp, MetadataSample/createMetadataCmd.h, MetadataSample/exportMetadataCmd.cpp, MetadataSample/exportMetadataCmd.h, MetadataSample/importMetadataCmd.cpp, MetadataSample/importMetadataCmd.h, MetadataSample/metadataBase.cpp, MetadataSample/metadataBase.h, multiPlugInfoCmd/multiPlugInfoCmd.cpp, narrowPolyViewer/narrowPolyViewerCmd.cpp, nodeCreatedCBCmd/nodeCreatedCBCmd.cpp, nodeCreatedCBCmd/nodeCreatedCBCmd.h, nodeIconCmd/nodeIconCmd.cpp, nodeInfoCmd/nodeInfoCmd.cpp, particlePathsCmd/particlePathsCmd.cpp, peltOverlapCmd/peltOverlapCmd.cpp, renderViewInteractiveRenderCmd/renderViewInteractiveRenderCmd.cpp, renderViewRenderCmd/renderViewRenderCmd.cpp, renderViewRenderRegionCmd/renderViewRenderRegionCmd.cpp, scanDagSyntax/scanDagSyntax.cpp, sceneAssembly/adskRepresentationCmd.cpp, sceneAssembly/adskRepresentationCmd.h, sceneAssembly/adskSceneMetadataCmd.cpp, sceneAssembly/adskSceneMetadataCmd.h, userMsgCmd/userMsgCmd.cpp, viewCallbackTest/viewCallbackTest.cpp, viewMRenderOverride/viewMRenderOverride.cpp, viewRenderOverrideFrameCache/viewRenderOverrideFrameCacheMain.cpp, viewRenderOverridePostColor/viewRenderOverridePostColorCmd.cpp, viewRenderOverridePostColor/viewRenderOverridePostColorCmd.h, workspaceControlCmd.cpp, and workspaceControlCmd.h.

Member Enumeration Documentation

enum MArgType

Argument types.

MPxSelectionContext::argTypeNumericalInput(unsigned int index) const.

This method is used by the feedback line to determine what units to display. Users should override this method to return the appropriate argument type for the given index of the numeric input field. Specifically, this method should be overridden to return one of the following:

Parameters
[in]indexthe index of the numerical input whose argument type is requested
Returns
MSyntax::kNoArg the default return value.
Enumerator
kInvalidArgType 

 

kNoArg 

 

kBoolean 

 

kLong 

 

kDouble 

 

kString 

 

kUnsigned 

 

kDistance 

 

kAngle 

 

kTime 

 

kSelectionItem 

 

kLastArgType 

 

Object list types.

Enumerator
kInvalidObjectFormat 

 

kNone 

 

kStringObjects 

 

kSelectionList 

 

kLastObjectFormat 

 

Constructor & Destructor Documentation

MSyntax ( const MSyntax other)

The copy constructor.

Parameters
[in]otherMSyntax object to copy.

Member Function Documentation

MSyntax & operator= ( const MSyntax rhs)

The assignment operator.

Parameters
[in]rhsRight operand.
MStatus addFlag ( const char *  shortName,
const char *  longName,
MArgType  argType1 = kNoArg,
MArgType  argType2 = kNoArg,
MArgType  argType3 = kNoArg,
MArgType  argType4 = kNoArg,
MArgType  argType5 = kNoArg,
MArgType  argType6 = kNoArg 
)

Adds a flag to the list of flags accepted for the given command.

Also specifies any arguments required by the flag.

Parameters
[in]shortNamethe string representing the short (< 4 character) version of the flag
[in]longNamethe string representing the int (> 3 character) version of the flag
[in]argType1type of the argument required by the flag, if any
[in]argType2another type of the argument required by the flag, if any
[in]argType3another type of the argument required by the flag, if any
[in]argType4another type of the argument required by the flag, if any
[in]argType5another type of the argument required by the flag, if any
[in]argType6another type of the argument required by the flag, if any
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
Examples:
AbcBullet/AbcBullet.cpp, AbcExport/AbcExport.cpp, AbcImport/AbcImport.cpp, blast2Cmd/blast2Cmd.cpp, captureViewRenderCmd/captureViewRenderCmd.cpp, cgFx/cgfxShaderCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.cpp, clusterWeightFunction/clusterWeightFunction.cpp, conditionTest/conditionTest.cpp, dagMessageCmd/dagMessageCmd.cpp, dx11Shader/dx11ShaderCmd.cpp, eventTest/eventTest.cpp, exampleCameraSetView/exampleCameraSetViewCmd.cpp, filteredAsciiFile/filteredAsciiFile.cpp, flipUVCmd/flipUVCmd.cpp, geometryCacheConverter/geometryCacheConverter.cpp, geometrySurfaceConstraint/geometrySurfaceConstraint.cpp, glslShader/GLSLShaderCmd.cpp, gpuCache/gpuCacheCmd.cpp, grabUVMain.cpp, helixTool/helixTool.cpp, hlslShader/hlslShader.cpp, hwApiTextureTest/hwApiTextureTest.cpp, lensDistortionCallback/lensDistortionCallback.cpp, lockEvent/lockEvent.cpp, MetadataSample/createMetadataCmd.cpp, MetadataSample/importMetadataCmd.cpp, MetadataSample/metadataBase.cpp, multiPlugInfoCmd/multiPlugInfoCmd.cpp, narrowPolyViewer/narrowPolyViewerCmd.cpp, nodeCreatedCBCmd/nodeCreatedCBCmd.cpp, nodeIconCmd/nodeIconCmd.cpp, nodeInfoCmd/nodeInfoCmd.cpp, particlePathsCmd/particlePathsCmd.cpp, peltOverlapCmd/peltOverlapCmd.cpp, renderViewInteractiveRenderCmd/renderViewInteractiveRenderCmd.cpp, renderViewRenderCmd/renderViewRenderCmd.cpp, renderViewRenderRegionCmd/renderViewRenderRegionCmd.cpp, scanDagSyntax/scanDagSyntax.cpp, sceneAssembly/adskRepresentationCmd.cpp, sceneAssembly/adskSceneMetadataCmd.cpp, userMsgCmd/userMsgCmd.cpp, viewCallbackTest/viewCallbackTest.cpp, viewMRenderOverride/viewMRenderOverride.cpp, viewRenderOverrideFrameCache/viewRenderOverrideFrameCacheMain.cpp, viewRenderOverridePostColor/viewRenderOverridePostColorCmd.cpp, and workspaceControlCmd.cpp.
MStatus makeFlagMultiUse ( const char *  flag)

Specifies that the given flag can be used by the command multiple times in on the same command line.

Parameters
[in]flagthe flag to be made multi-use
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
Examples:
AbcBullet/AbcBullet.cpp, AbcExport/AbcExport.cpp, geometryCacheConverter/geometryCacheConverter.cpp, and hwApiTextureTest/hwApiTextureTest.cpp.
MStatus makeFlagQueryWithFullArgs ( const char *  flag,
bool  queryArgsAreOptional 
)

Specifies that the given flag will require all of its arguments in query mode.

Usually flags do not take arguments in query mode, since you are getting values instead of setting them. However, sometimes it is necessary to take arguments on a flag to allow the user to provide information which will help specify the scope of a query.

Note that query arguments may be set to be optional. In that case the flag will be accepted with arguments or without. In that case, you must check at runtime to see how many arguments where passed to the flag.

Parameters
[in]flagthe flag which should be set to use arguments during query
[in]queryArgsAreOptionalset to true if the flag arguments are optional
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
Examples:
gpuCache/gpuCacheCmd.cpp, and sceneAssembly/adskSceneMetadataCmd.cpp.
MStatus addArg ( MArgType  arg)

Specifies the type of one of the arguments to the command.

This method can be called multiple times to specify multiple arguments to the command.

Parameters
[in]argthe type of the argument to the command
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
Examples:
dx11Shader/dx11ShaderCmd.cpp, glslShader/GLSLShaderCmd.cpp, hlslShader/hlslShader.cpp, lensDistortionCallback/lensDistortionCallback.cpp, viewCallbackTest/viewCallbackTest.cpp, and viewRenderOverrideFrameCache/viewRenderOverrideFrameCacheMain.cpp.
void useSelectionAsDefault ( bool  useSelectionList = false)

Specifies that the command will use the current selection list as arguments to the command if the command requires objects and none are provided}.

Parameters
[in]useSelectionListif true, the command will use the current selection list as arguments if none are specified
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
Examples:
cameraMessageCmd/cameraMessageCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.cpp, dagMessageCmd/dagMessageCmd.cpp, deletedMsgCmd/deletedMsgCmd.cpp, gpuCache/gpuCacheCmd.cpp, lockEvent/lockEvent.cpp, MetadataSample/createMetadataCmd.cpp, MetadataSample/metadataBase.cpp, nodeIconCmd/nodeIconCmd.cpp, and particlePathsCmd/particlePathsCmd.cpp.
MStatus setObjectType ( MObjectFormat  objectFormat,
unsigned int  minimumObjects = 0 
)

Specifies the representation of the objects passed to the command as either MObjects or MStrings.

Also specifies the minimum number of objects required by the command.

Parameters
[in]objectFormatthe form of the objects passed to the command
[in]minimumObjectsthe minimum number of objects required by the command
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
Examples:
AbcImport/AbcImport.cpp, cameraMessageCmd/cameraMessageCmd.cpp, cgFx/cgfxShaderCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.cpp, conditionTest/conditionTest.cpp, dagMessageCmd/dagMessageCmd.cpp, deletedMsgCmd/deletedMsgCmd.cpp, eventTest/eventTest.cpp, gpuCache/gpuCacheCmd.cpp, lockEvent/lockEvent.cpp, MetadataSample/createMetadataCmd.cpp, MetadataSample/metadataBase.cpp, multiPlugInfoCmd/multiPlugInfoCmd.cpp, nodeIconCmd/nodeIconCmd.cpp, particlePathsCmd/particlePathsCmd.cpp, peltOverlapCmd/peltOverlapCmd.cpp, sceneAssembly/adskRepresentationCmd.cpp, and sceneAssembly/adskSceneMetadataCmd.cpp.
MStatus setObjectType ( MObjectFormat  objectFormat,
unsigned int  minimumObjects,
unsigned int  maximumObjects 
)

Specifies the representation of the objects passed to the command as either MObjects or MStrings.

Also specifies the upper and lower limits of the number of objects accepted by the command.

Parameters
[in]objectFormatthe form of the objects passed to the command
[in]minimumObjectsthe lower limit of the number of objects
[in]maximumObjectsthe upper limit of the number of objects
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
void setMinObjects ( unsigned int  minimumObjectCount)

Specifies the lower limit on the number of objects accepted by the command.

Parameters
[in]minimumObjectCountthe lower limit of the number of objects
Examples:
cameraMessageCmd/cameraMessageCmd.cpp, dagMessageCmd/dagMessageCmd.cpp, deletedMsgCmd/deletedMsgCmd.cpp, and nodeIconCmd/nodeIconCmd.cpp.
void setMaxObjects ( unsigned int  maximumObjectCount)

Specifies the upper limit on the number of objects accepted by the command.

Parameters
[in]maximumObjectCountthe upper limit of the number of objects
unsigned int minObjects ( ) const

Returns the lower limit on the number of objects accepted by the command.

Returns
The minimum number of objects
unsigned int maxObjects ( ) const

Returns the upper limit on the number of objects accepted by the command.

Returns
The maximum number of objects
bool canQuery ( ) const

Returns whether or not the command supports the query flag ("-q").

Returns
  • true can query
  • false cannot query
bool canEdit ( ) const

Returns whether or not the command supports the edit flag ("-e").

Returns
  • true can edit
  • false cannot edit
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.

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