Is there a reason you are aliasing MPxNode to MPxCommand? When you use MPxNode, you have to register an id with Maya. If you make your plugin actually subclass from the real MPxCommand, does it work?
On Thu, 5 Nov 2015 1:36 AM Anthony Tan <[email protected]> wrote: > Try make your kMyJointShortFlg shorter by one character? > > Just from the addFlag documentation (and some googling for that error > message, admittedly) on MSyntax you need < 4 characters. > > > On Wed, Nov 4, 2015, at 11:17 PM, Rudi Hammad wrote: > > sure, so if I do cmds.myJointCommand(jRh=1) or cmds.myJointCommand(h=1) > I get > # Error: RuntimeError: file <string> line 2: You are not licensed > to use the "myJointCommand" command. # > > > > El miércoles, 4 de noviembre de 2015, 9:42:11 (UTC+1), Marcus Ottosson > escribió: > > Could you say again what the problem was, the help flag doesn't work? > Would it be possible to post a minimal example of the problem? > > On 3 Nov 2015, at 17:51, Rudi Hammad <[email protected]> wrote: > > Hello again, > I hope it is okey to keep asking. So far every thing I posted was solved > so thanks a lot for that > I hope you could help me out wth that too. > I bought Chayan Vinayak Dvd, and it excelent but there are some things > that remain unclear. So I am trying to build this command plugin that just > builds a joint when the argument jointRh is given > Also, the help flag doesn´t work so... > the command is cmds.myJointCommand(jRh=1) > it register and unregister okey, so can someone try it out? > Thanks > > > > > > """--------------------------------------------------------------------------------[REQUISITOS]--------------------------------------------------------------------------------""" > > ##[MODULOS,OBJETOS Y CLASS]## > # modulos > import maya.OpenMayaasOpenMaya > import maya.OpenMayaMPxasOpenMayaMPx > import sys > # objetos y classes > > MPxCommand=OpenMayaMPx.MPxNode# class (que no objeto) de la que heredar > > > > ##[VARIABLES]## > kHelpShortFlg ="-h" > kHelpLongFlg ="-help" > helpMessage ="este commando sirve para crear una joint mediante un > command plugin" > kMyJointShortFlg ="-jRh" > kMyJointtLongFlg ="-jointRh" > #--[nombre del commando]--# > myCommandName ="myJointCommand" > > > """----------------------------------------------------------------------------------[CLASS]----------------------------------------------------------------------------------""" > > ##[CLASS]## > classMyJointPluginCommand(MPxCommand): > > #--[static Var]--# > myJointValue =None > > #--[methods]--# > # __init__ > def __init__(self): > super(MyJointPluginCommand,self).__init__() > > # argumentParser > def argumentParser(self,argList): > syntax =self.syntax() > > OpenMaya.MArgDatabase(syntax, argList)#MArgDatabase analiza(parse) > command args, flags y flags args > mArgDatabase =OpenMaya.MArgDatabase(syntax, argList) > > > > #--[flags]--] > # flag corta help corta/larga > if mArgDatabase.isFlagSet(kHelpShortFlg):# isFlagSet() viene heredado de > la superclass de MArgDatabase que es MArgParse. Esto es para que queriee > que flag le he dado > > self.setResult(helpMessage)# el mesaje de ayuda como arg > > > returnOpenMaya.MStatus.kSuccess > if mArgDatabase.isFlagSet(kHelpLongFlg): > self.setResult(helpMessage) > returnOpenMaya.MStatus.kSuccess > # flag corta joint corta/larga > if mArgDatabase.isFlagSet(kMyJointShortFlg): > > self.myJointValue = mArgDatabase.flagArgumentBool(kMyJointShortFlg,0)# > aqui le digo que tipo de argumento espero recibir en la flag, y entr() los > args son la flag, y el indice por defecto > > > returnOpenMaya.MStatus.kSuccess > if mArgDatabase.isFlagSet(kMyJointtLongFlg): > self.myJointValue = mArgDatabase.flagArgumentBool(kMyJointtLongFlg,0) > returnOpenMaya.MStatus.kSuccess > > > def isUndoable(self): > returntrue > > def undoIt(self): > print"undo" > > > mFnDagNode =OpenMaya.MfnDagNode# para acceder al transform de > lo que quiero borrar > mDagModifier =OpenMaya.MDagModifier(mFnDagNode.parent(0))# es > el stack de operacion > > > mDagModifier.deleteNode() > mDagModifier.doIt() > returnOpenMaya.MStatus.kSuccess > > def redoIt(): > mFnDagNode =OpenMaya.MFnDagNode() > objJoint = mFnDagNode.create("joint","myJoint") > returnOpenMaya.MStatus.kSuccess > > def doIt(self,argList): > print"yeeeee" > > self.argumentParser(argList)# como siempre, en OOP para usar un metodo > dentro de otro (nesting), uso self para indicar que el metodopertenece a la > class > ifself.myJointValue !=None: > self.redoIt()# aqui dice es donde va el script donde pilla vertices y > pone cubos. redoIt porque se puede hacer varias veces. Y doIt porque solo > hace argumentParser una vez > > > else: > print" nada que crear " > > returnOpenMaya.MStatus.kSuccess #es importante devolver el estado de lo > has hecho > > > > > > > > > > """----------------------------------------------------------------------------------[FUNCIONES]----------------------------------------------------------------------------------""" > > ##[FUNCIONES]## > > # def para atachar pointer > def myCommandCreator(): > returnOpenMayaMPx.asMPxPtr(MyJointPluginCommand()) > > # MSyntax object > def mySyntaxCreator(): > # creo objeto mSyntax > mSyntax =OpenMaya.MSyntax() > # addo flags > mSyntax.addFlag(kHelpShortFlg, kHelpLongFlg) > > > mSyntax.addFlag(kMyJointShortFlg, kMyJointShortFlg,OpenMaya.MSyntax. > kDouble)#indico tipo de variable que debe recibir > > return mSyntax > > > """------------------------------------------------------------------------------[REGISTRO > Y > DESREGISTRO]-----------------------------------------------------------------------------""" > > #--[initialization command plugin]--# > def initializePlugin(myMObject): > myPlugin =OpenMayaMPx.MFnPlugin(myMObject) > try: > > > myPlugin.registerCommand( myCommandName, myCommandCreator, > mySyntaxCreator )#attacho pointer > > > sys.stderr.write("\n se ha inicializado correctamente "+ > myCommandName) > except: > sys.stderr.write("\n meeeccc!! , fallo de registro de "+ > myCommandName) > > #--[uninitialization command plugin]--# > def uninitializePlugin > > > ... > > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/fbc9fe34-5cac-499c-a6e0-c99b59c7af21%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/fbc9fe34-5cac-499c-a6e0-c99b59c7af21%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/1446640554.1346926.428847777.30F613DB%40webmail.messagingengine.com > <https://groups.google.com/d/msgid/python_inside_maya/1446640554.1346926.428847777.30F613DB%40webmail.messagingengine.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0aisOGivBbDZ_EPSgytgUbkXYPdydiYuscob_CTvFEdQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
