def delete_object()

in tools.py [0:0]


def delete_object(context: Any, name: str) -> dict:
    try:
        view_area_3d = next(
            (area for area in context.screen.areas if area.type == "VIEW_3D"), None
        )
        if view_area_3d is None:
            raise RuntimeError("View 3D area not found")

        override = context.copy()
        override["area"] = view_area_3d

        with context.temp_override(**override):
            obj = bpy.data.objects.get(name)
            if not obj:
                raise ValueError(f"Object with name {name} not found")

            bpy.data.objects.remove(obj, do_unlink=True)
            return {"status": "success", "data": name}
    except Exception as e:
        print(f"Error in delete_object: {str(e)}")
        traceback.print_exc()
        return {"status": "error", "data": str(e)}