Skip to content

Instantly share code, notes, and snippets.

@akloster
Created March 31, 2017 17:19
Show Gist options
  • Save akloster/d2cff07a9dc336a171293bc3633d24a6 to your computer and use it in GitHub Desktop.
Save akloster/d2cff07a9dc336a171293bc3633d24a6 to your computer and use it in GitHub Desktop.
create an image caption in blender python part 3
# Open template .blend
path = os.path.dirname(__file__)
template_path="/"+os.path.join(path,"blends",template+".blend")
if not os.path.exists(template_path):
print(prog_name + "could not find this template file: '%s'" % template_path)
sys.exit(1)
bpy.ops.wm.open_mainfile(filepath=template_path)
# Change text
bpy.data.objects["Text"].data.body = text
# Render output image
bpy.context.scene.render.filepath = output
bpy.context.scene.render.resolution_x = 1900
bpy.context.scene.render.resolution_y = 1080
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