Ligamen

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#

SectionPageCommands
lg.fileFiles and pipeline17
lg.pipelineFiles and pipeline2
lg.projectFiles and pipeline5
lg.importerFiles and pipeline4
lg.exporterFiles and pipeline4
lg.editEditing and selection21
lg.historyEditing and selection1
lg.selectEditing and selection22
lg.viewView panels and modes13
lg.viewportView panels and modes2
lg.modeView panels and modes4
lg.layoutView panels and modes4
lg.panelView panels and modes20
lg.helpView panels and modes5
lg.toolTools and meshes11
lg.meshTools and meshes2
lg.skinTools and meshes3
lg.animAnimation21
lg.animationAnimation5
lg.rigRig and queries11
lg.queryRig and queries8