1
$\begingroup$

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)

vertex animation GIF

Script:

import bpy
import bmesh
import time

# START WITH CUBE or low vertex number mesh selected.

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)
$\endgroup$

Browse other questions tagged or ask your own question.