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$
4
  • 1
    $\begingroup$ also related, possibly useful. blender.stackexchange.com/questions/3249/show-mesh-vertices-id $\endgroup$
    – zeffii
    Commented Aug 1, 2015 at 5:50
  • 1
    $\begingroup$ proof: gist.github.com/zeffii/a422d4d7dc04ed023a57 $\endgroup$
    – zeffii
    Commented Aug 1, 2015 at 5:56
  • $\begingroup$ Those answers are what I needed @zeffii. I've accepted this as duplicate. I'll read more about ops.wm.redraw_timer now. Thanks! $\endgroup$
    – uhoh
    Commented Aug 1, 2015 at 6:42
  • $\begingroup$ I was hoping to get through life without having to learn about lambda. rats! That's a snazzy script @zeffii $\endgroup$
    – uhoh
    Commented Aug 1, 2015 at 6:50

0

Browse other questions tagged .