class MSyntax

Jump to documentation

Syntax for Commands.

public members:

enum MArgType
kInvalidArgType
kNoArg
kBoolean
kLong
kDouble
kString
kUnsigned
kDistance
kAngle
kTime
kSelectionItem
kLastArgType
enum MObjectFormat
kInvalidObjectFormat
kNone
kStringObjects
kSelectionList
kLastObjectFormat
MSyntax ()
MSyntax ( const MSyntax & other )
virtual ~MSyntax ()
MSyntax &operator= (const MSyntax &rhs)
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 )
MStatus makeFlagMultiUse (const char *flag)
MStatus addArg ( MArgType arg)
void useSelectionAsDefault (bool useSelectionList = false)
MStatus setObjectType ( MObjectFormat objectFormat, unsigned int minimumObjects = 0)
MStatus setObjectType ( MObjectFormat objectFormat, unsigned int minimumObjects, unsigned int maximumObjects)
void setMinObjects (unsigned int minimumObjectCount)
void setMaxObjects (unsigned int maximumObjectCount)
void enableQuery (bool supportsQuery = true)
void enableEdit (bool supportsEdit = true)
unsigned int minObjects () const
unsigned int maxObjects () const
bool canQuery () const
bool canEdit () const

Documentation

This class is used to specify flags and arguments passed to commands.
Description

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:

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.

Functions

MSyntax:: MSyntax ()

Description

The default class constructor.

MSyntax:: MSyntax ( const MSyntax & other )

Description

The copy constructor.

MSyntax:: ~MSyntax ()

Description

The class destructor.

MSyntax & MSyntax:: operator= (const MSyntax &rhs)

Description

The assignment operator.

MStatus MSyntax:: addFlag (const char *shortName, const char *longName, MArgType argType1, MArgType argType2, MArgType argType3, MArgType argType4, MArgType argType5, MArgType argType6)

Description

Adds a flag to the list of flags accepted for the given command. Also specifies any arguments required by the flag.

Arguments

  • shortName the string representing the short (< 4 character) version of the flag
  • longName the string representing the int (> 3 character) version of the flag
  • argType1 type of the argument required by the flag, if any
  • argType2 another type of the argument required by the flag, if any
  • argType3 another type of the argument required by the flag, if any
  • argType4 another type of the argument required by the flag, if any
  • argType5 another type of the argument required by the flag, if any
  • argType6 another type of the argument required by the flag, if any

Return Value

  • MS::kSuccess operation successful
  • MS::kFailure operation failed

MStatus MSyntax:: makeFlagMultiUse (const char *flag)

Description

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

Arguments

  • flag the flag to be made multi-use

Return Value

  • MS::kSuccess operation successful
  • MS::kFailure operation failed

MStatus MSyntax:: addArg ( MArgType arg)

Description

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.

Arguments

  • argumentType the type of the argument to the command

Return Value

  • MS::kSuccess operation successful
  • MS::kFailure operation failed

void MSyntax:: useSelectionAsDefault (bool useSelectionList)

Description

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

Arguments

  • useSelectionList if true, the command will use the current selection list as arguments if none are specified

Return Value

  • MS::kSuccess operation successful
  • MS::kFailure operation failed

MStatus MSyntax:: setObjectType ( MObjectFormat objectFormat, unsigned int minimumObjects)

Description

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.

Arguments

  • objectFormat the form of the objects passed to the command
  • minimumObjects the minimum number of objects required by the command

Return Value

  • MS::kSuccess operation successful
  • MS::kFailure operation failed

MStatus MSyntax:: setObjectType ( MObjectFormat objectFormat, unsigned int minimumObjects, unsigned int maximumObjects)

Description

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.

Arguments

  • objectFormat the form of the objects passed to the command
  • minimumObjects the lower limit of the number of objects
  • maximumObjects the upper limit of the number of objects

Return Value

  • MS::kSuccess operation successful
  • MS::kFailure operation failed

void MSyntax:: setMinObjects (unsigned int minimumObjectCount)

Description

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

Arguments

  • minimumObjectCount the lower limit of the number of objects

Return Value

  • none

void MSyntax:: setMaxObjects (unsigned int maximumObjectCount)

Description

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

Arguments

  • maximumObjectCount the upper limit of the number of objects

Return Value

  • none

void MSyntax:: enableQuery (bool supportsQuery)

Description

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

Arguments

  • supportsQuery if true, the command supports the query flag

Return Value

  • none

void MSyntax:: enableEdit (bool supportsEdit)

Description

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

Arguments

  • supportsEdit if true, the command supports the edit flag

Return Value

  • none

unsigned int MSyntax:: minObjects () const

Description

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

Return Value

  • the minimum number of objects

unsigned int MSyntax:: maxObjects () const

Description

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

Return Value

  • the maximum number of objects

bool MSyntax:: canQuery () const

Description

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

Return Value

  • true can query
  • false cannot query

bool MSyntax:: canEdit () const

Description

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

Return Value

  • true can edit
  • false cannot edit

This class has no child classes.


Autodesk® Maya® 8.0 © 1997-2006 Autodesk, Inc. All rights reserved. doc++ Copyright