em physics tools adicione a opção de limpar lista: bl_info = {
    "name": "Mesh Flexible Stacker + RigidBody Collision Shape",
    "blender": (3, 0, 0),
    "category": "Object",
}

import bpy
from bpy.props import (
    IntProperty, FloatProperty, EnumProperty, PointerProperty,
    StringProperty, FloatVectorProperty, BoolProperty, CollectionProperty
)
from bpy.types import Operator, Panel, PropertyGroup
from math import radians

preview_objs = []

def clear_preview():
    global preview_objs
    for obj in preview_objs:
        if obj and obj.name in bpy.data.objects:
            bpy.data.objects.remove(obj, do_unlink=True)
    preview_objs.clear()

class ManualObjectItem(PropertyGroup):
    object_ref: PointerProperty(
        name="Object",
        type=bpy.types.Object,
    )

class OBJECT_OT_clear_preview(Operator):
    bl_idname = "object.clear_preview"
    bl_label = "Clear Preview"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        clear_preview()
        return {'FINISHED'}

def create_preview(props):
    clear_preview()
    base_obj = None
    if props.mesh_type == "MESH":
        mesh_obj_original = bpy.data.objects.get(props.custom_mesh)
        if not mesh_obj_original or mesh_obj_original.type != "MESH":
            return

        depsgraph = bpy.context.evaluated_depsgraph_get()
        eval_obj = mesh_obj_original.evaluated_get(depsgraph)
        mesh_eval = eval_obj.to_mesh()
        mesh_copy = mesh_eval.copy()
        eval_obj.to_mesh_clear()

        tmp_obj = bpy.data.objects.new(mesh_obj_original.name + "_preview", mesh_copy)
        tmp_obj.matrix_world = mesh_obj_original.matrix_world.copy()
        base_obj = tmp_obj
    else:
        bpy.ops.object.select_all(action='DESELECT')
        primitive_map = {
            "CUBE": bpy.ops.mesh.primitive_cube_add,
            "SPHERE": bpy.ops.mesh.primitive_uv_sphere_add,
            "ICO_SPHERE": bpy.ops.mesh.primitive_ico_sphere_add,
            "CYLINDER": bpy.ops.mesh.primitive_cylinder_add,
            "CONE": bpy.ops.mesh.primitive_cone_add,
            "PLANE": bpy.ops.mesh.primitive_plane_add,
            "TORUS": bpy.ops.mesh.primitive_torus_add,
            "MONKEY": bpy.ops.mesh.primitive_monkey_add,
            "UV_SPHERE": bpy.ops.mesh.primitive_uv_sphere_add,
            "CIRCLE": bpy.ops.mesh.primitive_circle_add,
            "GRID": bpy.ops.mesh.primitive_grid_add,
        }
        func = primitive_map.get(props.mesh_type)
        if func is None:
            return
        func()
        base_obj = bpy.context.active_object

    rows = props.rows
    columns = props.columns
    if props.placement_mode == "FREE":
        start_loc = props.free_start_location
        inc1 = props.free_increment_vector1
        inc2 = props.free_increment_vector2
        for col in range(columns):
            for row in range(rows):
                new_obj = base_obj.copy()
                new_obj.data = base_obj.data.copy()
                new_obj.name = f"Preview_{row}_{col}"
                new_obj.location = (
                    start_loc[0] + inc1[0]*row + inc2[0]*col,
                    start_loc[1] + inc1[1]*row + inc2[1]*col,
                    start_loc[2] + inc1[2]*row + inc2[2]*col,
                )
                new_obj.scale = props.scale
                new_obj.rotation_euler = (
                    radians(props.rotation[0]),
                    radians(props.rotation[1]),
                    radians(props.rotation[2]),
                )
                new_obj.hide_render = True
                new_obj.show_in_front = True
                new_obj.hide_select = True
                new_obj.display_type = 'WIRE'
                bpy.context.collection.objects.link(new_obj)
                preview_objs.append(new_obj)
        bpy.data.objects.remove(tmp_obj, do_unlink=True)
    else:
        clear_preview()

