Message 1 of 3
Maya 2020 Python 2.0 API - MPxContextCommand : Help with user defined parameters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good afternoon all,
I'm using the new python Context/ContextCommand API that were recently added and I'm not sure if I'm appending a new "-length" paramater/syntax to the MPxContextCommand properly.
This is a snippet of the MPxContextCommand...
class MoveBrushCommand(omuiapi2.MPxContextCommand):
COMMAND_NAME = "MoveBrushCommand"
LENGTH_FLAG = "-l"
LENGTH_FLAG_LONG = "-length"
MOVEBRUSHCONTEXT = None
SYNTAX = omapi2.MSyntax()
def __init__(self):
omuiapi2.MPxContextCommand.__init__(self)
@classmethod
def creator(cls):
return cls()
def makeObj(self):
MoveBrushCommand.MOVEBRUSHCONTEXT = MoveBrushContext()
return MoveBrushCommand.MOVEBRUSHCONTEXT
def doEditFlags(self):
pass
def doQueryFlags(self):
argData = omapi2.MArgParser(MoveBrushCommand.SYNTAX, omapi2.MArgList())
if (argData.isFlagSet(MoveBrushCommand.LENGTH_FLAG)):
length = argData.flagArgumentDouble(MoveBrushCommand.LENGTH_FLAG, 0)
MoveBrushCommand.MOVEBRUSHCONTEXT.test_query_data()
def appendSyntax(self):
MoveBrushCommand.SYNTAX.addFlag(MoveBrushCommand.LENGTH_FLAG, MoveBrushCommand.LENGTH_FLAG_LONG, omapi2.MSyntax.kDouble)
If I try to queue my context and the instance with...
MoveBrushCommand -q -length MoveBrushCommand14857705;
I get this error...
// Error: line 1: Invalid flag '-length' //
I'm assuming the appendSyntax method is where you add user-defined arguments, is it not?
Can anyone help point me in the right direction? 😀