Sub topic 10
IK Limits and Locks on Individual Bones
Assume you already have an armature with an IK constraint on a two-bone arm. You should also know how to enter Pose Mode and identify a bone's local X, Y, and Z axes. This chapter focuses on restricting the bones that the IK solver controls.
Why IK Limits Matter
An IK solver finds rotations that place a chain at a target. Without restrictions, it may choose a physically strange solution. An elbow might bend backward, twist around the arm, or rotate on several axes when it should act like a hinge.
IK locks and IK limits constrain the solver while it searches:
- An IK lock prevents rotation around a local axis.
- An IK limit gives an allowed minimum and maximum rotation on a local axis.
- A limit applies to a bone during IK solving, not just to the final visible pose.
For an elbow, lock the local Y and Z axes, then allow only local X rotation. The result is a hinge-like joint.
import math
import bpy
rig = bpy.data.objects.get("ArmRig")
if rig is None or "forearm" not in rig.pose.bones:
raise RuntimeError("Create an ArmRig object with a forearm pose bone first")
forearm = rig.pose.bones["forearm"]
forearm.rotation_mode = "XYZ"
# Let the elbow bend only around its local X axis.
forearm.lock_ik_y = True
forearm.lock_ik_z = True
forearm.use_ik_limit_x = True
forearm.ik_min_x = 0.0
forearm.ik_max_x = math.radians(150.0)The lock_ik_* properties affect the IK solver. They do not necessarily prevent another constraint or a direct pose edit from changing the bone. This difference explains why an apparent lock can seem to fail.
IK Limits and Limit Rotation
A Limit Rotation constraint is a separate constraint. It clamps the bone's rotation during constraint evaluation. Use it as a final guard when the result must stay within a range for IK, FK, or another driver.
| Tool | Main purpose | Affects |
|---|---|---|
| IK lock | Remove an axis from IK solving | IK solution |
| IK limit | Restrict an axis during IK solving | IK solution |
| Limit Rotation | Clamp a constrained pose | Constraint result |
For a final elbow safeguard, add a local-space Limit Rotation constraint:
limit = forearm.constraints.get("Elbow Rotation Guard")
if limit is None:
limit = forearm.constraints.new("LIMIT_ROTATION")
limit.name = "Elbow Rotation Guard"
limit.owner_space = "LOCAL"
limit.use_limit_x = True
limit.min_x = 0.0
limit.max_x = math.radians(150.0)
limit.use_limit_y = True
limit.min_y = 0.0
limit.max_y = 0.0
limit.use_limit_z = True
limit.min_z = 0.0
limit.max_z = 0.0Place this constraint after the IK constraint when you want it to guard the IK result. Constraint order is evaluated from top to bottom, so inspect the stack if a later constraint appears to undo the restriction.
Exercise
An elbow bends backward even though the target is in front of the character. What should you check first?
Show answer
Check the pole target and the bone's local axes. Then lock the unwanted IK axes and set a local bend range with an IK limit.