For mesh objects with shape keys, you can access the vertex coordinates of the shape key using:
obj = C.scene.objects["Suzanne"] for v in obj.data.shape_keys.key_blocks["My Shape Key"].data: print(v.co)
For mesh objects with a subsurf modifier, you can access the vertex coordinates of the mesh with the modifier applied using:
obj = C.scene.objects["Suzanne"] m = obj.to_mesh(C.scene, True, "RENDER") for v in m.vertices: print(v.co)
However, what do you do if a mesh object contains both a subsurf modifier and a shape key? I need to access the vertex coordinates of the shape key after the subsurf modifier is applied from python.
I tried to use the first way, but
key_blocks["..."].data only holds the vertex coordinates of the mesh without the subsurf modifier. If use
m = obj.to_mesh(...) instead, the
shape_keys attribute of
I found an article that explains what you do in the blender GUI to create a new object with both modifiers and shape keys applied: Shape keys and applying subdivision surface modifier. Do I need to reproduce all these steps in python? It seems rather complicated and I find it strange that
to_mesh is not able to do this.
Note: I am using Blender 2.79.