Python scripting: how to select next vertex in mesh I have the following script (doesn't work) to try to select the next connected vertex (of the current object) in a mesh. Would appreciate some help. thanks

# seems like I need to toggle this to sync script to view. Please help
# if there is a better way!
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')

count = len(bpy.context.scene.objects.active.data.vertices)
try:
  active = [e.index for e in bpy.context.scene.objects.active.data.vertices if e.select][0]
except IndexError:
  active = 0

active = (active+1) % count

for idx, e in enumerate(bpy.context.scene.objects.active.data.vertices):
    if idx==active:
        e.select = True
    else:
        e.select = False
You can get all adjacent vertices like this 

import bpy
import bmesh

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

bm = bmesh.from_edit_mesh(mesh)
active = bm.select_history.active

if active and isinstance(active, bmesh.types.BMVert):
    for edge in active.link_edges:
        print(edge.other_vert(active))