how to render and save as png from python script?

Sorry, this might be a newbie question:

I’ve just learned how to move objects from inside my python script. Now I need to know how to make a rendering and save it as png file, using a certain (chaning) file name. I’ve visited some tutorials on python and Blender, but somehow I’m still clueless.

Thanks a lot for any help.

See ya, jp.

Internally, Blender has no command to start a render (AFAIK), but since Blender supports command line rendering, all you have to do is use one of the spawn command in the os module to call Blender.exe with the corresponding arguments.


So that means I could save repeatedly to a temporary .blend file and then use the operating system interaction to make renderings out of them.
Sounds feasible if I can find out how to save .blend files :slight_smile:
Strange that this seems not to be frequently encountered problem. In my case it only arises because we need several parts of an animated object from different points of view for use in a game, so the need to save everything and in an ordered fashion for conveninet use by the game engine.

Thanks a lot for the hint.

See ya, jp.

So I think I’ve got everything together, except for one thing: How to I save the currently loaded .blend file so some given file name, say ‘tmp.blend’? Maybe it’s just one line. Could someone link me to a page or drop me that ‘line’?

Thanks a thousand times and see ya, jp.

Thanks to all who thought about the problem or posted something.
The problem has been worked around now. We use anim button to create all the renderings and just glue the script in question to the frame change and then work on the saved files each, rename them and crop them and everything we need… That’s almost perfect solution for many of our cases. Thanks again and see ya. (johannesprix)