Code Snippet with Bmesh: find the linked vertices

Just a little example of BMesh API: find the linked vertices, of the selected vertice:

import bpy, bmesh
obj = bpy.context.object
mesh =
bm = bmesh.from_mesh(mesh)
# Found the linked vertices of selected vertices
for i_0, v_0 in enumerate(bm.verts):
    if and v_0.is_valid:
        print("Vertice Index: ", v_0.index)
        for i_1, e_0 in enumerate(v_0.link_edges):
            print("    Linked verticess:",  e_0.other_vert(v_0).index)

a bit confusing !

there is no vert selection done before loop

so in


wher is the vert selection done ?

good example for the link edges
look more powerfull then older method !


You must start the script with vertice/s alredy selected.
If you want select a vertice from the script, add (for example) the following row, before the loop:

bm.verts[2].select=True #Select the vertice with index=2

i treid the script and even if not selected any verts then it will list all verts !

but may be your right
i think all verts where already selected in edit mode !