Huh... I wonder if the renderman plugin is having similar issues... - Paul
On Thu, Sep 17, 2009 at 10:07 AM, Olivier Renouard <[email protected]> wrote: > Hi, > > Jumping in but did anyone notice some bugged behavior, where pluging > commands using flags with String String String arguments forms are not > correctly made accessible in Python by Maya ? > > Having the problem at the moment with 3delight's Ri commands, that work well > from Mel but can't be accessed correctly from Python for that reason : > > http://www.3delight.com/en/modules/PunBB/viewtopic.php?id=1643 > > Did anyone manage to write a plugin command using that type of syntax and > have it correctly handled by Maya in Python, a MSyntax:: addFlag (const > char *shortName, const char *longName, MArgType argType1, MArgType argType2, > MArgType argType3 with like 3 String arguments? > > Olivier > > Paul Molodowitch wrote: > > Well, glad you got that sorted out. =) > > Still, I'm a little surprised that the PRMan plugin didn't also supply > a python version of mtor - generally speaking, as long as the plugin > is implemented "properly" - ie, uses MSyntax for it's command arg > processing - it should make both a python and mel command. > > - Paul > > > On Thu, Sep 17, 2009 at 3:41 AM, Drake <[email protected]> wrote: > > > Hey Paul, > > Thx a lot for the detailed explanation. During the tracing of pymel's > Mel class, I did notice the different handling of mel commands and mel > functions and I didn't realize that I have found the solution yet. > PRMan's mtor is command-styled and I would use pymel.mel.mtor > ('control', 'getvalue', '-sync') for them. > > Sometimes, it is too convenient to use pymel such that we made some > very fundamental mistakes~ > > -- Drake > > On Sep 17, 12:04 am, Paul Molodowitch <[email protected]> wrote: > > > Hey drake - > First of all, for commands from plugins, BOTH a python command and a > mel command should be made. So, both of these should be valid: > > // From mel: > mtor(...) > > # From python: > import maya.cmds > maya.cmds.mtor(...) > > Also, if you encounter problems with pymel.mel's wrapping, you can > always fall back on the the default maya.mel.eval, which just > evaluates a mel string: > > import maya.mel > maya.mel.eval('mtor ...') > > Thus far, I've just talked about stuff in maya's standard python/mel > - now onto pymel. Note that I don't have access to Renderman myself, > so I can't give definitive answers on the mtor command, but this > should point you in the right direction. > > In pymel, you can access the maya.cmds python function as normal: > > import pymel > pymel.mtor(...) > > Note, however, that if you did something like this: > > from pymel import * > loadPlugin('mtor.so') > mtor(...) > > ...you would get: > > # NameError: name 'mtor' is not defined # > > The reason here is that when you did the 'from pymel import *', the > 'mtor' command was not defined - you will have to either re-import * > into your namespace, or use pymel.mtor > > Making a guess at the syntax for the mtor command, the best way to > invoke the command you were looking for would probably be something > like this: > > mtor('control', 'getvalue', sync=True) > > If, for some reason, you have to use the MEL version of the command, > note that pymel's 'mel' wraps things using the 'function' syntax of > the mel command, not the 'command' syntax. If you're not clear on the > difference between the two, here's an example: > > // mel command syntax: > xform -q -translation; > // mel function syntax: > xform("-q", "-translation"); > > Thus, the correct way to invoke this command from pymel.mel would also be: > > pymel.mel.xform("-q", "-translation"); > > So, if you had to call mtor from python using the mel version, you > would likely do something like this: > > pymel.mel.mtor('control', 'getvalue', '-sync') > > Finally, as a last fallback, you can use pymel.mel.eval, which is just > a wrapper for the standard maya.mel.eval: > > pymel.mel.eval('mtor control getvalue -sync') > > On Wed, Sep 16, 2009 at 4:48 AM, Drake <[email protected]> wrote: > > > > It's a lovely design to use 'mel.ooxx(...)' to invoke mel function as > 'ooxx ...' but we encountered one special case as Pixar's mtor > function. In mel, mtor's function works like these: > > > mtor control getvalue -sync; > mtor control getvalue -rg dspyName; > mtor control setvalue -rg "dspyQuantizeOne" -value $ooxx; > ... > > > We could not directly make it work through pymel as following: > > > mel.mtor("control getvalue -sync") > > > Therefore, I did my own dirty hack on Mel class to make the above code > snippet work. I am wondering what is the suggested way to invoke some > mel functions like 'mtor'? > > > -- Drake > > > > > > > > > > -- > Olivier Renouard > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