def update_preview(self, context):
    props = context.scene.mesh_flexible_stacker_properties
    if props.placement_mode == "FREE":
        create_preview(props)
    else:
        clear_preview()

class MeshFlexibleStackerProperties(PropertyGroup):
    placement_mode: EnumProperty(
        name="Placement Mode",
        items=[
            ("GRID", "Grid", "Arrange objects in a grid."),
            ("FREE", "Free", "Arrange objects with custom offsets."),
        ],
        default="GRID",
        update=update_preview,
    )
    rows: IntProperty(name="Rows", default=5, min=1, max=100, update=update_preview)
    columns: IntProperty(name="Columns", default=3, min=1, max=100, update=update_preview)
    stack_axis: EnumProperty(name="Stack Axis", items=[("X","X",""), ("Y","Y",""), ("Z","Z","")], default="Z")
    spacing_vertical: FloatProperty(name="Vertical Spacing", default=2.0, min=0.1, max=100)
    spacing_horizontal: FloatProperty(name="Horizontal Spacing", default=3.0, min=0.1, max=100)
    free_start_location: FloatVectorProperty(name="Start Location", subtype='TRANSLATION', default=(0,0,0), update=update_preview)
    free_increment_vector1: FloatVectorProperty(name="Offset Vector 1", subtype='TRANSLATION', default=(0,0,2), update=update_preview)
    free_increment_vector2: FloatVectorProperty(name="Offset Vector 2", subtype='TRANSLATION', default=(3,0,0), update=update_preview)
    scale: FloatVectorProperty(name="Scale", subtype='XYZ', default=(1,1,1), update=update_preview)
    rotation: FloatVectorProperty(name="Rotation", subtype='EULER', default=(0,0,0), update=update_preview)

    apply_rigid_body: BoolProperty(name="Apply Rigid Body", default=False)
    collision_shape: EnumProperty(
        name="Collision Shape",
        description="Type of collision shape to apply",
        items=[
            ('BOX', "Box", ""),
            ('SPHERE', "Sphere", ""),
            ('CAPSULE', "Capsule", ""),
            ('CYLINDER', "Cylinder", ""),
            ('CONE', "Cone", ""),
            ('MESH', "Mesh", ""),
            ('CONVEX_HULL', "Convex Hull", ""),
        ],
        default='BOX',
    )
    mesh_type: EnumProperty(name="Mesh Type", items=[
            ("CUBE","Cube",""), ("SPHERE","Sphere",""), ("CYLINDER","Cylinder",""),
            ("CONE","Cone",""), ("PLANE","Plane",""), ("TORUS","Torus",""),
            ("MONKEY","Monkey",""), ("UV_SPHERE","UV Sphere",""),
            ("ICO_SPHERE","Ico Sphere",""), ("CIRCLE","Circle",""),
            ("GRID","Grid",""), ("MESH","Custom Mesh","")
        ], default="CUBE")
    custom_mesh: StringProperty(name="Custom Mesh", description="Name of the custom mesh object to use.", default="")
    custom_mesh_mode: EnumProperty(name="Custom Mesh Mode", description="How to use the custom mesh object",
                                  items=[("LIVE","Live Object","Use the custom mesh as in scene"),
                                         ("APPLIED","Applied Copy", "Copy with modifiers applied")],
                                  default="LIVE", update=update_preview)
    manual_objects: CollectionProperty(type=ManualObjectItem)
    manual_objects_index: IntProperty(default=0)
    color: FloatVectorProperty(name="Color", subtype='COLOR', size=3, default=(1,1,1), min=0, max=1, update=update_preview)

