I need a python script to add a dummy keyframe to all shapekeys at one particular frame... Pls anyone can help me...
1 Answer
$\begingroup$
$\endgroup$
3
Insert keyframes to all shapekey values
for active object:
import bpy
def add_all_keyframe(obj, attr="value", frame=1):
if obj.type != 'MESH': return
blocks = obj.data.shape_keys.key_blocks
if not blocks: return
for k in blocks:
k.keyframe_insert(attr, frame=frame)
add_all_keyframe(bpy.context.object)
bpy.context.scene.frame_set(bpy.context.scene.frame_current) #update ui
for selected object:
import bpy
def add_all_keyframe(obj, attr="value", frame=1):
if obj.type != 'MESH': return
blocks = obj.data.shape_keys.key_blocks
if not blocks: return
for k in blocks:
k.keyframe_insert(attr, frame=frame)
for obj in bpy.context.selected_objects:
add_all_keyframe(obj)
bpy.context.scene.frame_set(bpy.context.scene.frame_current) #update ui
-
$\begingroup$ Thanks for quick response & solution... $\endgroup$ Commented Aug 7, 2022 at 13:18
-
$\begingroup$ In second case In line 8 can I change to for obj in bpy.data.selected.objects: to insert keyframe only to selected object? $\endgroup$ Commented Aug 7, 2022 at 13:25
-
$\begingroup$ @RadhakrishnaRao Hello and welcome. This site is not a regular forum, the answer section is reserved exclusively for answering the OP question, to post comments or replies please use the comments section instead. Please don't reply "Thanks" as an answer or comment, instead upvote the post that helped you. If you feel it completely solved your issue consider marking it as accepted. $\endgroup$ Commented Aug 7, 2022 at 14:07