CGMatter

Animation to CSV

Aug 30th, 2026
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | Source Code | 0 0
  1. #This script exports selected object's animation as a .csv
  2. import bpy, csv, os
  3.  
  4. obj = bpy.context.active_object
  5. scene = bpy.context.scene
  6. path = os.path.join(os.path.dirname(bpy.data.filepath), obj.name + "_positions.csv")
  7.  
  8. with open(path, "w", newline="") as f:
  9.     writer = csv.writer(f)
  10.     writer.writerow(["frame", "index", "x", "y", "z"])
  11.     for frame in range(scene.frame_start, scene.frame_end + 1):
  12.         scene.frame_set(frame)
  13.         eval_obj = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
  14.         mesh = eval_obj.to_mesh()
  15.         for i, v in enumerate(mesh.vertices):
  16.             writer.writerow([frame, i, *(eval_obj.matrix_world @ v.co)])
  17.         eval_obj.to_mesh_clear()
Advertisement
Add Comment
Please, Sign In to add comment