From e00f4b7008590db3de4cee47574445cbb4e10cf0 Mon Sep 17 00:00:00 2001 From: RrrrobertB1992 <40670302+RrrrobertB1992@users.noreply.github.com> Date: Mon, 26 Oct 2026 14:16:15 -0400 Subject: [PATCH] Moonraker printer agents: report a color list for every slot (#16630) Moonraker agents now send cols and ctype for every tray, the same fields the Bambu AMS sends. A single-color tray sends its one color with ctype 1. A multi-color spool sends all its colors once an agent fills the new AmsTrayData::tray_colors. Sending cols for every tray keeps update_filament_multi_color() from stopping at the first tray that has none. --- src/slic3r/Utils/MoonrakerPrinterAgent.cpp | 12 ++++++++++++ src/slic3r/Utils/MoonrakerPrinterAgent.hpp | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp index d59e5f9897..67289b85b6 100644 --- a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp +++ b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp @@ -533,6 +533,18 @@ void MoonrakerPrinterAgent::build_ams_payload(int ams_count, int max_lane_index, tray_json["tray_info_idx"] = tray->tray_info_idx; tray_json["tray_type"] = tray->tray_type; tray_json["tray_color"] = normalize_color_value(tray->tray_color); + // Sent for every tray, since update_filament_multi_color() stops at the first tray without "cols". + // "ctype" uses the filament_colour_type values (0 = gradient, 1 = solid or segments). + const bool multi = tray->tray_colors.size() > 1; + nlohmann::json cols = nlohmann::json::array(); + if (multi) { + for (const std::string& color : tray->tray_colors) + cols.push_back(normalize_color_value(color)); + } else { + cols.push_back(tray_json["tray_color"]); + } + tray_json["cols"] = cols; + tray_json["ctype"] = multi && tray->colors_gradient ? 0 : 1; // Add temperature data if provided if (tray->bed_temp > 0) { diff --git a/src/slic3r/Utils/MoonrakerPrinterAgent.hpp b/src/slic3r/Utils/MoonrakerPrinterAgent.hpp index 5388793cda..7159699189 100644 --- a/src/slic3r/Utils/MoonrakerPrinterAgent.hpp +++ b/src/slic3r/Utils/MoonrakerPrinterAgent.hpp @@ -102,6 +102,9 @@ protected: bool has_filament = false; std::string tray_type; // Material type (e.g., "PLA", "ASA") std::string tray_color; // Raw color (#RRGGBB, 0xRRGGBB, or RRGGBBAA) + std::vector tray_colors; // Optional: every color of a multi-color spool, in order (same formats). + // Used when it holds two or more; otherwise tray_color is the only one. + bool colors_gradient = false; // With tray_colors: blend them as a gradient instead of drawing segments std::string tray_info_idx; // Filament ID (optional) int bed_temp = 0; // Optional int nozzle_temp = 0; // Optional