[Syntax] MEL / Python

[Syntax] MEL / Python

Anonymous
Not applicable
1,016 Views
1 Reply
Message 1 of 2

[Syntax] MEL / Python

Anonymous
Not applicable

Hi there, I was hoping someone could point me in the right direction here. Probably some syntax issues, but stuck on it for over 2 hours..

 

Python

import maya.cmds as cmds

pyPos = cmds.xform('HET_FAD_0',q=1,ws=1,rp=1)

 

MEL

 

 

float $transPyPos[] = 'python "pyPos"'
string $myType = 'getAttr -type ($transPyPos)';

 

The pyPos command works, it returns an (float) array [100.11177362714494, 47.04773793901715, 73.88260686965215] , however I don't know the type that transPyPos or xform when used directly in MEL for that matter return. This makes it impossible for me to do it in MEL only, which is needed in order to use the output in another MEL script of mine..

 

The error reads Invalid redeclaration of variable "$transPyPos" as a different type

 

Not working MEL:

 

float $myPos[] = xform('HET_FAD_0',q=1,ws=1,rp=1)

^syntax error?

 

I have searched but couldn't find what type xform returns.

Thanks for your help.

 

0 Likes
Accepted solutions (1)
1,017 Views
1 Reply
Reply (1)
Message 2 of 2

RFlannery1
Collaborator
Collaborator
Accepted solution

Here is how you can do it in MEL only:

float $myPos[] = `xform -q -ws -rp "HET_FAD_0"`;

A couple of things to note here.  First, the object name is in regular quotes; not single quotes.  In Python, you can use either, but in MEL, you must use regular quotes.  Second, the command is surrounded by backticks.  Do not confuse backticks with single quotes.  (` vs ').  The backtick is the one under ~ on the keyboard.

 

 

You could also do it this way, but most people don't use this syntax and will find it confusing.

float $myPos[] = xform("-q", "-ws", "-rp", "HET_FAD_0");