Page MenuHome

editmode - Bmesh vert index error when using 'frame selected'
Closed, ArchivedPublic

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 660/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 442.19

Blender Version
Broken: version: 2.82 (sub 7), branch: master, commit date: 2020-03-12 05:06, hash: rB375c7dc4caf4
Worked: (optional)

Short description of error
I have simple script that prints bmesh vert.index - works ok.
But if user uses => View -> 'Frame selected' - numpad .
Then vert index is prints -1
Im using bm.verts.ensure_lookup_table() but it wont work when using frame selected and then running the script.

Exact steps for others to reproduce the error
a) use frame selected (numpad .) in mesh editmode
b) run script - in console you can see vert index is -1 but should be 5.

Seems to be happening in blender 2.83 too.
Simple blend file:

Event Timeline

Ankit Meel (ankitm) changed the task status from Needs Triage to Confirmed.Apr 26 2020, 8:37 AM

a) use frame selected (numpad .) in mesh editmode
b) run script - in console you can see vert index is -1 but should be 5.

c) slightly move the viewport, run script - it prints 5.

For convenience:

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bm = bmesh.new()
bm = bmesh.from_edit_mesh(mesh)  

bm.verts.ensure_lookup_table()
bm.edges.ensure_lookup_table()

print(bm.edges[0].index)
print(bm.edges[0].verts[0].index)

To ensure correct indices, use index_update method, closing.

@Campbell Barton (campbellbarton) ok, but still no other operation breaks the indices, just the 'focus tool'.