class OBJECT_OT_generate_stack(Operator):
    bl_idname = "object.generate_stack"
    bl_label = "Generate Stack"
    bl_options = {'REGISTER','UNDO'}
    def execute(self, context):
        props = context.scene.mesh_flexible_stacker_properties

        clear_preview()
        mesh_obj = None
        tmp_obj = None

        if props.mesh_type == "MESH":
            mesh_obj_original = bpy.data.objects.get(props.custom_mesh)
            if not mesh_obj_original or mesh_obj_original.type != "MESH":
                self.report({'ERROR'}, "Custom mesh not found or not a mesh type")
                return {'CANCELLED'}

            if props.custom_mesh_mode == "APPLIED":
                depsgraph = bpy.context.evaluated_depsgraph_get()
                eval_obj = mesh_obj_original.evaluated_get(depsgraph)
                mesh_eval = eval_obj.to_mesh()
                mesh_copy = mesh_eval.copy()
                eval_obj.to_mesh_clear()
                tmp_obj = bpy.data.objects.new(mesh_obj_original.name + "_eval", mesh_copy)
                tmp_obj.matrix_world = mesh_obj_original.matrix_world.copy()
                base_obj = tmp_obj
            else:
                base_obj = mesh_obj_original
        else:
            bpy.ops.object.select_all(action='DESELECT')
            map_mesh = {
                "CUBE": bpy.ops.mesh.primitive_cube_add,
                "SPHERE": bpy.ops.mesh.primitive_uv_sphere_add,
                "ICO_SPHERE": bpy.ops.mesh.primitive_ico_sphere_add,
                "CYLINDER": bpy.ops.mesh.primitive_cylinder_add,
                "CONE": bpy.ops.mesh.primitive_cone_add,
                "PLANE": bpy.ops.mesh.primitive_plane_add,
                "TORUS": bpy.ops.mesh.primitive_torus_add,
                "MONKEY": bpy.ops.mesh.primitive_monkey_add,
                "UV_SPHERE": bpy.ops.mesh.primitive_uv_sphere_add,
                "CIRCLE": bpy.ops.mesh.primitive_circle_add,
                "GRID": bpy.ops.mesh.primitive_grid_add,
            }
            func = map_mesh.get(props.mesh_type)
            if func is None:
                self.report({'ERROR'}, "Mesh type not supported")
                return {'CANCELLED'}
            func()
            base_obj = context.active_object

        mat = bpy.data.materials.new(name="StackMaterial")
        mat.use_nodes = True
        bsdf = mat.node_tree.nodes.get("Principled BSDF")
        if bsdf:
            bsdf.inputs["Base Color"].default_value = (*props.color, 1.0)
        base_obj.data.materials.clear()
        base_obj.data.materials.append(mat)

        def set_transform(obj):
            obj.scale = props.scale
            obj.rotation_euler = (
                radians(props.rotation[0]),
                radians(props.rotation[1]),
                radians(props.rotation[2]),
            )

        def apply_rigidbody(obj):
            bpy.context.view_layer.objects.active = obj
            bpy.ops.rigidbody.object_add()
            obj.rigid_body.type = 'ACTIVE'
            obj.rigid_body.mass = 1.0
            obj.rigid_body.collision_shape = props.collision_shape

        if props.placement_mode == "GRID":
            rows = props.rows
            columns = props.columns
            spacing_v = props.spacing_vertical
            spacing_h = props.spacing_horizontal
            stack_axis = props.stack_axis
            axes = ['X', 'Y', 'Z']
            h_axis = axes[(axes.index(stack_axis) + 1) % 3]

            for col in range(columns):
                for row in range(rows):
                    new_obj = base_obj.copy()
                    if props.custom_mesh_mode == "APPLIED" or props.mesh_type != "MESH":
                        new_obj.data = base_obj.data.copy()
                    new_obj.name = f"Stack_{row}_{col}"
                    loc = [0.0, 0.0, 0.0]

                    if stack_axis == "X":
                        loc[0] = row * spacing_v
                    elif stack_axis == "Y":
                        loc[1] = row * spacing_v
                    else:
                        loc[2] = row * spacing_v

                    if h_axis == "X":
                        loc[0] += col * spacing_h
                    elif h_axis == "Y":
                        loc[1] += col * spacing_h
                    else:
                        loc[2] += col * spacing_h

                    new_obj.location = loc
                    set_transform(new_obj)
                    context.collection.objects.link(new_obj)

                    if props.apply_rigid_body:
                        apply_rigidbody(new_obj)

        else:
            rows = props.rows
            columns = props.columns
            start_loc = props.free_start_location
            inc1 = props.free_increment_vector1
            inc2 = props.free_increment_vector2

            for col in range(columns):
                for row in range(rows):
                    new_obj = base_obj.copy()
                    if props.custom_mesh_mode == "APPLIED" or props.mesh_type != "MESH":
                        new_obj.data = base_obj.data.copy()
                    new_obj.name = f"Stack_{row}_{col}"
                    loc = (
                        start_loc[0] + inc1[0]*row + inc2[0]*col,
                        start_loc[1] + inc1[1]*row + inc2[1]*col,
                        start_loc[2] + inc1[2]*row + inc2[2]*col,
                    )
                    new_obj.location = loc
                    set_transform(new_obj)
                    context.collection.objects.link(new_obj)

                    if props.apply_rigid_body:
                        apply_rigidbody(new_obj)

        if tmp_obj:
            bpy.data.objects.remove(tmp_obj, do_unlink=True)

        return {'FINISHED'}

