1
$\begingroup$

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?

$\endgroup$
3
$\begingroup$

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()
$\endgroup$
  • $\begingroup$ bm.verts.index_update() is correct. $\endgroup$ – mifth May 28 '15 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.