Share

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:

  • Shortcuts which apply from within the Python editor, e.g. F5 to execute the current script, or F10 to launch the tool manager.
  • Global shortcuts which can be used to access Python scripts from anywhere in MotionBuilder.

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:

  • Relative to the location of ActionScript.txt, e.g. ..\myScript.py
  • An absolute path, e.g. c:\scripts\myScript.py.
  • A path to a server, e.g. \\someserver\scripts\myScript.py.

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 NameCode
Num lockNUML
DivisionNDIV
SubtractionNSUB
Decimal pointNDEC
Numpad 0N0
Numpad 1N1
Numpad 2N2
Numpad 3N3
Numpad 4N4
Numpad 5N5
Numpad 6N6
Numpad 7N7
Numpad 8N8
Numpad 9N9

Keyboard Modifiers

Key NameCode
ShiftSHFT
CtrlCTRL
AltALT
Alt+CtrlALCT
Alt+ShiftALSH
Alt+Control+ShiftALCTSH

Keyboard Keys

Key NameCode
TabTAB
Caps LockCAPS
BackspaceBKSP
Left BracketLBR
Right BracketRBR
Semi-colonSEMI
Return/EnterENTR
Space BarSPC
PausePAUSE
InsertINS
HomeHOME
Page UpPGUP
Page DownPGDN
DeleteDEL
EndEND
Up ArrowUP
Left ArrowLEFT
Down ArrowDOWN
Right ArrowRGHT

Was this information helpful?