hello everyone, im new here
i would like to change the head position of the bones by names
example:
clacicle_l
bpy.context.active_bone.head[0] = 3.782
clacicle_r
bpy.context.active_bone.head[0] = 2.500
hello everyone, im new here
i would like to change the head position of the bones by names
example:
clacicle_l
bpy.context.active_bone.head[0] = 3.782
clacicle_r
bpy.context.active_bone.head[0] = 2.500
I think the below script should provide enough of an example for you to follow.
import bpy
from mathutils import Vector
b_name = "forearm.L"
b_pos = Vector((1,1,1))
obj = bpy.context.active_object
# use selected active object if object is an armature
if obj.type == 'ARMATURE'and obj in bpy.context.selected_objects:
arm = obj
else:
arm = None
# set positoin of edit bone head
if arm:
ori_mode = bpy.context.mode
bpy.ops.object.mode_set(mode = 'EDIT')
my_bone = arm.data.edit_bones.get(b_name)
if my_bone:
my_bone.head = b_pos
bpy.ops.object.mode_set(mode = ori_mode)
else:
print("No active armature")