So im facing issue with my python code which is as follows.
objects= ["sphere","cube"]
c_frames=60
for k in objects:
bpy.data.objects[str(k)].select_set(True)
bpy.context.view_layer.objects.active=bpy.data.objects[str(k)]
obj = bpy.context.view_layer.objects.active
obj.keyframe_insert("rotation_euler",frame=c_frame)
bpy.ops.transform.rotate(value=0.151266, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SPHERE', proportional_size=0.318631, use_proportional_connected=False, use_proportional_projected=False)
obj.keyframe_insert("rotation_euler",frame=(c_frame+5))
obj.keyframe_insert("rotation_euler",frame=c_frame+5+10)
bpy.ops.transform.rotate(value=-0.151266, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SPHERE', proportional_size=0.318631, use_proportional_connected=False, use_proportional_projected=False)
obj.keyframe_insert("rotation_euler",frame=c_frame+5+10+5)
For this code blender is selecting both the objects but is creating keyframes only for the cube but not for the sphere. I want the code to create keyframes for all the objects in the list. Kindly let me know what it is that i'm doing wrong, and what is the way to go about it. Thank you.
bpy.data.objects[obj_name]bybpy.context.scene.objects.get(obj_name), related: https://blender.stackexchange.com/questions/132825/python-selecting-object-by-name-in-2-8/132829#132829 and I'd suggest get rid of the transform operator if possible, then you don't have to set the active object. How to insert rotation keyframes propperly: https://blender.stackexchange.com/a/60238/31447 – brockmann Jul 11 '20 at 21:16