Sub topic 11
Limit Rotation, Location, and Distance Constraints
Assume you can create an armature, switch to Pose Mode, and add basic bone constraints. This chapter focuses on three constraints that keep a pose within useful bounds:
- Limit Rotation restricts a bone’s rotation.
- Limit Location restricts a bone’s local movement.
- Limit Distance keeps a bone at a chosen distance from a target.
These constraints are useful after IK or other constraints have produced a pose. They prevent impossible elbow bends, controls moving too far from a rig, and targets drifting outside a permitted area.
How the Constraints Work
A constraint has an owner, which is the bone receiving the constraint, and sometimes a target. The owner space defines how Blender measures the owner’s transform. Local space is usually best for joint limits because it follows the bone’s rest orientation. World space is useful when a control must stay within a fixed scene region.
Blender evaluates constraints from top to bottom in the constraint stack. A later constraint receives the result of earlier constraints. Its influence then blends its effect with the incoming pose.
| Constraint | Main purpose | Typical use |
|---|---|---|
| Limit Rotation | Clamps angular movement | Keep an elbow from bending backward |
| Limit Location | Clamps local translation | Keep a control inside a small handle range |
| Limit Distance | Restricts separation from a target | Keep a hand control near a wrist control |
Setting Rotation and Location Limits
For Limit Rotation, enable each axis that should be restricted and provide minimum and maximum angles. The values use radians in Python. In the Blender interface, they appear as degrees.
Limit Location works similarly. Enable a minimum or maximum for each axis. Because a pose bone’s location is normally relative to its parent, local space makes the limit follow the bone hierarchy.
import bpy
import math
rig = bpy.data.objects["ArmRig"]
bone = rig.pose.bones["forearm"]
rotation = bone.constraints.new("LIMIT_ROTATION")
rotation.name = "Elbow rotation limit"
rotation.owner_space = "LOCAL"
rotation.use_limit_x = True
rotation.min_x = 0.0
rotation.max_x = math.radians(150)
rotation.use_limit_y = True
rotation.min_y = 0.0
rotation.max_y = 0.0
rotation.use_limit_z = True
rotation.min_z = 0.0
rotation.max_z = 0.0
location = bone.constraints.new("LIMIT_LOCATION")
location.name = "Small local movement limit"
location.owner_space = "LOCAL"
location.use_min_x = True
location.min_x = -0.1
location.use_max_x = True
location.max_x = 0.1
location.use_min_y = True
location.min_y = -0.1
location.use_max_y = True
location.use_min_z = True
location.min_z = 0.1
location.use_max_z = True
location.max_z = 0.3Limiting Distance from a Target
Limit Distance needs a target object or bone. Its modes have different meanings:
- Inside keeps the owner within the specified distance.
- Outside keeps the owner beyond that distance.
- On Surface keeps the owner exactly on the distance boundary.
For example, an arm control can remain within 2 Blender units of a shoulder control. Use world space when the distance should not change with parent transforms.
distance = bone.constraints.new("LIMIT_DISTANCE")
distance.target = rig
distance.subtarget = "shoulder_control"
distance.distance = 2.0
distance.limit_mode = "LIMITDIST_INSIDE"
distance.owner_space = "WORLD"
distance.target_space = "WORLD"Exercise
An elbow bends backward after IK solves the arm. Which constraint should you add first, and which space is usually appropriate?
Show answer
Add Limit Rotation to the elbow bone, enable the joint’s allowed local axis, and use Local owner space.