Last active
April 29, 2023 06:04
-
-
Save CGLion/229606949d13ce89a51bc9b56626cbe3 to your computer and use it in GitHub Desktop.
Python for Blender - access mesh animated vertices location data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
obj = bpy.context.active_object | |
frames = range(0,10) | |
# get the object's evaluated dependency graph: | |
depgraph = bpy.context.evaluated_depsgraph_get() | |
# iterate animation frames: | |
for f in frames: | |
bpy.context.scene.frame_set(f) | |
# define new bmesh object: | |
bm = bmesh.new() | |
bm.verts.ensure_lookup_table() | |
# read the evaluated (deformed) mesh data into the bmesh object: | |
bm.from_object( obj, depgraph ) | |
# iterate the bmesh verts: | |
for i, v in enumerate(bm.verts): | |
print("frame: {}, vert: {}, location: {}".format(f, i, v.co)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment