Scripting¶
For riggers and TDs. Per-item Python and MEL, the variables they get, and the API for opening the window from your own tools.
Nothing here is required. A picker that only selects controls is a complete, useful picker — this section is for when you want it to do more.
-
Running Python or MEL when an item is clicked, the embedded editor, and per-item right-click menus.
-
The eight names injected into every item script — controls, namespace, the item itself, layers.
-
Am_picker.load(), making your own shelf button or menu entry, and the environment variables.
Three ways to add behaviour¶
| Approach | Reach for it when |
|---|---|
| Attribute control | The item should drive a rig attribute. Try this first — it needs no code and behaves consistently |
| A click script | The item should do something — reset a limb, run a studio tool, select a set |
| A right-click menu | The item should offer several commands without changing what a plain click does |
Prefer no code where no code will do
A script is a small program that lives inside a picker file, running in whatever Maya version somebody opens it in, years from now, with no test suite. Attribute control covers the common cases — blends, switches, spaces — declaratively, so those cases cannot rot.
Save the scripting for what actually needs it.
Safety¶
Scripts are stored inside the picker, and a picker is a file people pass
around. Treat an .ampkr from an unknown source the way you would treat any
other file containing executable code — clicking an item runs whatever the author
put in it.
Am_Picker will not run anything on its own: item scripts only run when an item is clicked, or when you press Test in the editor. Loading a picker executes nothing by itself.