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
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to