Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import bpy
  2.  
  3. #save the total number of frames as var
  4. frames = bpy.context.scene.frame_end + 1
  5.  
  6. #loop through frames, jump to each frame, add the armature, set as shapekey
  7. for frame in range(frames):
  8. bpy.context.scene.frame_set(frame)
  9. bpy.ops.object.modifier_add(type='ARMATURE')
  10. bpy.context.object.modifiers["Armature"].object = bpy.data.objects["rig"]
  11. bpy.ops.object.modifier_apply(apply_as='SHAPE', modifier="Armature")
  12.  
  13. #for each frame, loop through shapekeys and add as keyframe per frame, set value to 1 if current frame = corresponding shapekey
  14. for frame in range(frames):
  15. for shapekey in bpy.data.shape_keys:
  16. for i, keyblock in enumerate(shapekey.key_blocks):
  17. if keyblock.name != 'Basis':
  18. curr = i - 1
  19. if curr != frame:
  20. keyblock.value = 0
  21. keyblock.keyframe_insert("value", frame=frame)
  22. else:
  23. keyblock.value = 1
  24. keyblock.keyframe_insert("value", frame=frame)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement