# How Could I Select a vertex by its ID?

How could I select one vertex from my mesh if I know ID of that vertex? I enabled bpy.app.debug = True and I can see all IDs but cant find a specific one.

• do you mean index ? – Chebhou Apr 5 '15 at 14:08
• Yup, Im not sure whats the correct term, you can call it index, select vertex by number – Slobodan Vidovic Apr 7 '15 at 7:41

import bpy
import bmesh

index = 0 # here the index you want select please change

obj = bpy.context.object
me = obj.data
bm = bmesh.from_edit_mesh(me)

vertices= [e for e in bm.verts]
oa = bpy.context.active_object

for vert in vertices:
if vert.index == index:
vert.select = True
else:
vert.select = False

bmesh.update_edit_mesh(me, True)

• Tnx, this is working just perfect – Slobodan Vidovic Apr 7 '15 at 7:44
• I added more then one number in index with comma but it does not work, what else do I need to change :) – Slobodan Vidovic Apr 8 '15 at 15:47

I would like to add to yhoyos answer, that a vertex can be selected by replacing the for-loop with

bpy.ops.mesh.select_all(action='DESELECT')
bm.verts[index].select = True


Also, if you don't care about the previous selections, just using

bm.verts[index].select = True


should be significantly faster for large meshes

• Agree re no need for for loop. Btw it's bm.verts and will need to bm.verts.ensure_lookup_table() to access via index, and maybe add the check abs(index) < len(bm.verts) – batFINGER Feb 21 '19 at 14:19