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
Long name (short name) |
Argument types |
Properties |
|
addKeyword(ak)
|
string
|
|
|
Append one keyword to the keyboard list, which is used by the Search user interface
|
|
addTag(at)
|
string
|
|
|
Append one keyword to the tag list, which is used by the Search user interface
|
|
annotation(ann)
|
string
|
|
|
Description of the command.
|
|
category(cat)
|
string
|
|
|
Category for the command.
|
|
categoryArray(caa)
|
boolean
|
|
|
Return all the run time command categories.
|
|
command(c)
|
script
|
|
|
Command to be executed when runTimeCommand is invoked.
|
|
commandArray(ca)
|
boolean
|
|
|
Returns an string array containing the names of all the run
time commands.
|
|
commandLanguage(cl)
|
string
|
|
|
In edit or create mode, this flag allows the caller to choose a scripting
language for a command passed to the "-command" flag. If this flag is not
specified, then the callback will be assumed to be in the language from which
the runTimeCommand command was called. In query mode, the language for this
runTimeCommand is returned. The possible values are "mel" or "python".
|
|
default(d)
|
boolean
|
|
|
Indicate that this run time command is a default command.
Default run time commands will not be saved to preferences.
|
|
defaultCommandArray(dca)
|
boolean
|
|
|
Returns an string array containing the names of all the
default run time commands.
|
|
delete(delete)
|
boolean
|
|
|
Delete the specified user run time command.
|
|
exists(ex)
|
boolean
|
|
|
Returns true|false depending upon whether the specified object
exists. Other flags are ignored.
|
|
helpUrl(url)
|
string
|
|
|
Custom URL for the online documentation of this command. Used in the Search user interface.
|
|
hotkeyCtx(hc)
|
string
|
|
|
hotkey Context for the command.
|
|
image(i)
|
string
|
|
|
Image filename for the command.
|
|
keywords(k)
|
string
|
|
|
Keywords for the command. Used for searching for commands in the Search user interface.
When multiple keywords, use ; as a separator. (Example: "keyword1;keyword2")
|
|
label(l)
|
string
|
|
|
longAnnotation(la)
|
string
|
|
|
Extensive, multi-line description of the command.
This will show up in the Search user interface's 'more info' page in addition to the annotation.
|
|
numberOfCommands(nc)
|
boolean
|
|
|
Return the number of run time commands.
|
|
numberOfDefaultCommands(ndc)
|
boolean
|
|
|
Return the number of default run time commands.
|
|
numberOfUserCommands(nuc)
|
boolean
|
|
|
Return the number of user run time commands.
|
|
plugin(p)
|
string
|
|
|
Name of the plugin this command requires to be loaded.
This flag wraps the script provided into a safety check and automatically loads the
plugin referenced on execution if it hasn't been loaded.
If the plugin fails to load, the command won't be executed.
|
|
save(s)
|
boolean
|
|
|
Save all the user run time commands.
|
|
showInHotkeyEditor(she)
|
boolean
|
|
|
Indicate that this run time command should be shown in the Hotkey Editor.
Default value is true.
|
|
tags(t)
|
string
|
|
|
Tags for the command. Used for grouping commands in the Search user interface.
When more than one tag, use ; as a separator. (Example: "tag1;tag2")
|
|
userCommandArray(uca)
|
boolean
|
|
|
Returns an string array containing the names of all the
user run time commands.
|
|
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();