# Select vertices by their indices (by vertex id) [duplicate]

I want to select vertices by their indices (by vertex id) Like a python script,so that i can write the vertex id into it, and run the script,and it would automatically select those vertices

there is already an answer (python script) ,but it only works with one vertex when i tried with more than 2 vertices,it does not work : How Could I Select a vertex by its ID?

## marked as duplicate by someonewithpc, p2or, PGmath, David♦Apr 1 '16 at 22:08

I have modified the code from this answer to solve the problem, where I have replaced if vert.index == index: to if vert.index in indices: where indices= [1, 2, ...]

example :

import bpy
import bmesh

indices = [1, 3, 4, 7, 8]

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 in indices:
vert.select = True
else:
vert.select = False

bmesh.update_edit_mesh(me, True)

• Another approach would be to remove the else: vert.select=False so that it only extends the selection, then manually de-select all if you want to start again. – sambler Apr 2 '16 at 9:09
• same thing for the faces? face in faces ? – June Wang Oct 18 at 6:03