Working on a slice & mirror modifier combo script (a la 3ds max). Unable to stack modifiers. [Beginner] I've made a crude script to combine Boolean and Mirror modifiers and have the whole thing controlled by an Empty. The goal was to basically have a 3dsMax-like modifier that has a slice plane that can be rotated. This is useful for architectural corner pieces etc. The script works in general, but I'm unable to stack the modifiers. I'd like to be able to use it three or four times in a row on top of each other. I'm suspecting the way I am naming the objects starts to conflict when I try to use the script twice in a row. Could anyone have a look and recommend how to build this script so it would be stackable? Any other notes welcome too. If you wanna add a shortcut just install the add-on and use halfbool.mirror2 as the identifier. Thanks.

bl_info = {
    "name": "Half Bool Mirror 2",
    "category": "Object",
}

import bpy


class HalfBoolMirror2(bpy.types.Operator):
    """Half Bool Mirror WIP"""      # blender will use this as a tooltip for menu items and buttons.
    bl_idname = "halfbool.mirror2"        # unique identifier for buttons and menu items to reference.
    bl_label = "Half Bool Mirror 2"         # display name in the interface.
    bl_options = {'REGISTER', 'UNDO'}  # enable undo for the operator.

    def execute(self, context):        # execute() is called by blender when running the operator.

        # The original script


        mirobj = bpy.context.active_object
        bpy.ops.mesh.primitive_plane_add(radius=1000, view_align=False, enter_editmode=False, rotation=(1.5708, 0, 0))
        bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
        bpy.context.object.draw_type = 'BOUNDS'
        boolbox = bpy.context.active_object
        bpy.ops.object.empty_add(type='CIRCLE', radius=1, view_align=False)
        bpy.context.object.show_x_ray = True
        bpy.context.object.empty_draw_size = 4
        handleobj = bpy.context.active_object
        bpy.ops.object.select_all(action='DESELECT')
        boolbox.select = True
        handleobj.select = True
        bpy.context.scene.objects.active = handleobj
        bpy.ops.object.parent_set(type='OBJECT', keep_transform=False)
        mirobj.select = True
        bpy.context.scene.objects.active = mirobj

        bpy.ops.object.modifier_add(type='BOOLEAN')
        bpy.context.object.modifiers["Boolean"].operation = 'DIFFERENCE'
        bpy.context.object.modifiers["Boolean"].solver = 'CARVE'
        bpy.context.object.modifiers["Boolean"].object = boolbox

        bpy.ops.object.modifier_add(type='MIRROR')
        bpy.context.object.modifiers["Mirror"].use_x = False
        bpy.context.object.modifiers["Mirror"].use_y = True
        bpy.context.object.modifiers["Mirror"].use_z = False
        bpy.context.object.modifiers["Mirror"].mirror_object = handleobj
        bpy.ops.object.select_all(action='DESELECT')
        handleobj.select = True
        bpy.context.scene.objects.active = handleobj

        return {'FINISHED'}            # this lets blender know the operator finished successfully.

def register():
    bpy.utils.register_class(HalfBoolMirror2)


def unregister():
    bpy.utils.unregister_class(HalfBoolMirror2)


# This allows you to run the script directly from blenders text editor
# to test the addon without having to install it.

if __name__ == "__main__":
    register()
When you add the second boolean modifier, it is automatically named as Boolean.001, but then you change the properties of the first one you added, named "Boolean", by using bpy.context.object.modifiers["Boolean"].

Instead, add the modifiers like this:

    boolean_modifier = mirobj.modifiers.new('Boolean', 'BOOLEAN')


The first parameters is the name of the new modifier, the second is the type: bpy.types.ObjectModifiers

And then change the properties like this:

    boolean_modifier.operation = 'DIFFERENCE'
    boolean_modifier.solver = 'CARVE'
    etc...


This way, even if it's automatically renamed to Boolean.001, you will be editing the properties of the modifier you just added.
Same for the mirror modifier.