So I’m(noob in blender) trying to make a script that reads points and makes an animation for armature. I was thinking I can change edit_bones tail and head location and make framekeys for location, rotation and scale for armature.pose.bones, but it didn’t work for me. Is it even posible or there is another way to animate bones from script?
My code look like this:
import bpy
def set_edit_mode(check = True):
if check:
if bpy.context.active_object.mode == 'OBJECT':
bpy.ops.object.editmode_toggle()
else:
if bpy.context.active_object.mode == 'EDIT':
bpy.ops.object.editmode_toggle()
armature = bpy.data.objects['Armature']
armature.select_set(True)
armData = armature.data
set_edit_mode()
ebone = armData.edit_bones['Bone']
pbone = armature.pose.bones['Bone']
bpy.context.scene.frame_current = 0
ebone.tail = (0,0,1)
ebone.head = (0,0,0)
pbone.keyframe_insert('location', frame = 0)
pbone.keyframe_insert('rotation_euler', frame = 0)
pbone.keyframe_insert('scale', frame = 0)
bpy.context.scene.frame_current = 60
ebone.tail = (1,1,1)
ebone.head = (-1,-1,-1)
pbone.keyframe_insert('location', frame = 60)
pbone.keyframe_insert('rotation_euler', frame = 60)
pbone.keyframe_insert('scale', frame = 60)
It’s for one bone and no animation’s being made.
I think the location might be of an armature but why? Can some one help me?