Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import bpy
  2. from pathlib import Path
  3.  
  4. interval = 100
  5. paths = sorted([str(path) for path in Path.cwd().glob('*.ply')])
  6.  
  7. scene = bpy.context.scene
  8. scene.frame_start = 0
  9. scene.frame_end = len(paths) * interval
  10. scene.frame_current = 0
  11. bpy.ops.object.select_all(action='DESELECT')
  12.  
  13. for i, path in enumerate(paths):
  14. bpy.ops.import_mesh.ply(filepath=path)
  15. next_obj = bpy.context.object
  16. if i == 0:
  17. base_obj = next_obj
  18. base_obj.select = True
  19. continue
  20.  
  21. scene.objects.active = base_obj
  22. bpy.ops.object.join_shapes()
  23.  
  24. key_blocks = bpy.data.meshes[base_obj.data.name].shape_keys.key_blocks
  25. key_block = key_blocks[-1]
  26. key_block.value = 0.0
  27. key_block.keyframe_insert(data_path='value')
  28. scene.frame_current = i * interval
  29. for kb in key_blocks:
  30. kb.value = 0.0
  31. kb.keyframe_insert(data_path='value')
  32. key_block.value = 1.0
  33. key_block.keyframe_insert(data_path='value')
  34.  
  35. # Delete next obj
  36. bpy.ops.object.select_all(action='DESELECT')
  37. next_obj.select = True
  38. bpy.ops.object.delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement