Last active
August 29, 2015 13:56
-
-
Save Muffo/9271031 to your computer and use it in GitHub Desktop.
Blender scene manipulation and rendering with Python
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 math | |
import bpy | |
# Replace with the correct object name | |
object = bpy.data.objects["Surface"] | |
scene = bpy.data.scenes['Scene'] | |
# Set the resolution of the output image (this does not work) | |
# scene.render.resolution_x = 1920 | |
# scene.render.resolution_y = 1080 | |
# Movement | |
start_angle = 0 | |
end_angle = 360 | |
step_angle = 30 | |
start_location = -2 | |
# Obtain the radius of the cylinder | |
assert(object.scale[0] == object.scale[1], "Radius is not correct") | |
radius = object.scale[0] | |
# Generate the sequence of images | |
for cur_angle in range(start_angle, end_angle, step_angle): | |
object.rotation_euler[2] = cur_angle | |
object.location[0] = radius * math.radians(cur_angle) + start_location | |
# The format of the image must be defined in the GUI | |
scene.render.filepath = 'C:\\Users\\grandian\\Desktop\\render\\image_%d.bmp' % (cur_angle) | |
bpy.ops.render.render( write_still=True ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment