[python] Sprites in Blender
Viewer
- import bpy
- import math
- # Set animation base name
- anim_name = bpy.path.basename(bpy.context.blend_data.filepath)
- anim_name = anim_name[0:-6]
- # Grab the armature
- armature = bpy.data.objects['Armature']
- # Render SW
- bpy.context.scene.render.filepath = "//sprites//" + anim_name + "_sw_"
- bpy.ops.render.render(animation=True)
- # Render S
- armature.rotation_euler.rotate_axis('Y', math.radians(45))
- bpy.context.scene.render.filepath = "//sprites//" + anim_name + "_s_"
- bpy.ops.render.render(animation=True)
- # Render SE
- armature.rotation_euler.rotate_axis('Y', math.radians(45))
- bpy.context.scene.render.filepath = "//sprites//" + anim_name + "_se_"
- bpy.ops.render.render(animation=True)
- # Render E
- armature.rotation_euler.rotate_axis('Y', math.radians(45))
- bpy.context.scene.render.filepath = "//sprites//" + anim_name + "_e_"
- bpy.ops.render.render(animation=True)
- # Render NE
- armature.rotation_euler.rotate_axis('Y', math.radians(45))
- bpy.context.scene.render.filepath = "//sprites//" + anim_name + "_ne_"
- bpy.ops.render.render(animation=True)
- # Render N
- armature.rotation_euler.rotate_axis('Y', math.radians(45))
- bpy.context.scene.render.filepath = "//sprites//" + anim_name + "_n_"
- bpy.ops.render.render(animation=True)
- # Render NW
- armature.rotation_euler.rotate_axis('Y', math.radians(45))
- bpy.context.scene.render.filepath = "//sprites//" + anim_name + "_nw_"
- bpy.ops.render.render(animation=True)
- # Render W
- armature.rotation_euler.rotate_axis('Y', math.radians(45))
- bpy.context.scene.render.filepath = "//sprites//" + anim_name + "_w_"
- bpy.ops.render.render(animation=True)
- # Rotate back to SW
- armature.rotation_euler.rotate_axis('Y', math.radians(45))
Editor
You can edit this paste and save as new: