render with blender as a python module

Hello everyone

I’d like to know if it is possible to import the bpy module in a python script, and use it to “open” a .blend file (or other file format), to then render it.
I tried this :


import bpy
bpy.ops.render.render(write_still=True)

It worked (wrote a .png file) but I would like to be able to render something else than a cube :wink:

Thanks!

If anyone is interested I’ve managed to do it eventually!
Here are the commands I used:


bpy.ops.wm.open_mainfile('EXEC_DEFAULT',filepath='/path/to/file.blend', load_ui=False)
bpy.ops.render.render('EXEC_DEFAULT', write_still=True)

It was actually quite simple once I noticed that when you hover a menu item, the corresponding python function is displayed…
Thanks anyway, hope this will help someone.

Thank you so much for the hovering thing. I have compiled blender as a python module, and I hope to render it with python script, and get the render results. But I found Blender only render scene to a file, rather than an image in memory. Do you know if Blender can do that? Thanks.