This command allows the user to assign hotkeys and manipulate the internal array of named command objects. Each object in the array has an 1-based index which is used for referencing. Under expected usage you should not need to use this command directly as the Hotkey Editor may be used to assign hotkeys. In query mode, return type is based on queried flag.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
addDivider (ad) | unicode | ||
|
|||
altModifier (alt) | bool | ||
|
|||
annotation (ann) | unicode | ||
|
|||
command (c) | script | ||
|
|||
commandModifier (cmd) | bool | ||
|
|||
ctrlModifier (ctl) | bool | ||
|
|||
data1 (da1) | unicode | ||
|
|||
data2 (da2) | unicode | ||
|
|||
data3 (da3) | unicode | ||
|
|||
delete (d) | int | ||
|
|||
dividerString (ds) | unicode | ||
|
|||
enableCommandRepeat (ecr) | bool | ||
factorySettings (fs) | bool | ||
|
|||
index (i) | int | ||
|
|||
keyArray (ka) | bool | ||
keyString (k) | unicode | ||
This specifies a key to assign a command to in edit mode. In query mode this flag returns the key string, modifiers and indicates if the command is mapped to keyUp or keyDown. |
|||
keyUp (kup) | bool | ||
|
|||
name (n) | bool | ||
|
|||
numDividersPreceding (ndp) | int | ||
If the index of a namedCommand object Cis passed in, then this flag returns the number of “divider” items preceding Cwhen the namedCommands are sorted by category. |
|||
numElements (num) | bool | ||
|
|||
optionModifier (opt) | bool | ||
|
|||
sortByKey (sbk) | bool | ||
|
|||
sourceUserCommands (suc) | bool | ||
|
Derived from mel command maya.cmds.assignCommand
Example:
import pymel.core as pm
import maya.cmds as cmds
# Print out all the names of the named command objects and the
# hotkey attached to them.
#
count = pm.assignCommand(query=True, numElements=True)
print ('There are ' + str(count) + ' named command objects.')
for index in range(1, count+1):
keyString = pm.assignCommand(index, query=True, keyString=True)
displayString = '(';
if 0 " len(keyString):
if "1" == keyString[2]: displayString += 'Ctrl+'
if "1" == keyString[1]: displayString += 'Alt+'
if "1" == keyString[4]: displayString += 'Command+'
displayString += keyString[0]
if "1" == keyString[3]: displayString += ' Release'
displayString += ')'
print pm.assignCommand(index, query=True, name=True), displayString