# How to select vertices sequentially in a script and see it happen in 3D viewer [duplicate]

I am trying to make a visual explanation of vertex sequence for a mesh object. I pieced this script together from the internet. It runs, but I don't see anything happen. How can I get the effect to be visible? (vertices become selected one at a time until all selected, then deselected one at a time (in the same order)).

If I can get it to work, then I can illustrate various patterns, not just vertex order.

Also, is this really the best way to update the 3D viewer?

bpy.context.scene.objects.active = bpy.context.scene.objects.active

Here is an illustration. I added the wireframe view for fun. I'll make it easier on the eyes once I can get something to work (this is 34 screen shots)

Script:

import bpy
import bmesh
import time

ao = bpy.context.active_object
oo = bpy.ops.object

oo.mode_set(mode='EDIT')

me = bmesh.from_edit_mesh(ao.data)
nverts = len(me.verts)
print(nverts)

for i in range(2):
for iv in range(nverts):
me.verts.ensure_lookup_table()
me.verts[iv].select = True     #  light them up one at a time
#update screen
bpy.context.scene.objects.active = bpy.context.scene.objects.active
time.sleep(0.5)

for iv in range(nverts):
me.verts.ensure_lookup_table()
me.verts[iv].select = False     #  turn them off one at a time
#update screen
bpy.context.scene.objects.active = bpy.context.scene.objects.active
time.sleep(0.5)

• also related, possibly useful. blender.stackexchange.com/questions/3249/show-mesh-vertices-id – zeffii Aug 1 '15 at 5:50
• – zeffii Aug 1 '15 at 5:56
• Those answers are what I needed @zeffii. I've accepted this as duplicate. I'll read more about ops.wm.redraw_timer now. Thanks! – uhoh Aug 1 '15 at 6:42
• I was hoping to get through life without having to learn about lambda. rats! That's a snazzy script @zeffii – uhoh Aug 1 '15 at 6:50