Hello , I would like in my code below, how to obtain the location, scale and rotation of all the bones in Amature at different keyframe in animation .
def writeAnimArmarture(ident , obj, amature , world):
obj_id = quoteattr(unique_name(amature, OB_ + amature.name, uuid_cache_object, clean_func=clean_def, sep="_"))
keyframe_data = {} # table of all information of bone ( name , frame , type( location , rotate , scale) and coordinate)
nombre_iteration =0
nombre_iteration_scale= 0
nombre_iteration_rotation=0
data = {}
if amature.animation_data.action != None:
scene=bpy.data.scenes
for fc in amature.animation_data.action.fcurves:
data_path = fc.data_path
for key in fc.keyframe_points :
frame = key.co.x
for joint in amature.data.bones:
if not joint.name.endswith("_end"):
bones_name = joint.name
array_index = fc.array_index
if bones_name not in keyframe_data:
keyframe_data[bones_name] = {}
#for posebones in amature.pose.bones:
# if posebones.name =='brasD':
# print("les posesbones :" ,posebones.rotation_quaternion)
if frame not in keyframe_data[bones_name]:
keyframe_data[bones_name][frame] = {
'location': obj.pose.bones[bones_name].location.copy(),
'rotation': obj.pose.bones[bones_name].rotation_quaternion.copy(),
'scale': obj.pose.bones[bones_name].scale.copy()
}
if 'location' in data_path and bones_name in data_path:
nombre_iteration= nombre_iteration+1
name_type = 'location'
keyframe_data[bones_name][frame]['location'][array_index] = key.co.y
#print( "le key.co.y pour location est : ",key.co.y , "pour le bone : ", bones_name)
elif 'rotation_quaternion' in data_path and bones_name in data_path:
nombre_iteration_rotation= nombre_iteration_rotation+1
name_type = 'rotation'
keyframe_data[bones_name][frame]['rotation'][array_index] = key.co.y
#if bones_name == 'brasD':
# print( "le key.co.y pour rotation est : ",key.co , " pour le bone : ", bones_name)
elif 'scale' in data_path and bones_name in data_path:
nombre_iteration_scale= nombre_iteration_scale+1
name_type = 'scale'
keyframe_data[bones_name][frame]['scale'][array_index] = key.co.y
With this code , i get a table of all bones but the coordinate of this not changed , for example at frame 90 , the bone “brasD” have a value rotation_quaterion(w=1,x=0,y=0,z=1) but in this table , the value is rotation_quaterion(w=1 , x=0, y=0 , z=0).