Need to set for loop to continue rendering sequence

Hi all,

I am new to python and am trying to alter this script to render out a sequence of up to 60 frames.

def startRenderSequence(object, items, destination):
counter = 0
for i in items:
changeText(object, i)
renderImage(destination, “Image”+str(counter))
counter += 1

def renderImage(directory, filename):
bpy.ops.render.render()
filepath = directory + “\” + filename + “.png”
bpy.context.scene.render.filepath = filepath
bpy.ops.render.render(use_viewport = True, write_still=True)

def run():
ob = getTextObject()
items = [“name”]
startRenderSequence(ob, items, “C:\TestRender”)

run()

I had assumed it would be as simple as canging the “for i” to

for i in range(60):
    changeText(object, i)
    renderImage(destination, "Image"+str(counter))
    counter += 1

But it shows an error when I run that.

Can someone help out?

what happens if you run,

startRenderSequence(object, 60, destination)?

No I tried that. But it just comes up with an error.

Cheers though

eppo thanks,

Yes that is the code! I want to set up an automated process that is being run by another program 'Autoit" and what I want is a template script that can be changed by this and run for a minimum of 60 frames. I might try sifting through your example and see where that leads me.

OK so I found a solution that works quite well.

import os
import bpy
bpy.data.objects[“Text”].data.body = “Hello World”
original_frame = bpy.context.scene.frame_current
output_path = bpy.context.scene.render.filepath
start = bpy.context.scene.frame_start
end = bpy.context.scene.frame_end
frames = []

for obj in bpy.context.selected_objects:
for fcurve in obj.animation_data.action.fcurves:
for keyframe_point in fcurve.keyframe_points:
x, y = keyframe_point.co
if x >= start and x <= end and x not in frames:
frames.append(x)

for frame in frames:
bpy.context.scene.frame_current = frame
bpy.context.scene.render.filepath = os.path.join(output_path, “%05d” % frame)
bpy.ops.render.render(write_still=True)

bpy.context.scene.frame_current = original_frame
bpy.context.scene.render.filepath = output_path

Thanks for all your help. I’m about to post a newy on how can I centre the text in the camera veiwport without converting it to a mesh and centring its origin to the cursor.