1

A boolean modifier that was working is now throwing an error in Blender 4.0.1

raise ValueError("1-2 args execution context is supported")

bpy.context.view_layer.objects.active = bpy.data.objects['resX']
context = bpy.context
        scene = context.scene
        resX = scene.objects.get("resX")
        resCut = scene.objects.get("resCut")
        if resX and resCut:
            bool = resX.modifiers.new(name='bool', type='BOOLEAN')
            bool.object = resCut
            bool.operation = 'DIFFERENCE'
            bpy.ops.object.modifier_apply(
                    {"object": resX},
                    modifier=bool.name)

Error throws at the 3rd from last line: bpy.ops.object.modifier_apply

So the boolean is activated, set to Difference, but throws an error during the apply function from what I can tell. I cannot as of yet look into this via the Blender documentation due to the servers being down.

Increality
  • 411
  • 3
  • 14

1 Answers1

1

No need to override context here: {"object": resX} in bpy.ops.object.modifier_apply()

Operator only needs the active object (with modifier) as set in line 1

bpy.context.view_layer.objects.active = bpy.data.objects['resX']
context = bpy.context
scene = context.scene
resX = scene.objects.get("resX")
resCut = scene.objects.get("resCut")
if resX and resCut:
    bool = resX.modifiers.new(name='bool', type='BOOLEAN')
    bool.object = resCut
    bool.operation = 'DIFFERENCE'
    bpy.ops.object.modifier_apply(modifier=bool.name)
relaxed
  • 2,267
  • 6
  • 15