Last active
August 29, 2015 14:26
-
-
Save zeffii/a422d4d7dc04ed023a57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
import time | |
US = lambda: bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) | |
# 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 | |
US() #update screen | |
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 | |
US() #update screen | |
time.sleep(0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
import time | |
US = lambda: bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) | |
# 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 b in [1, 0]: | |
for v in me.verts: | |
v.select = b | |
US() #update screen | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The lambda is in essence a single line function declaration, a shorthand for functions which really don't have much going on, but at the same you just clutter the code if you always pass the same arguments. In this case the lambda allows the execution of a function with pre-filled arguments.
The following are functional equivalents in this scenario.
and
One could pass arguments to the lambda.. but then you might as well be using a function definition with default arguments if there's a set of arguments that would get passed most frequent