I want to render a batch of short videos in blender. They are all based on the same .blend file, a simple scene with a text object in front of a background.
Now, the task is that each of the videos I need to render from that scene has a different text object, or simply: I need to change the text-object in every iteration of the rendering. Everything else in the scene stays the same.
So, (as an example) here is MyText.py
import bpy
context = bpy.context
scene = context.scene
# delete all default objects
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete(use_global=False)
# ADD TEXT HERE
bpy.ops.object.text_add(view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
# EDIT TEXT HERE
bpy.ops.object.editmode_toggle()
bpy.ops.font.delete(type='PREVIOUS_OR_SELECTION')
bpy.ops.font.delete(type='PREVIOUS_OR_SELECTION')
bpy.ops.font.delete(type='PREVIOUS_OR_SELECTION')
bpy.ops.font.delete(type='PREVIOUS_OR_SELECTION')
bpy.ops.font.text_insert(text="M", accent=False)
bpy.ops.font.text_insert(text="Y", accent=False)
bpy.ops.font.text_insert(text=" ", accent=False)
bpy.ops.font.text_insert(text="T", accent=False)
bpy.ops.font.text_insert(text="E", accent=False)
bpy.ops.font.text_insert(text="X", accent=False)
bpy.ops.font.text_insert(text="T", accent=False)
bpy.ops.object.editmode_toggle()
bpy.ops.transform.rotate(value=1.5708, axis=(1, 0, 0), constraint_axis=(True, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
bpy.context.object.data.extrude = 0.05
bpy.context.object.data.size = 1.0
I want to accept user input to change the text (edit the copy) with a limit of up to 20 characters. The input will eventually come from an HTML form that uses php to update the MyText.py script with the USER TEXT all within the .blend file
import bpy
context = bpy.context
scene = context.scene
# delete all default objects
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete(use_global=False)
# ADD TEXT HERE
bpy.ops.object.text_add(view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
# EDIT TEXT HERE
bpy.ops.object.editmode_toggle()
bpy.ops.font.delete(type='PREVIOUS_OR_SELECTION')
bpy.ops.font.delete(type='PREVIOUS_OR_SELECTION')
bpy.ops.font.delete(type='PREVIOUS_OR_SELECTION')
bpy.ops.font.delete(type='PREVIOUS_OR_SELECTION')
bpy.ops.font.text_insert(text="U", accent=False)
bpy.ops.font.text_insert(text="S", accent=False)
bpy.ops.font.text_insert(text="E", accent=False)
bpy.ops.font.text_insert(text="R", accent=False)
bpy.ops.font.text_insert(text=" ", accent=False)
bpy.ops.font.text_insert(text="T", accent=False)
bpy.ops.font.text_insert(text="E", accent=False)
bpy.ops.font.text_insert(text="X", accent=False)
bpy.ops.font.text_insert(text="T", accent=False)
bpy.ops.object.editmode_toggle()
bpy.ops.transform.rotate(value=1.5708, axis=(1, 0, 0), constraint_axis=(True, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
bpy.context.object.data.extrude = 0.05
bpy.context.object.data.size = 1.0
Is it possible to manipulate a .blend file in this manner? Do I need to call (execute) several python scripts to accomplish this, or can it be accomplished in one python script where (1) it loads the initial MyText.py, (2) accepts user input and changes the text accordingly (a new python script e.g. UserText.py?) and (3) renders the updated .blend file
I am using Terminal (Mac OS) to call the .blend file which has the initial (saved) python script MyText.py and output the file with formatting options to a specific output folder. I am using Blender 2.79
I am new to python and so any code examples would be extremely helpful and appreciated. Thank you in advance for any help you may provide.