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