shortest_path_select() does not work I have a List (verts_index_list) of 2 numbers that represents the index of 2 vertices. My goal is to collapse all vertices that are on the shortest path between those 2 Vertices. I looked in the blender api and saw that there is a function shortest_path_select() that should do what I want. So I wrote :

for v in verts_index_list:
    mesh.vertices[v].select = True
bpy.ops.mesh.shortest_path_select()
bpy.ops.mesh.edge_collapse()


but it does not work. The terminal prints the following warning :


  Warning: Path selection requires two matching elements to be selected


I don't understand... I selected exactly 2 vertices ([v for v in mesh.vertices if v.select] gives me 2 Elements). So my question is: Do I have to update something before calling shortest_path_select?
It works when I uses a BMesh instead of a Mesh type. When I uses the select_set(True) from BMVerts, the shortest_path_select() works fine.