Managing Python Tools
 
 
 

Python Tool Manager

The Python Tool Manager is a dialog containing a button for each running Python tool. It uses functionality in pyfbsdk_additions to listen for Python tools being created or destroyed and updates the buttons accordingly. To open the Tool Manager, click Tool Manager tool in the Python Editor. The Tool Manager script is itself a Python tool and is found in config\Python.

If you close the tool by using the X button in the right corner, use the Tool Manager to restart it.

You can write your own tool manager. See the ToolManager.py script for details.

Binding Keyboard Shortcuts to a Python Tool

There are two types of Python shortcuts:

You can create up to 12 global shortcuts that can be mapped to scripts. Some shortcuts are already mapped by default. For example, Shift+F1 is bound to the execution of NewCamera.py. Pressing Shift+F1 from the MotionBuilder interface will therefore create a new camera.

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:

Files in config\Keyboard\ map the keyboard shortcuts to their respective script name. 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.

Numpad Modifiers

Key Name Code
Num lock NUML
Division NDIV
Subtraction NSUB
Decimal point 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

Keyboard Modifiers

Key Name Code
Shift SHFT
Ctrl CTRL
Alt ALT
Alt+Ctrl ALCT
Alt+Shift ALSH
Alt+Control+Shift ALCTSH

Keyboard Keys

Key Name Code
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
Page Down PGDN
Delete DEL
End END
Up Arrow UP
Left Arrow LEFT
Down Arrow DOWN
Right Arrow RGHT