Commands
Commands
Every command of the editor can be called from a script. The object lg is in the scope of every script and of the console in the Scripts panel, next to api: lg.file.save() does what File → Save does, and lg.rig.create_bone(name="arm", parent="root") creates a bone. The commands are grouped in sections, as in the menus, and this chapter lists them all with a short description and the shortest example for the script editor.
How to call a command#
A command is lg.<section>.<command>(...). In the script editor, type lg. and the editor offers the sections and commands with their descriptions; the API list in the sidebar shows the same commands grouped by section, and a double click inserts one at the cursor.
lg.view.frame_all()
lg.rig.create_bone(name="arm", parent="root", length=60)
Two kinds of commands#
Editor actions are the items of the menus, the tools, the playback controls and the panels: what a hotkey does. They take no arguments. A toggle (a command marked in the tables as a switch, such as lg.view.show_rulers) is set with True or False and flipped when called without an argument. A command whose name in the menu ends with three dots opens a dialog and waits for you, so use it in the console rather than in a script that must run unattended. A disabled action, for example one that needs a selected bone, raises LigamenCommandError.
Rig tools edit the project and read it: create bones, slots, skins and constraints, write keys, import and export. They take named arguments, return a dictionary with the result and raise LigamenCommandError when the tool refuses the arguments. Every call is one undo step named AI: …, so Ctrl+Z returns it, and it is subject to the permissions of the AI assistant in Settings.
Finding a command#
In the console, lg.sections() lists the sections, lg.commands("rig") the commands of one, lg.search("bone") finds commands by a word and lg.help("rig.create_bone") prints the description with the arguments. lg.run("file.save") runs an action by its id, and lg.call("ligamen_create_bone", name="arm") calls a tool by its full name. Scripting itself is explained in Scripting.
lg.sections()
lg.commands("rig")
lg.search("bone")
lg.help("rig.create_bone")
Sections#
| Section | Page | Commands |
|---|---|---|
lg.file | Files and pipeline | 17 |
lg.pipeline | Files and pipeline | 2 |
lg.project | Files and pipeline | 5 |
lg.importer | Files and pipeline | 4 |
lg.exporter | Files and pipeline | 4 |
lg.edit | Editing and selection | 21 |
lg.history | Editing and selection | 1 |
lg.select | Editing and selection | 22 |
lg.view | View panels and modes | 13 |
lg.viewport | View panels and modes | 2 |
lg.mode | View panels and modes | 4 |
lg.layout | View panels and modes | 4 |
lg.panel | View panels and modes | 20 |
lg.help | View panels and modes | 5 |
lg.tool | Tools and meshes | 11 |
lg.mesh | Tools and meshes | 2 |
lg.skin | Tools and meshes | 3 |
lg.anim | Animation | 21 |
lg.animation | Animation | 5 |
lg.rig | Rig and queries | 11 |
lg.query | Rig and queries | 8 |