Monday, July 22, 2013

TIP for reading MEL parameters as Python parameters

Hi there,

Here are a couple of tips for reading MEL parameters as Python parameters I wrote today. Hope you find them helpful.

EXAMPLE 1.
//MEL
joint -e -oj xyz -secondaryAxisOrient yup -ch -zso;

#PYTHON
cmds.joint(edit=True, oj = 'xyz', secondaryAxisOrient = 'yup', ch=True, zso = True)

EXAMPLE 2.
//MEL
xform -ws -translation 1.0 0.0 0.0 joint1

#PYTHON
cmds.xform('joint1',q=False, ws=True, translation = [1.0, 0.0, 0.0] )


1. first thing in MEL is the function that gets put next to cmds.

2. if see a dash (-something) and after it is another (-else) we know the -something is a boolean a true or false. so
in python would do (something = True). (ex: edit = True), (ex: ch=True).

3. if see a dash (-something) and after it is NOT another (-else) we know the -something needs an argument.
if there are letters after the (-something) we know it needs a string. so in Python would do (ex: oj = 'xyz')
if see numbers after the (-somthing) we know it needs float(s). (ex: translation = [1,0,0])

4. last if see a string at end of MEL command it needs to go in the PYTHON version but at the BEGINNING (reason i think is that in Python non keword argument needs to go before the keyword arguments). (ex: cmds.xform('joint1', …) )

cheers,
-Nate