Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created August 14, 2015 19:12
Show Gist options
  • Save zeffii/afd28ce54d8fef9ded1d to your computer and use it in GitHub Desktop.
Save zeffii/afd28ce54d8fef9ded1d to your computer and use it in GitHub Desktop.
import bpy
import bmesh
import time
import math
path = "/home/zeffii/Desktop/tmpo5/"
context = bpy.context
for area in context.screen.areas:
if area.type == "VIEW_3D":
ctx = { "window": context.window, "area": area, "region":None}
break
US = lambda: bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
obj = bpy.data.objects['Suzanne']
bpy.context.scene.objects.active = obj # not only active but also selects.
bpy.ops.object.mode_set(mode='OBJECT')
for i in range(9):
obj.rotation_euler = ((0.0, 0.0, math.pi*i/4.0))
US()
for k, f in enumerate(obj.data.polygons):
f.material_index = 1 if k%(i+2) else 0
time.sleep(2.0)
file = "ao2_" + str(1000+i) + ".png"
bpy.ops.screen.screenshot(ctx, filepath=path+file, full=False)
@zeffii
Copy link
Author

zeffii commented Aug 14, 2015

The other difference with doing screenshots manually is that blender does a bunch more updates when you move your mouse around the UI, i would consider sticking a few more calls to US() .. maybe even directly before taking the screenshot

 US()
 bpy.ops.screen.screenshot(ctx, filepath=path+file, full=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment