Python BMesh: index of new verts? When i try to create verts with BMesh i get always the same verts index.

bm = bmesh.from_edit_mesh(active_obj.data)
for i in range(20):
    vert = bm.verts.new((0.0, 0.0, 0.0))
    print(vert.index)


index of all 20 verts will be -1.

How to get right index or correct it manually?
you'll have to reassign the vertices indexes using an built in function or using your own code as mentioned in the DOCs


  index_update()

Initialize the index values of this sequence.
This is the equivalent of looping over all elements and assigning the index values.



so your code should be :

bm = bmesh.from_edit_mesh(active_obj.data)
for i in range(20):
    vert = bm.verts.new((0.0, 0.0, 0.0))
    vert.index = len(bm.verts)
    print(vert.index)


or use 

bm.verts.index_update()