3
$\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$

1 Answer 1

4
$\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$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .