rendering different objects on frame change

Hello all, I wonder what is the best approach to render a different object for each frame.
I’ve tried to register my handler on frame_change_pre or render_pre that select and delete everything and call my operator that generate the object with different parameters, but I’ve realized you don’t have access to the context.
A different approach would be to generate the geometry before and switch the visibility/layer on frame_change, but the drawback is that I would end up with a file with hundred of objects and I would like to avoid it.
What do you suggest?

thanks Atom, neat! But that means sphere data should already be there to swap it.
My program start from a base solid then it’s copied several time and some modifier is applied to each linked or full copy based on the parameters, so I don’t “build” directly the mesh.
Maybe a better approach would be to call blender from the shell passing a script to run with different parameter?

To fetch mesh data with the modifiers applied.


import bpy
scene = bpy.data.scenes[0]
mesh = ob.data.to_mesh(scene, True, 'RENDER') # Can also convert modifiers that support 'PREVIEW' settings as well.

http://www.blender.org/documentation/blender_python_api_2_70_release/bpy.types.Object.html?highlight=to_mesh#bpy.types.Object.to_mesh

I see now, thanks you!