简体   繁体   中英

to_mesh() in blender 3

in previous blender versions, it was possible to get the actual position of a vertex with to_mesh():

https://blenderartists.org/t/how-to-get-vertices-coordinates-from-animated-mesh/565581/4

Unfortunately this function does not work in blender 3, does it? Is there an alternative approach to get the vertex coordinates with modifiers and shape keys applied? Thanks in advance!

Greetings

This minimal example is working for in blender 3.0.0:

import bpy

# get absolute position of a vertex from an object with shapekeys (and other transforms)
dg = bpy.context.evaluated_depsgraph_get()
obj = bpy.context.object.evaluated_get(dg)

mesh = obj.to_mesh(preserve_all_data_layers=True, depsgraph=dg)
co = mesh.vertices[0].co
co_final = obj.matrix_world @ co
print(co_final)

It is based on approaches from ideasman42 and iceythe Kaio in this older posts: https://blenderartists.org/t/get-mesh-data-with-modifiers-applied-in-2-8/1163217 https://blender.stackexchange.com/questions/1311/how-can-i-get-vertex-positions-from-a-mesh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM