Page MenuHome

BMesh vert indexes are incorrect after using view selected
Closed, ArchivedPublic


Blender versions with this bug

  • 2.79b windows64
  • latest 2.79 windows64 daily build, c960804
  • latest 2.8 windows64 daily build, 53c63db

Short description of error
Vert indexes are left in an invalid state after pressing NumpadPeriod (View Selected) in Mesh Edit mode.

Exact steps for others to reproduce the error

  1. Open Blender from the command line so console output is visible
  2. Switch to Blender's script editor and paste in the code below
  3. Run the script to put the operator in memory
  4. Switch to edit mode (if not already)
  5. Switch to Orthographic view (if not already)
  6. Make sure there is mesh object with at least 2 vertices in the scene
  7. Select a vertex that does not have index 0
  8. Open the Search bar (spacebar in 2.79)
  9. Type in the newly added operator name ("Verify Vert Index Bug") and press enter to run it.
  10. Press the left mouse button to print the index number to the console (make sure the selected vert does not have index 0)
  11. Press NumpadPeriod (centers the view on the selected object)
  12. Press the left mouse button again and note the selected vert no longer has the same index
  13. Press right mouse or escape to exit the operator

Additional details

  • this bug is also reproducible in Perspective View if you zoom way out from the selected object before pressing NumpadPeriod
  • Blender's built-in index visibility option (accessible in the N-Panel when Blender is launched in debug mode) does not have this issue.
  • the vertex number will be corrected if a different vert is selected, if you leave vert select mode, or if you switch out of Mesh edit mode and then switch back
  • the bug is only reproducible in the full Blender release builds (eg: 2.79b and the daily releases). debug builds do not have this issue.

Code to verify the bug:
This code was used to reproduce the bug in all the builds listed above

import bpy
import bmesh

print("\nAdd-on loaded")  # debug

class VerifyVertIndexBug(bpy.types.Operator):
    bl_idname = "mesh.verify_vert_index_bug"
    bl_label = "Verify Vert Index Bug"

    def poll(cls, context):
        return context.mode == 'EDIT_MESH'

    def modal(self, context, event):
        if event.type in {'NUMPAD_PERIOD', 'MIDDLEMOUSE', 
                    'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}:
            return {'PASS_THROUGH'}

        elif event.type == 'LEFTMOUSE' and event.value == 'PRESS':
            print("Last selected vert index:", self.sel_vert.index)

        elif event.type in {'ESC', 'RIGHTMOUSE'}:
            print("Add-on exited")  # debug
            return {'CANCELLED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        self.sel_vert = None
        # must store bm data as class value, otherwise anything linked to
        # its data will be invalidated when invoke returns = bmesh.from_edit_mesh(
        if len( == 0:
  {'WARNING'}, "No verts selected")
            return {'CANCELLED'}
        elif type([-1]) is not bmesh.types.BMVert:
  {'WARNING'}, "Last selected item must be vert")
            return {'CANCELLED'}
            print("Add-on started")  # debug
            self.sel_vert =[-1]
            print("Last selected vert index:", self.sel_vert.index)
            return {'RUNNING_MODAL'}

def register():

def unregister():

if __name__ == "__main__":

Affected Blender Add-ons

  • MeasureIt
    • measurements do not appear to be affected, but indexes drawn using "Mesh Debug" are wrong
    • the code that draws the vertex indexes is the "draw_vertices" function in ""
    • index numbering in edit mode is retrieved from bmesh data with a call similar to this: txt += str(bm.verts[0].index)

Animated GIF of the bug in MeasureIt: (made with 0a8af46 build)



Event Timeline

nBurn (nBurn) updated the task description. (Show Details)
nBurn (nBurn) claimed this task.

Hi @nBurn (nBurn),

havent hunted down the related commit, but this seems to be resolved in master?

Philipp Oeser (lichtwerk) triaged this task as Normal priority.Jun 19 2018, 4:16 PM
nBurn (nBurn) raised the priority of this task from Normal to Needs Triage by Developer.Jun 20 2018, 8:43 AM

Hi @Philipp Oeser (lichtwerk),

Which Blender release did you use? I just tried 0a8af46 from (blender-2.79-0a8af46-win64) and am still able to reproduce this bug. I updated the "steps to reproduce" and added an "Additional details" section to the description with some more info.

I looked over the code and I think this may actually be a problem with the data being fed to Blender's Python API and not MeasureIt. I didn't see anything obvious in MeasureIt's code that should be causing this, my guess is it's "Center view on selected" that is causing the invalid vertex data. To double check I tried 2 other add-ons that had a vertex index visualization feature and both had this problem.

nBurn (nBurn) triaged this task as Normal priority.Jun 20 2018, 8:46 AM
Campbell Barton (campbellbarton) closed this task as Invalid.

If you want indices to be correct, use bm.verts.index_update(), closing.

Campbell Barton (campbellbarton) reopened this task as Open.

Re-opened, since it is a bug in the add-on.

nBurn (nBurn) updated the task description. (Show Details)Jul 5 2018, 2:57 PM
nBurn (nBurn) renamed this task from MeasureIt vert indexes change in debug mode when using view selected to BMesh vert indexes are incorrect after using view selected.
Brendon Murphy (meta-androcto) closed this task as Archived.

closing as archived. @nBurn (nBurn) feel free to double check.