A command can have both arguments and flags.
Flags are named options to a command. For example, in
cmds.polyCube( sx=10, sy=15, sz=5, h=20 )
'sx
', 'sy
', 'sz
', and 'h
' are command flags.
Command arguments do not have associated names. They will always appear at the beginning of the call to the command, before the command's flags. For example, in
cmds.group( 'circle1', 'sphere1', n='group1' )
'circle1'
and 'sphere1'
are command arguments. They are placed before the optional 'n
flag.
When your command processes arguments or flags, registerCommand()
needs to include the command's argument syntax.
mplugin.registerCommand( kPluginCmdName, cmdCreator, syntaxCreator )
syntaxCreator
is an MSyntax object that defines the flags and arguments. Flags are added with MSyntax.addFlag()
and arguments are added with MSyntax.addArg()
.
The MSyntax object is parsed in the doIt
function by using the MArgParser and MArgList classes.