[Tutor] MEL to Python Translation of array index in conditional statement
Alan Gauld
alan.gauld at yahoo.co.uk
Thu Nov 10 20:09:41 EST 2016
On 10/11/16 13:08, Brian Schindler wrote:
> I'm trying to convert the following code from MEL (Maya Embedded Language)
> to Python
You'll probably get better support fromthe Maya community than here
since most of us don;'t know anything about Maya's language.
> and having trouble with syntax errors in the conditional statement.
> float $pos[3] = `xform -q -rp $obj`;
> if ($pos[0] != 0 || $pos[1] != 0 || $pos[2] != 0)
That is presumably the Maya code?
Unfortunately I don't know exactly what it does - I can make
a guess but that's all it would be. For example, is the
indentation on line 2 significant? (It would be in python)
I'm guessing the backtick(`) mean you are executing an OS command?
If so you'll need the python subprocess module to do the equivalent.
If the 2nd line does what I think, the equivalent Python code would
be something like:
if pos[0] or pos[1] or pos[2]:
# do something here
Can you show us what you tried and what error message(s) you
got(in full)?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list