2
$\begingroup$

I have an armature object with a single bone. Now I want to change the rest position for animation purposes.

The only way to manipulate bones I have found is via

arm_object.pose.bones

Anytime I change the position of a bone I get that way, for example with bone.rotation_euler = (0, 0, angle) it changes the pose but not the rest position.

$\endgroup$
3
$\begingroup$

You have to access Armature.edit_bones, but they can only be accessed from EditMode.

Example of moving all bones rest positions.

# This script assumes you have an active armature in 'Object Mode'

import bpy
from bpy import context

obj = context.object

bpy.ops.object.mode_set(mode='EDIT')

for bone in obj.data.edit_bones:
    bone.head.y += 1.0
    bone.tail.y += 1.0

bpy.ops.object.mode_set(mode='OBJECT')

Note: instead of manipulating the head/tail directly, it can be more convenient to use EditBone.transform so you can use a transformation matrix to rotate/scale/translate - all at once.

To transform the entire armature, use Armature.transform

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.