class MFS_UL_manual_objects(bpy.types.UIList):
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
        obj = item.object_ref
        if obj:
            layout.prop(obj, "name", text="", emboss=False, icon='OBJECT_DATA')
        else:
            layout.label(text="Missing object", icon='ERROR')

class MFS_OT_add_manual_object(Operator):
    bl_idname = "mfs.add_manual_object"
    bl_label = "Add Selected Object"
    def execute(self, context):
        props = context.scene.mesh_flexible_stacker_properties
        obj = context.active_object
        if not obj:
            self.report({'WARNING'}, "No active object selected")
            return {'CANCELLED'}
        if any(item.object_ref == obj for item in props.manual_objects):
            self.report({'INFO'}, "Object already added")
            return {'FINISHED'}
        item = props.manual_objects.add()
        item.object_ref = obj
        props.manual_objects_index = len(props.manual_objects) - 1
        return {'FINISHED'}

class MFS_OT_remove_manual_object(Operator):
    bl_idname = "mfs.remove_manual_object"
    bl_label = "Remove Selected Object"
    def execute(self, context):
        props = context.scene.mesh_flexible_stacker_properties
        idx = props.manual_objects_index
        if 0 <= idx < len(props.manual_objects):
            props.manual_objects.remove(idx)
            props.manual_objects_index = min(max(0, idx -1), len(props.manual_objects)-1)
        return {'FINISHED'}

class MFS_OT_add_selected_objects(Operator):
    bl_idname = "mfs.add_selected_objects"
    bl_label = "Add Selected Objects"
    bl_description = "Add all selected mesh objects to the manual list"
    def execute(self, context):
        props = context.scene.mesh_flexible_stacker_properties
        selected = context.selected_objects
        added = 0
        for obj in selected:
            if obj.type != 'MESH':
                continue
            if any(item.object_ref == obj for item in props.manual_objects):
                continue
            item = props.manual_objects.add()
            item.object_ref = obj
            added += 1
        if added == 0:
            self.report({'INFO'}, "No new mesh objects added.")
        else:
            self.report({'INFO'}, f"Added {added} object(s) to manual list.")
        props.manual_objects_index = len(props.manual_objects) - 1
        return {'FINISHED'}

class MFS_OT_apply_rigidbody_manual(Operator):
    bl_idname = "mfs.apply_rigidbody_manual"
    bl_label = "Apply Rigid Body to Manual Objects"
    def execute(self, context):
        props = context.scene.mesh_flexible_stacker_properties
        count = 0
        for item in props.manual_objects:
            obj = item.object_ref
            if obj and not obj.rigid_body:
                bpy.context.view_layer.objects.active = obj
                bpy.ops.rigidbody.object_add()
                obj.rigid_body.type = 'ACTIVE'
                obj.rigid_body.mass = 1.0
                obj.rigid_body.collision_shape = props.collision_shape
                count += 1
        self.report({'INFO'}, f"Rigid Body applied to {count} object(s).")
        return {'FINISHED'}

