Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- #save the total number of frames as var
- frames = bpy.context.scene.frame_end + 1
- #loop through frames, jump to each frame, add the armature, set as shapekey
- for frame in range(frames):
- bpy.context.scene.frame_set(frame)
- bpy.ops.object.modifier_add(type='ARMATURE')
- bpy.context.object.modifiers["Armature"].object = bpy.data.objects["rig"]
- bpy.ops.object.modifier_apply(apply_as='SHAPE', modifier="Armature")
- #for each frame, loop through shapekeys and add as keyframe per frame, set value to 1 if current frame = corresponding shapekey
- for frame in range(frames):
- for shapekey in bpy.data.shape_keys:
- for i, keyblock in enumerate(shapekey.key_blocks):
- if keyblock.name != 'Basis':
- curr = i - 1
- if curr != frame:
- keyblock.value = 0
- keyblock.keyframe_insert("value", frame=frame)
- else:
- keyblock.value = 1
- keyblock.keyframe_insert("value", frame=frame)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement