2
$\begingroup$

My problem is as follows: I'm working on a script that renders all the scenes in a file (matching some criteria, in this case having a default Camera on Layer 0).

This works.

But I cannot make a Render option based on this.

The (bad) code is as follows

import bpy

class LoopRenderEngine(bpy.types.RenderEngine):
    bl_idname = 'loop_renderer'
    bl_label = 'Loop Renderer'

    def render(self, scene):
        #bpy.context.scene.render.engine = 'BLENDER_RENDER'
        bpy.ops.render.render()

bpy.utils.register_class(LoopRenderEngine)

Since this calls the render() function in when implementing the render() function, it's not a surprise that this doesn't work.

Switching back as mentioned above to the BLENER_RENDER engine didn't work.

Any idea how to render within the render function?

PS Here is the whole code to understand my intentions better.

import bpy
import time

class LoopRenderEngine(bpy.types.RenderEngine):
    bl_idname = 'loop_renderer'
    bl_label = 'Loop Render Test'
    bl_use_preview = True

    def render(self, scene):
        bpy.context.scene.render.engine='BLENDER_RENDER'
        bpy.ops.render.render()

bpy.utils.register_class(LoopRenderEngine)

This works (ie starts rendering), but crashes when rendering. The command line shows:

Error: EXCEPTION_ACCESS_VIOLATION

$\endgroup$
  • 1
    $\begingroup$ Do you really need a custom render engine, or are you just wanting to loop with whatever render engine will work? $\endgroup$ – Matt May 16 '16 at 18:18
  • $\begingroup$ you made render() recursive it will keep calling it self $\endgroup$ – Chebhou May 16 '16 at 18:24
  • $\begingroup$ 1. I understand that render() calls itself and it's a stupidity. 2. I don't want a truly custom render engine, but it would be practical to have it in the render engines' drop-down list, since it does the same as other render methods. This is the reason I want to register it as a render engine. 3. I was considering reaching the render() method of the parent RenderEngine class, but now I'm not sure about it. $\endgroup$ – Gyula Sámuel Karli May 16 '16 at 19:31
  • $\begingroup$ If all you need to do is loop through the scenes and render them than you probably want to use an operator. Render engines are more for connecting blender to external renderers. $\endgroup$ – Isaac May 19 '16 at 15:09
  • $\begingroup$ Actually that is the point I started from. What I'm curious about is whether I can include this function in the roll-down list of Blender renderers (Blender/Cycles/Game/Network). If it's not possible, I add a button to the Properties/Render and bind that button to a hotkey. $\endgroup$ – Gyula Sámuel Karli May 20 '16 at 16:44

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.