Call Python per-frame

[First post here, so please forgive / correct if this is the wrong place, or otherwise breaches etiquette]

I have been animating with the python API for a while. I run a script that clears all IPOs, then rebuilds them according to some algorithm. Then during render, blender interpolates, configures and draws. All fine and dandy.

For a current project it would be ideal if I could do things a little differently. Ideally I’d have a script that would get called each frame to say “please configure for frame X”. It would then do so before terminating and allowing the renderer to run. I’ve never used the game engine, but this seems like how the game engine works: you have a script that gets called per frame. But I can’t figure out if I can set up blender to do the same when rendering with Cycles (or BI).

I’ve faked this at the moment by having a command-line script which takes as arguments the frames to be rendered, and configures, then calls the render command, then configures, and so on. Basically making the inner loop belong to my script.

But am I missing some easy way to have a script run pre-render for each frame?

I should add that I’m on 2.66, though I have a few 2.5+ versions installed that I can run it on.

I didn’t test what I will tell you now …but I think it should work!!
make all your script functions into a big function …do something like this:

read current frame = … #get current frame
if (current frame change) do (your function)

You just need to setup your script to be called with the frame change handler.

http://www.blender.org/documentation/blender_python_api_2_60_6/bpy.app.handlers.html

kastoria - perfect, thanks. I did search the documentation, but obviously didn’t use the right terms. Hey ho. Very much appreciate the link.

Yeah, some things are really difficult to search for.