0
$\begingroup$

I tried to animate simple bones with python, keyframes are inserted in timeline but nothing happens, Partially this question is copy-paste of that one (sorry) but I didn't find answer there

Controlling armature through python

import bpy

import math
import mathutils
from mathutils import Euler

rig = bpy.data.objects['Armature']
bone = rig.pose.bones['Bone.00']
print("temp", rig)

rot = math.radians(5)
bone.rotation_euler = Euler((rot, rot, rot))
bone.keyframe_insert('rotation_euler', frame=1)

rot2 = math.radians(100)
bone.rotation_euler = Euler((rot2, rot2,rot2 ))
bone.keyframe_insert('rotation_euler', frame =50)  

enter image description here

UPDATE: After running few times and removing previous keyframe animation is still cached somewhere how to clear it ?

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ By default bone rotation mode is set to Quaternion. Either chage it to Euler or use bone.rotation_quaternion $\endgroup$
    – JayReigns
    Commented Oct 6, 2023 at 17:09
  • 1
    $\begingroup$ @JayReigns Thanks! $\endgroup$ Commented Oct 6, 2023 at 20:41

0

You must log in to answer this question.

Browse other questions tagged .