Go to: Synopsis. Return value. Flags. Python examples.
runTimeCommand(
name
, [addKeyword=string], [addTag=string], [annotation=string], [category=string], [categoryArray=boolean], [command=script], [commandArray=boolean], [commandLanguage=string], [default=boolean], [defaultCommandArray=boolean], [delete=boolean], [exists=boolean], [helpUrl=string], [hotkeyCtx=string], [image=string], [keywords=string], [label=string], [longAnnotation=string], [numberOfCommands=boolean], [numberOfDefaultCommands=boolean], [numberOfUserCommands=boolean], [plugin=string], [save=boolean], [showInHotkeyEditor=boolean], [tags=string], [userCommandArray=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
runTimeCommand is undoable, queryable, and editable.
Create a MEL command given the specified name. Once the command is created
you can invoke it like any other MEL command. When the command is invoked
it will execute the string attached to the command flag.
Note that the resulting command takes no arguments, has no flags and
may not be queried or edited.
The command name you provide must be unique. The name itself must
begin with an alphabetic character or underscore followed by
alphanumeric characters or underscores.
If you create your run time commands in a script which is automatically
sourced at startup then set the default flag to true. This
will prevent the application from attempting to save these commands.
string | The name of the command on. |
In query mode, return type is based on queried flag.
addKeyword, addTag, annotation, category, categoryArray, command, commandArray, commandLanguage, default, defaultCommandArray, delete, exists, helpUrl, hotkeyCtx, image, keywords, label, longAnnotation, numberOfCommands, numberOfDefaultCommands, numberOfUserCommands, plugin, save, showInHotkeyEditor, tags, userCommandArray
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
# Create a command that simply prints a message. After executing
# the following lines enter the command name <i>MyHelloCommand</i>
# in the Command Line.
#
if maya.cmds.runTimeCommand( 'MyHelloCommand', exists=True ):
cmds.runTimeCommand( annotation='Print the word "Hello"', command='print "Hello\\n"', MyHelloCommand )
# Create a window with a button that invokes the <i>MyHelloCommand</i>
# command.
#
cmds.window()
cmds.paneLayout()
# Some commands support different language source types. Since the button command does not, it
# assumes Python and the command has to be explicitly forwarded to MEL, which is what the runTimeCommand creates.
cmds.button( command='import maya.mel; mel.eval("MyHelloCommand")' )
cmds.showWindow();