[Tutor] MEL to Python Translation of array index in conditional statement
Peter Otten
__peter__ at web.de
Thu Nov 10 13:19:58 EST 2016
Brian Schindler wrote:
> I'm trying to convert the following code from MEL (Maya Embedded Language)
> to Python and having trouble with syntax errors in the conditional
> statement.
What did you try?
> Could you help me out?
>
> float $pos[3] = `xform -q -rp $obj`;
> if ($pos[0] != 0 || $pos[1] != 0 || $pos[2] != 0)
I don't know MEL. Is xform a commandline tool? In that case you might need
something along the lines of
output = subprocess.Popen(
["xform", "-q", "-rp", obj],
stdout=subprocess.PIPE).communicate()[0]
pos = [float(s) for s in output.split()]
if pos[0] or pos[1] or pos[2]:
... # whatever
> Brian Schindler
> Professor of Animation
Well, what can I say -- it's never too late to read <http://sscce.org/>.
Or <http://www.catb.org/~esr/faqs/smart-questions.html> if you prefer the
classics;)
More information about the Tutor
mailing list