I want to append some code to the bpy.app.handlers.render_post operator. But I need to know whether the bpy.ops.render.render() operator has been called with the animation parameter (/argument?) set to True or False.

import bpy

def mRenderOutput(scene):
    print(getattr(bpy.ops.render.render, "animation"))
    #something like: if bpy.ops.render.render.animation == True: do my code

def register():

def unregister():

if __name__ == "__main__":

Unfortunately, this throws:

Traceback (most recent call last): File "C:\Users\morph3us\Desktop\mRenderOutput\mSaveRender001.blend\Text.004", line 4, in mRenderOutput AttributeError: 'BPyOpsSubModOp' object has no attribute 'animation'

So my question: How can I detect in an if clause inside of "mRenderOutput" whether a still image or an animation has been rendered?

  • $\begingroup$ bpy.ops.foo.bar is not an instance of nor the operator class. Have a look at context.active_operator or in the window managers operators collection. $\endgroup$
    – batFINGER
    Oct 1, 2018 at 16:44
  • $\begingroup$ Thanks for the pointer! I do not fully understand what you are saying, although I have been trying to figure it out for the past 3 hours, but I hope I will eventually get behind it! $\endgroup$
    – morph3us
    Oct 2, 2018 at 10:56
  • $\begingroup$ Sorry bum steer the render operator isn't added to wm's operators collection. Once apon a time could get all operator classes from bpy.types, appears no longer the case. One way is to look at the other render handlers. More than one render between render init and complete suggests animation. blender.stackexchange.com/a/62870/15543 $\endgroup$
    – batFINGER
    Oct 2, 2018 at 11:32
  • $\begingroup$ I would like to automatically save still images and rename the output (e.g. scene = scene name, cam = cam name, etc.) There are 3 different cases: 1. Still Image 2. Animation - Output as movie file 3. Animation - Output as image sequence I couldnt just check the output file type because of case 3. I couldnt check the timeline length, too, one could also render one still frame from an animation. Also, first rendering an image sequence and renaming when finished is bad, as they wouldnt be renamed at all if the PC gets stuck somewhere in between. But thanks for the suggestion! $\endgroup$
    – morph3us
    Oct 8, 2018 at 7:09
  • $\begingroup$ Another is to create your own render operator that calls the old one. $\endgroup$
    – batFINGER
    Oct 8, 2018 at 7:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.