Binding shortcuts to a Python tool
 
 
 

There are two types of Python shortcuts:

You can create up to 12 global shortcuts that can be mapped, or bound, to scripts. By default, some are already set up. Try Shift+F1 (from the MotionBuilder interface, not the Python editor); it creates a new camera. This is because the keyboard combination Shift+F1 is bound to the execution of NewCamera.py.

Bindings between shortcuts and scripts are configured in two steps:

  1. Add the scripts to the [ScriptFiles] section of config\Scripts\ActionScript.txt.
  2. Define the shortcuts in config\Keyboard\. This can be done by editing the files with a text editor or by using the graphical editor provided by the script KeyboardMapper.py.

config\Scripts\ActionScript.txt contains a list of scripts to execute:

[ScriptFiles]
Script1 = Basic OperationsNewCamera.py
Script2 = ActionScriptKeyIK.py
Script3 = ActionScriptKeyFK.py
Script4 = ActionScriptKeyEffector.py
Script5 = ActionScriptKeySelected.py
Script6 = 
Script7 = 
Script8 = 
Script9 = 
Script10 = 
Script11 = 
Script12 = 

The path to the script can be one of:

Next map the script (for example Script1) to a keyboard shortcut in a keyboard file in config\Keyboard\. These files contain entries for all of the keyboard shortcuts in MotionBuilder. There are several files; you use one at a time according to the menu Settings > Keyboard Configuration. You can also use the KeyboardMapper.py script as a graphical interface to the keyboard configuration text files.

Python script bindings are of the form:

action.global.script1 = SHFT:F1*DN}

Do not to assign the same shortcut to two different actions. If you do, neither will work.

You can create your own keyboard.txt files. In the example below, "MyKeyboardConfig" would appear in the Settings > Keyboard Configuration menu after MotionBuilder restart.

[Config]
Name = MyKeyboardConfig

Following are codes used in Keyboard\*.txt. See the existing keyboard files for examples of usage.

Note that a key is specified, and not a character. For example, on a standard American keyboard there is no "@" key, since this character is made by using the modifier key Shift+2.

Modifiers

Num lock

NUML

Division

NDIV

Subtraction

NSUB

Dot

NDEC

Numpad 0

N0

Numpad 1

N1

Numpad 2

N2

Numpad 3

N3

Numpad 4

N4

Numpad 5

N5

Numpad 6

N6

Numpad 7

N7

Numpad 8

N8

Numpad 9

N9

Keys

Tab

TAB

Caps Lock

CAPS

Backspace

BKSP

Left bracket

LBR

Right bracket

RBR

Semi-colon

SEMI

Return/Enter

ENTR

Space bar

SPC

Pause

PAUSE

Insert

INS

Home

HOME

Page Up

PGUP

Delete

DEL

End

END

Page Down

PGDN

Up Arrow

UP

Left Arrow

LEFT

Down Arrow

Down

Right Arrow

RGHT

Modifiers

Shift

SHFT

Control

CTRL

Alt

ALT

Alt+Control

ALCT

Alt+Shift

ALSH

Alt+Control+Shift

ALCTSH