runTimeCommand -command "sphere -name myName" mySphere;
import maya.cmds as cmds cmds.mySphere()
import maya.cmds as cmds def mySphere(): cmds.sphere(name='myName') cmds.runTimeCommand('MyBall', command='mySphere()') cmds.MyBall()
maya.cmds.scale(3, 3, 3, r=True, p=('0cm', '0.5cm', '0cm'))
import maya.cmds as cmds def defaultButtonPush(*args): print 'Default was pushed.' cmds.window( width=150 ) cmds.columnLayout( adjustableColumn=True ) cmds.button( label='Default', command=defaultButtonPush ) cmds.button( label='Left', align='left' ) cmds.button( label='Center', align='center' ) cmds.button( label='Right', align='right' ) cmds.showWindow()
select -r surface1.cv["*"];
cmds.select( 'surface1.cv[*]' , r=True)
There are two ways in which MEL and Python differ in the areas of returning and echoing results. One is relevant to proper script execution while the other is a superficial issue. This section discusses both echoing a result and returning a result -- they are sometimes confused.
When MEL executes a script, it returns the result of the last executed statement, if there is any. Statements that assign values to variables and procedure calls that return results are types of statements which return results. For example, the following block of code will have a result, which MEL will echo to the script editor and command line message area:
if ( $foo == 1 ) $bar = 42; else $bar = 7;
Understanding this difference is important if you want to use values computed in one language in the context of the other. For example, if you want to use a Python value in MEL, you can simply do the following:
This works because the assignment statement, which is last in the script passed to the eval command, returns a result.