Can loopcuts be made when Blender is in background with the "-b" option? I am trying to make loopcuts on an object in a Python script running Blender 2.77a in the background with the "-b" commandline option. If I don't override the context I get this error:

bpy.ops.mesh.loopcut.poll() expected a view3d region &amp; editmesh

There is an answer for this here on StackExchange:

How do I override context for bpy.ops.mesh.loopcut?

...and the loopcut override works when Blender is in the foreground. But when using the technique in the background, this error comes up:

wmSubWindowScissorSet 0: doesn't exist

...and Blender crashes. Online searches don't help on this, I could find no solution. That leads me to the question - can this be done? How can the context be overrriden so that it will work in the background?

My context override is done like so:

def context_override():
    for window in bpy.context.window_manager.windows:
        screen = window.screen
        for area in screen.areas:
            if area.type == "VIEW_3D":
                for region in area.regions:
                    if region.type == "WINDOW":
                        ctx = bpy.context.copy()
                        ctx["window"] = window
                        ctx["screen"] = screen
                        ctx["area"] = area
                        ctx["region"] = region
                        ctx["scene"] = bpy.context.scene
                        return ctx
It's actually quite simple:
You can't use operators in background mode.

When Blender is in background mode or you use Blender as a Python module, then the context does not work as usual, because it doesn't exist. There has to be a 3D viewport etc. for the context to work but all of those things don't exist in background mode.

The solution is to use the internal functions of the operator you are trying to use. But if this operator does not use internal functions you are out of luck.

I got this info from a youtube video where the blender devs answered questions (at about 11 minutes in).