Ben VZ 03 September 2009 09:57 PM
Aha,
Also, even though the docs would appear to have you supply 16 doubles to the matrix argument, you have to, in fact, just give it a boolean if you are in query mode. Makes sense, but I have not been able to find the actual docs that explain it.
In the User Guide - General - Python - Using Python there is a section on Flags (named arguments)
Flags are handled differently in Python than they are in MEL. MEL was designed with a shell command style syntax.
For Maya commands in Python, the command argument syntax has been adapted in a way that is natural for Python. As a result, flags—both long and short forms—are passed to commands as named arguments. The name of the argument is the flag name and the flag’s arguments are passed to the named argument.
Required arguments (True/False)
Named arguments must have a value associated with them. However, not all Maya flags require a value (for example, ls -sl). In order to maintain a consistent syntax, the Autodesk Maya Python implementation requires you to assign a boolean argument to those flags that do not normally take any arguments. If the boolean value is False, then the flag is ignored; if it is True, the flag is used.
This is one of the main differences between MEL and Python. In MEL you would use empty flags for query and the thing you were querying, something like
xform -q -matrix mmCam_
In Python you need to use:
cmds.xform("mmCam_",q=True, matrix=True)
The default value for any flag like this that is not specified is False. (so you don’t have to go through and remember all those flags that you don’t normally set through MEL)
Also, the 0 that you set the flag to in your first example can be used instead of False, had you used 1 it would have worked.
|