pythonrenderingblenderbpy

Python script for Blender: Get Render informations


I don't know how to use blender but I need to make a script that follow a render and send alarm if something is wrong. I'm using Python 3.5 (I could use something else if it's needed), windows 10 and Blender 2.79

I've a big problem and I can't find a solution anywhere. I can't read the render info...is it possible? I can only read the current frame:

bpy.context.scene.frame_current

I would need to read all info contained in this image:

enter image description here

particularly:

Thank you!

EDIT:

I don't know if I'm using the right language...when I talk about render I mean render of an animation.

EDIT2:

I would need to control if the render is going or is crashed for some reason...


Solution

  • Unfortunately blender doesn't provide info to python while it is rendering, feedback is limited to the line at the top of the render result which you show. This answer shows a way of using bpy.app.handlers to get notifications at certain stages. For a script to monitor a render inside blenders gui, that is probably the best you will find.

    If you provide a way to control rendering from outside of blender you have some other options. You can start blender as a CLI tool, the -b argument will keep it in the background (no gui) and allow you to read its output to monitor where it is.

    I would first run a small script to get the number of frames

    blender -b proj.blend --python-expr "import bpy;print(bpy.context.scene.frame_start, bpy.context.scene.frame_end)"
    

    Then when you render the animation you will get progress output like

    blender -b project.blend -a
    ...
    Fra:3 Mem:17.40M (0.00M, Peak 23.73M) | Time:00:00.10 | Scene, Part 230-240
    Fra:3 Mem:17.37M (0.00M, Peak 23.73M) | Time:00:00.10 | Scene, Part 228-240
    Fra:3 Mem:17.35M (0.00M, Peak 23.73M) | Time:00:00.10 | Scene, Part 231-240
    ...
    

    The first number is the frame being rendered, the last two are the tile just finished and the total tiles being rendered, you can see the time blender reports for the frame but you would want to monitor how long between each line being received and do something if it takes too long between output lines.