How to get vertex coordinates after modifier in Python in Blender 2.80? I have a mesh with armature modifier. Is there any efficient way to read its vertices coordinates with modifiers accounted in Blender 2.80?

So far the only way I found is to duplicate the object, apply modifier, read vertices and remove duplicated object:

def extract_vertices(my_object):
    # Duplicate object
    for obj in bpy.data.objects: obj.select_set(False)
    my_object.select_set(True)
    bpy.ops.object.duplicate_move()

    # Apply modificators
    duplicated_object = bpy.context.scene.objects[-1]
    bpy.context.view_layer.objects.active = duplicated_object
    duplicated_object.select_set(True)
    bpy.ops.object.modifier_apply(apply_as='DATA', modifier="RIG")

    # Read vertices
    vertices = [v.co for v in duplicated_object.data.vertices]

    # Remove duplicated object
    my_object.select_set(False)
    bpy.ops.object.delete()

    return vertices


It works, but very slow. I need to run this thing thousands of times in the loop, adjusting modifier every iteration.

It seems that Object.to_mesh() described in answer here could be exactly what I need, but it's signature is changed in Blender2.80 and there's no apply_modifiers parameter anymore.
Using bmesh and the dependencies graph, you can get an evaluated bmesh:

import bpy
import bmesh

depsgraph = bpy.context.evaluated_depsgraph_get()

obj = bpy.data.objects['Cube']

bm = bmesh.new()

bm.from_object( obj, depsgraph )

bm.verts.ensure_lookup_table()

print( "----" )
for v in bm.verts:
    print( v.co )

bm.free()


Edit:

obj.to_mesh should work too (have not tested) but if you don't want to create a mesh, this is not needed.