class MFS_OT_remove_rigidbody_manual(Operator):
    bl_idname = "mfs.remove_rigidbody_manual"
    bl_label = "Remove Rigid Body from Manual Objects"
    def execute(self, context):
        props = context.scene.mesh_flexible_stacker_properties
        count = 0
        for item in props.manual_objects:
            obj = item.object_ref
            if obj and obj.rigid_body:
                bpy.context.view_layer.objects.active = obj
                bpy.ops.rigidbody.object_remove()
                count += 1
        self.report({'INFO'}, f"Rigid Body removed from {count} object(s).")
        return {'FINISHED'}

class OBJECT_PT_manual_rigidbody_panel(bpy.types.Panel):
    bl_label = "Manual Rigid Body Applier"
    bl_idname = "OBJECT_PT_manual_rigidbody"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "Physics Tools"
    def draw(self, context):
        layout = self.layout
        props = context.scene.mesh_flexible_stacker_properties
        row = layout.row()
        row.template_list("MFS_UL_manual_objects", "", props, "manual_objects", props, "manual_objects_index", rows=5)
        col = row.column(align=True)
        col.operator("mfs.add_manual_object", icon='ADD', text="")
        col.operator("mfs.remove_manual_object", icon='REMOVE', text="")
        layout.operator("mfs.add_selected_objects", icon='GROUP', text="Add All Selected")
        layout.separator()
        layout.operator("mfs.apply_rigidbody_manual", icon='PHYSICS')
        layout.operator("mfs.remove_rigidbody_manual", icon='X')

class OBJECT_PT_mesh_flexible_stacker_panel(bpy.types.Panel):
    bl_label = "Mesh Flexible Stacker"
    bl_idname = "OBJECT_PT_mesh_flexible_stacker"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "Mesh Stacker"
    def draw(self, context):
        layout = self.layout
        props = context.scene.mesh_flexible_stacker_properties
        layout.prop(props, "placement_mode")
        if props.placement_mode == "GRID":
            layout.prop(props, "rows")
            layout.prop(props, "columns")
            layout.prop(props, "stack_axis")
            layout.prop(props, "spacing_vertical")
            layout.prop(props, "spacing_horizontal")
        else:
            layout.prop(props, "rows")
            layout.prop(props, "columns")
            layout.prop(props, "free_start_location")
            layout.prop(props, "free_increment_vector1")
            layout.prop(props, "free_increment_vector2")
        layout.separator()
        layout.prop(props, "scale")
        layout.prop(props, "rotation")
        layout.separator()
        layout.prop(props, "mesh_type")
        if props.mesh_type == "MESH":
            layout.prop_search(props, "custom_mesh", bpy.data, "objects", text="Custom Mesh")
            layout.prop(props, "custom_mesh_mode")
        layout.prop(props, "color")
        layout.prop(props, "apply_rigid_body", text="Apply Rigid Body on Generation")
        layout.prop(props, "collision_shape")
        layout.separator()
        layout.operator("object.generate_stack", icon="MESH_CUBE")
        layout.operator("object.clear_preview", icon="CANCEL")

classes = (
    ManualObjectItem,
    MeshFlexibleStackerProperties,
    OBJECT_OT_generate_stack,
    OBJECT_OT_clear_preview,
    MFS_OT_add_manual_object,
    MFS_OT_remove_manual_object,
    MFS_OT_add_selected_objects,
    MFS_OT_apply_rigidbody_manual,
    MFS_OT_remove_rigidbody_manual,
    MFS_UL_manual_objects,
    OBJECT_PT_manual_rigidbody_panel,
    OBJECT_PT_mesh_flexible_stacker_panel,
)

def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    bpy.types.Scene.mesh_flexible_stacker_properties = PointerProperty(type=MeshFlexibleStackerProperties)

def unregister():
    for cls in reversed(classes):
        bpy.utils.unregister_class(cls)
    del bpy.types.Scene.mesh_flexible_stacker_properties

if __name__ == "__main__":
    register()