thank you very much. Of course I will paste it better next time.
My head was hurting. Thanks Justin

El jueves, 5 de noviembre de 2015, 23:42:49 (UTC+1), Justin Israel escribió:
>
> You had a bunch of problems in this code. I cleaned it all up, fixed the 
> problems, and put it in a pastebin:
> http://paste.ubuntu.com/13116862/
>
> In the future, can you use some kind of code paste? Either pastebin, or 
> gist, or something to make sure indentation is preserved?
>
> Anyways, various things I fixed:
>
>    - Bad indentation had a number of the plugin methods indented into the 
>    arg parsing method
>    - Missing "self" in one of the methods
>    - Returning true instead of True
>    - Using MStatus instead of just returning, or raising exceptions
>
> This works for me, when I run it with the help flag.
>
> On Fri, Nov 6, 2015 at 7:49 AM Rudi Hammad <[email protected] 
> <javascript:>> wrote:
>
>> anyone? nop???
>> I am still stuck on this. 
>> By the way, is it okey to use cmds inside a command plugin? in my mind, 
>> maya API and maya cmds are things that should not be mixed.
>>
>>
>> El miércoles, 4 de noviembre de 2015, 20:00:35 (UTC+1), Rudi Hammad 
>> escribió:
>>
>>> upss...sorry, you are right, MPxNode was a mistake
>>> so I read all your feedback and did that...but still not working. Man 
>>> that´s frustrating. Same error
>>>
>>>
>>>
>>> """--------------------------------------------------------------------------------[REQUISITOS]--------------------------------------------------------------------------------"""
>>>
>>> ##[MODULOS,OBJETOS Y CLASS]##
>>> # modulos
>>> import maya.OpenMaya as OpenMaya
>>> import maya.OpenMayaMPx as OpenMayaMPx
>>> import sys
>>> # objetos y classes
>>> MPxCommand = OpenMayaMPx.MPxCommand # class (que no objeto) de la que 
>>> heredar
>>>
>>> ##[VARIABLES]##
>>> kHelpShortFlg = "-h"
>>> kHelpLongFlg = "-hlp"
>>> helpMessage = "este commando sirve para crear una joint mediante un 
>>> command plugin"
>>> kMyJointShortFlg = "-j"
>>> kMyJointtLongFlg = "-jnt"
>>> #--[nombre del commando]--#
>>> myCommandName = "myJointCommand"
>>>
>>>
>>> """----------------------------------------------------------------------------------[CLASS]----------------------------------------------------------------------------------"""
>>>
>>> ##[CLASS]##
>>> class MyJointPluginCommand(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
>>>             return OpenMaya.MStatus.kSuccess
>>>         if mArgDatabase.isFlagSet(kHelpLongFlg):
>>>             self.setResult(helpMessage)
>>>             return OpenMaya.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
>>>             return OpenMaya.MStatus.kSuccess
>>>         if mArgDatabase.isFlagSet(kMyJointtLongFlg): 
>>>             self.myJointValue = mArgDatabase.flagArgumentBool(
>>> kMyJointtLongFlg, 0)
>>>             return OpenMaya.MStatus.kSuccess
>>>    
>>>    
>>>         def isUndoable(self):
>>>             return true   
>>>    
>>>         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()
>>>             return OpenMaya.MStatus.kSuccess
>>>        
>>>         def redoIt():
>>>             mFnDagNode = OpenMaya.MFnDagNode()
>>>             objJoint = mFnDagNode.create("joint", "myJoint")
>>>             return OpenMaya.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
>>>             if self.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 "
>>>             return OpenMaya.MStatus.kSuccess #es importante devolver el 
>>> estado de lo has hecho
>>>     
>>>     
>>>
>>>
>>>   
>>>             
>>>
>>> """----------------------------------------------------------------------------------[FUNCIONES]----------------------------------------------------------------------------------"""
>>>
>>> ##[FUNCIONES]##
>>>
>>> # def para atachar pointer
>>> def myCommandCreator():
>>>     return OpenMayaMPx.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(myMObject):
>>>     myPlugin = OpenMayaMPx.MFnPlugin(myMObject)
>>>     try:
>>>         myPlugin.deregisterCommand(myCommandName) #aqui no requiere 
>>> attachar pointer, ya esta dentro del core
>>>         sys.stderr.write("\n se ha desinicializado correctamente " 
>>>
>> ...
>>
>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/56dcb75b-ed97-4036-b5b4-6f0163bc8c4c%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/56dcb75b-ed97-4036-b5b4-6f0163bc8c4c%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/c6454f77-974a-486c-8937-5c0a2e3e4309%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to