2010

Table Of Contents
7 Transfer the MEL variables value to Python by typing the following:
TransferMELvar = maya.mel.eval("$temp=$MyMELVariable")
When transferring variables between MEL and Python, the functions
return the value of the statement. MEL syntax does not allow you to
return the value of a variable by using the variable as a command string.
In MEL, when a variable is assigned a value, the value is returned to the
Script Editor. Within the eval() statement, you assign the value of the
global MEL variable to a temporary variable.
8 Output the value of the transferred MEL variable using Python commands:
print TransferMELvar;
To call Python commands from MEL
1 Select a MEL tab in the Script Editor.
Commands typed in the MEL tab are executed in MEL.
2 Call a Python command by typing the following:
python "cmds.sphere()";
A sphere is created at the origin, just as if you had typed the command
in the Python tab.
3 Select a Python Tab in the Script Editor
4 Declare a variable in the Python tab by typing the following:
MyPythonVariable=22.7
5 Select a MEL tab in the Script Editor.
6 Transfer the Python variables value to MEL by typing the following:
float $TransferVarPy = `python "MyPythonVariable"`;
Evaluation back quotes are used in MEL to use the return value of a
command in assignment, when the return value is normally returned to
the Script Editor history window.
7 Output the value of the transferred variable in MEL:
print $TransferVarPy;
714 | Chapter 13 Scripting in Maya