Go to: Synopsis. Return value. Python examples.
eval( string )
Note: Strings representing object names and
arguments must be separated by commas. This is not depicted in the
synopsis.
eval is NOT undoable, NOT queryable, and NOT editable.
This function takes a string which contains MEL code and evaluates it using the MEL interpreter. The result is converted into a Python data type and is returned. If an error occurs during the execution of the MEL script, a Python exception is raised with the appropriate error message.Any | depending on input. |
import maya.mel as mel mel.eval('match "a+b+" "abbcc"') # Result: abb # # Eval can be used to access global MEL variables. For example, the following # assigns the current value in $gMainWindow to a Python variable. myPythonVar=mel.eval('$tempMelVar=$gMainWindow') # Print the value retrieved. print myPythonVar # Result: MayaWindow