Commands
Rig and queries
This page describes 19 commands in 2 sections. How to call them is explained in Commands.
Rig#
Create and edit bones, slots, attachments, constraints and skins; delete objects.
lg.rig.create_bone#
Create a bone. Either local values (x,y,rotation,length relative to the parent) or world_start/world_end points (drawn like the Create tool). Parent defaults to the root bone.
Synopsis
lg.rig.create_bone(...)
| Argument | Type | Description |
|---|---|---|
name | str | Bone name. |
parent | str | Parent bone. |
world_start | list | World [x,y] of the bone origin. |
world_end | list | World [x,y] of the bone tip (sets rotation+length). |
x | float | Local X in the parent's space. |
y | float | Local Y (Y is up). |
rotation | float | Local rotation, degrees, counter-clockwise. |
length | float | Bone length (setup only, not animatable). |
scale_x | float | Scale X (1 = none). |
scale_y | float | Scale Y (1 = none). |
shear_x | float | Shear X, degrees. |
shear_y | float | Shear Y, degrees. |
color | str | Bone color RRGGBBAA. |
transform | str | Inherit mode. One of: normal, onlyTranslation, noRotationOrReflection, noScale, noScaleOrReflection. |
Example
lg.rig.create_bone(name="arm", parent="root", x=20, y=0, rotation=90, length=60)
lg.rig.edit_bone#
Edit a bone's setup pose / parent / name. Changing parent keeps the world position unless keep_world=false.
Synopsis
lg.rig.edit_bone(name, ...)
| Argument | Type | Description |
|---|---|---|
name | str | (required) Bone. |
new_name | str | Rename to. |
parent | str | New parent. |
keep_world | bool | Keep world transform when reparenting (default true). |
x | float | Local X in the parent's space. |
y | float | Local Y (Y is up). |
rotation | float | Local rotation, degrees, counter-clockwise. |
length | float | Bone length (setup only, not animatable). |
scale_x | float | Scale X (1 = none). |
scale_y | float | Scale Y (1 = none). |
shear_x | float | Shear X, degrees. |
shear_y | float | Shear Y, degrees. |
color | str | RRGGBBAA. |
transform | str | Inherit mode. |
Example
lg.rig.edit_bone(name="arm", rotation=45, length=80)
lg.rig.delete#
Delete bones/slots/skins/animations/events/attachments/constraints. Deleting a bone re-parents its children.
Synopsis
lg.rig.delete(kind, names, ...)
| Argument | Type | Description |
|---|---|---|
kind | str | (required) What. One of: bone, slot, skin, animation, event, attachment, ik, transform. |
names | list | (required) Names. |
slot | str | For attachments. |
skin | str | For attachments (default 'default'). |
Example
lg.rig.delete(kind="bone", names=["arm"])
lg.rig.create_slot#
Create a slot on a bone (a draw layer that shows one attachment).
Synopsis
lg.rig.create_slot(bone, ...)
| Argument | Type | Description |
|---|---|---|
bone | str | (required) Bone. |
name | str | Slot name. |
draw_index | int | Position in draw order (0 = back). |
color | str | RRGGBBAA. |
blend | str | Blend. One of: normal, additive, multiply, screen. |
Example
lg.rig.create_slot(name="arm_img", bone="arm", blend="normal")
lg.rig.edit_slot#
Edit a slot: bone, visible attachment (null hides), color, dark, blend, name.
Synopsis
lg.rig.edit_slot(name, ...)
| Argument | Type | Description |
|---|---|---|
name | str | (required) Slot. |
new_name | str | Rename to. |
bone | str | Move to bone. |
attachment | str or None | |
color | str | RRGGBBAA. |
dark | str or None | Tint black RRGGBB or null. |
blend | str | Blend. One of: normal, additive, multiply, screen. |
Example
lg.rig.edit_slot(name="arm_img", color="ffffff80")
lg.rig.set_draw_order#
Setup draw order: full 'order' (back to front) or move one 'slot' to 'index'.
Synopsis
lg.rig.set_draw_order(...)
| Argument | Type | Description |
|---|---|---|
order | list | All slots, back to front. |
slot | str | Slot to move. |
index | int |
Example
lg.rig.set_draw_order(slot="arm_img", index=0)
lg.rig.create_attachment#
Add an attachment to a slot and make it visible. type=region|mesh need 'image' (see lg.query.list_images; size read from the file); boundingbox|clipping|point create a default shape. Offsets are in the slot bone's space.
Synopsis
lg.rig.create_attachment(slot, ...)
| Argument | Type | Description |
|---|---|---|
slot | str | (required) Slot. |
type | str | Kind. One of: region, mesh, boundingbox, clipping, point, path. |
image | str | Image name, relative, no extension. |
name | str | Attachment name. |
skin | str | Skin (default 'default'). |
x | float | Offset X. |
y | float | Offset Y. |
rotation | float | Degrees. |
scale_x | float | Scale X. |
scale_y | float | Scale Y. |
width | float | Override width. |
height | float | Override height. |
Example
lg.rig.create_attachment(slot="arm_img", type="region", image="arm")
lg.rig.edit_attachment#
Edit an attachment's placement, size, image path, color or name.
Synopsis
lg.rig.edit_attachment(slot, name, ...)
| Argument | Type | Description |
|---|---|---|
slot | str | (required) Slot. |
name | str | (required) Attachment. |
skin | str | Skin. |
new_name | str | Rename to. |
path | str | Image path. |
x | float | X. |
y | float | Y. |
rotation | float | Degrees. |
scale_x | float | Scale X. |
scale_y | float | Scale Y. |
width | float | Width. |
height | float | Height. |
color | str | RRGGBBAA. |
Example
lg.rig.edit_attachment(slot="arm_img", name="arm", x=5, scale_x=1.2)
lg.rig.create_constraint#
Create an IK (1 bone, or 2 bones parent->child, aimed at 'target') or transform constraint (bones copy target's transform by mixes 0..1).
Synopsis
lg.rig.create_constraint(type, name, bones, target, ...)
| Argument | Type | Description |
|---|---|---|
type | str | (required) Kind. One of: ik, transform. |
name | str | (required) Name. |
bones | list | (required) Constrained bones. |
target | str | (required) Target bone. |
mix | float | IK mix 0..1. |
bend_positive | bool | IK bend direction. |
softness | float | IK softness. |
compress | bool | IK compress. |
stretch | bool | IK stretch. |
mix_rotate | float | 0..1 |
mix_x | float | 0..1 |
mix_y | float | 0..1 |
mix_scale_x | float | 0..1 |
mix_scale_y | float | 0..1 |
mix_shear_y | float | 0..1 |
rotation | float | Offset. |
x | float | Offset. |
y | float | Offset. |
local | bool | Local space. |
relative | bool | Relative. |
order | int |
Example
lg.rig.create_constraint(type="ik", name="arm_ik", bones=["upper", "lower"], target="hand_target", mix=1)
lg.rig.edit_constraint#
Edit an IK/transform constraint's bones, target, mixes, flags, order.
Synopsis
lg.rig.edit_constraint(name, ...)
| Argument | Type | Description |
|---|---|---|
name | str | (required) Constraint. |
bones | list | Bones. |
target | str | Target. |
mix | float | IK mix. |
bend_positive | bool | IK bend. |
softness | float | IK softness. |
mix_rotate | float | 0..1 |
mix_x | float | 0..1 |
mix_y | float | 0..1 |
mix_scale_x | float | 0..1 |
mix_scale_y | float | 0..1 |
mix_shear_y | float | 0..1 |
local | bool | Local. |
relative | bool | Relative. |
order | int |
Example
lg.rig.edit_constraint(name="arm_ik", mix=0.5, bend_positive=False)
lg.rig.create_skin#
Create a skin (optionally a copy of another) and activate it.
Synopsis
lg.rig.create_skin(name, ...)
| Argument | Type | Description |
|---|---|---|
name | str | (required) Skin name. |
duplicate_from | str | Copy this skin. |
activate | bool | Show it (default true). |
Example
lg.rig.create_skin(name="red", duplicate_from="default")
Query#
Read the state of the editor and the rig without changing anything.
lg.query.snapshot#
Current editor state: project, mode, open animation/frame, fps, selection, skins, dirty flag, undo/redo labels. Call first.
Synopsis
lg.query.snapshot()
Example
state = lg.query.snapshot()
print(state)
lg.query.get_skeleton#
Full rig: bones (setup local values + world position/tip), slots in draw order, skins with attachments, IK/transform constraints, events, animation list. Use it to learn bone names before rigging or animating.
Synopsis
lg.query.get_skeleton()
Example
rig = lg.query.get_skeleton()
print([b['name'] for b in rig['bones']])
lg.query.get_animation#
Keys of one animation: per bone/slot/constraint which frames are keyed, plus raw Spine timelines (seconds, offsets from setup).
Synopsis
lg.query.get_animation(...)
| Argument | Type | Description |
|---|---|---|
name | str | Animation name (default: the open one). |
include_raw | bool | Include raw timelines (default true). |
Example
lg.query.get_animation(name="walk", include_raw=False)
lg.query.render#
Render the character to a PNG you can look at. Setup pose by default; pass animation+frame for a pose in an animation. Use after every meaningful edit to check the result visually.
Synopsis
lg.query.render(...)
| Argument | Type | Description |
|---|---|---|
animation | str | Animation to sample. |
frame | float | Frame at the project FPS (fractional allowed). |
time | float | Time in seconds (alternative to frame). |
setup | bool | Force the setup pose. |
show_bones | bool | Overlay the bones. |
skins | list | Skins to show (default: active). |
width | int | |
height | int | |
zoom | float | Extra zoom factor over 'frame all'. |
background | str | Background. One of: white, gray, transparent. |
path | str | Also save the PNG here. |
Example
lg.query.render(animation="walk", frame=12, path="/tmp/walk12.png")
lg.query.validate#
Structural check (broken references, cycles) plus missing images. Run before exporting.
Synopsis
lg.query.validate()
Example
print(lg.query.validate())
lg.query.list_images#
Images available for attachments in the project's images folder (names without extension, pixel sizes).
Synopsis
lg.query.list_images(...)
| Argument | Type | Description |
|---|---|---|
folder | str | Another folder to list instead. |
Example
print(lg.query.list_images())
lg.query.list_skills#
Reference guides for animating with these tools (built-in ones plus the user's and the project's own) (id, name, one-line description) - e.g. workflow habits, rig naming conventions, how to build a walk cycle. Call lg.query.get_skill for the full text of one.
Synopsis
lg.query.list_skills()
Example
print(lg.query.list_skills())
lg.query.get_skill#
Full text of one built-in skill by id (see lg.query.list_skills).
Synopsis
lg.query.get_skill(id)
| Argument | Type | Description |
|---|---|---|
id | str | (required) Skill id, e.g. 'ligamen-basics'. |
Example
print(lg.query.get_skill(id="ligamen-basics"))