I need to do a loop cut on a mesh I've generated, so I found some code that works when I run Blender normally then the script. The catch is, I need it to work when I launch Blender from the command line and currently it causes an EXCEPTION_ACCESS_VIOLATION that crashes blender :(

Here is the code I'm using:

        bpy.context.view_layer.objects.active = argObject
        # setup a bunch of context for the loop cut operation
        region, rv3d, v3d, area = self.view3d_find(True)
        override = {
            'scene' : bpy.context.scene,
            'region': region,
        # perform the loop cut operation
            MESH_OT_loopcut = {
                "object_index": 0,
                "edge_index": 2,
                "mesh_select_mode_init":(True, False, False)
            TRANSFORM_OT_edge_slide = {
                "value": 0,
                "mirror": False,
                "snap": False,
                "snap_target": 'CLOSEST',
                "snap_point": (0,0,0),
                "snap_align": False,
                "snap_normal": (0,0,0),
                "correct_uv": False,
                "release_confirm": False,
                "use_accurate": False

Here's the error message I get in the command line:

Error : EXCEPTION_ACCESS_VIOLATION Address : 0x00007FF7193BE4C3 Module : blender.exe Thread : 00007ec0 Writing: C:\Users\Me\AppData\Local\Temp\MyBlend.crash.txt

I had a look in the crash log above for a thread with the id listed, but there was none :/

  • $\begingroup$ not sure why you have different properties in your override (like scene and space). but try to use these four (4) properties: window, screen, area, region as shown in this answer blender.stackexchange.com/a/270716/142292 . This one makes your code work. $\endgroup$ Aug 1, 2022 at 6:19
  • $\begingroup$ use override ={'window':bpy.context.window,'screen':bpy.context.window.screen,'area':area,'region': region}. and try to print(type(area), type(region)) and make sure they really are classes bpy.types.Area and bpy.types.Region $\endgroup$ Aug 1, 2022 at 6:35
  • $\begingroup$ and kindly share a link of your crash.txt log or paste the last few lines of the error in that crash.txt log. $\endgroup$ Aug 1, 2022 at 6:44
  • 1
    $\begingroup$ Awesome, I reckon that'll do it! I'll let you know how I go... $\endgroup$
    – ioflow
    Aug 1, 2022 at 7:24
  • 1
    $\begingroup$ Awesome work Harry, it's going :) $\endgroup$
    – ioflow
    Aug 3, 2022 at 12:56


You must log in to answer this question.

Browse other questions tagged .