Ligamen

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(...)
ArgumentTypeDescription
namestrBone name.
parentstrParent bone.
world_startlistWorld [x,y] of the bone origin.
world_endlistWorld [x,y] of the bone tip (sets rotation+length).
xfloatLocal X in the parent's space.
yfloatLocal Y (Y is up).
rotationfloatLocal rotation, degrees, counter-clockwise.
lengthfloatBone length (setup only, not animatable).
scale_xfloatScale X (1 = none).
scale_yfloatScale Y (1 = none).
shear_xfloatShear X, degrees.
shear_yfloatShear Y, degrees.
colorstrBone color RRGGBBAA.
transformstrInherit 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, ...)
ArgumentTypeDescription
namestr(required) Bone.
new_namestrRename to.
parentstrNew parent.
keep_worldboolKeep world transform when reparenting (default true).
xfloatLocal X in the parent's space.
yfloatLocal Y (Y is up).
rotationfloatLocal rotation, degrees, counter-clockwise.
lengthfloatBone length (setup only, not animatable).
scale_xfloatScale X (1 = none).
scale_yfloatScale Y (1 = none).
shear_xfloatShear X, degrees.
shear_yfloatShear Y, degrees.
colorstrRRGGBBAA.
transformstrInherit 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, ...)
ArgumentTypeDescription
kindstr(required) What. One of: bone, slot, skin, animation, event, attachment, ik, transform.
nameslist(required) Names.
slotstrFor attachments.
skinstrFor 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, ...)
ArgumentTypeDescription
bonestr(required) Bone.
namestrSlot name.
draw_indexintPosition in draw order (0 = back).
colorstrRRGGBBAA.
blendstrBlend. 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, ...)
ArgumentTypeDescription
namestr(required) Slot.
new_namestrRename to.
bonestrMove to bone.
attachmentstr or None
colorstrRRGGBBAA.
darkstr or NoneTint black RRGGBB or null.
blendstrBlend. 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(...)
ArgumentTypeDescription
orderlistAll slots, back to front.
slotstrSlot to move.
indexint

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, ...)
ArgumentTypeDescription
slotstr(required) Slot.
typestrKind. One of: region, mesh, boundingbox, clipping, point, path.
imagestrImage name, relative, no extension.
namestrAttachment name.
skinstrSkin (default 'default').
xfloatOffset X.
yfloatOffset Y.
rotationfloatDegrees.
scale_xfloatScale X.
scale_yfloatScale Y.
widthfloatOverride width.
heightfloatOverride 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, ...)
ArgumentTypeDescription
slotstr(required) Slot.
namestr(required) Attachment.
skinstrSkin.
new_namestrRename to.
pathstrImage path.
xfloatX.
yfloatY.
rotationfloatDegrees.
scale_xfloatScale X.
scale_yfloatScale Y.
widthfloatWidth.
heightfloatHeight.
colorstrRRGGBBAA.

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, ...)
ArgumentTypeDescription
typestr(required) Kind. One of: ik, transform.
namestr(required) Name.
boneslist(required) Constrained bones.
targetstr(required) Target bone.
mixfloatIK mix 0..1.
bend_positiveboolIK bend direction.
softnessfloatIK softness.
compressboolIK compress.
stretchboolIK stretch.
mix_rotatefloat0..1
mix_xfloat0..1
mix_yfloat0..1
mix_scale_xfloat0..1
mix_scale_yfloat0..1
mix_shear_yfloat0..1
rotationfloatOffset.
xfloatOffset.
yfloatOffset.
localboolLocal space.
relativeboolRelative.
orderint

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, ...)
ArgumentTypeDescription
namestr(required) Constraint.
boneslistBones.
targetstrTarget.
mixfloatIK mix.
bend_positiveboolIK bend.
softnessfloatIK softness.
mix_rotatefloat0..1
mix_xfloat0..1
mix_yfloat0..1
mix_scale_xfloat0..1
mix_scale_yfloat0..1
mix_shear_yfloat0..1
localboolLocal.
relativeboolRelative.
orderint

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, ...)
ArgumentTypeDescription
namestr(required) Skin name.
duplicate_fromstrCopy this skin.
activateboolShow 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(...)
ArgumentTypeDescription
namestrAnimation name (default: the open one).
include_rawboolInclude 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(...)
ArgumentTypeDescription
animationstrAnimation to sample.
framefloatFrame at the project FPS (fractional allowed).
timefloatTime in seconds (alternative to frame).
setupboolForce the setup pose.
show_bonesboolOverlay the bones.
skinslistSkins to show (default: active).
widthint
heightint
zoomfloatExtra zoom factor over 'frame all'.
backgroundstrBackground. One of: white, gray, transparent.
pathstrAlso 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(...)
ArgumentTypeDescription
folderstrAnother 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)
ArgumentTypeDescription
idstr(required) Skill id, e.g. 'ligamen-basics'.

Example

print(lg.query.get_skill(id="ligamen-basics"))