From 6fe27304c835ca94066f6014b16016a5e44577e7 Mon Sep 17 00:00:00 2001 From: viewit Date: Sun, 31 May 2026 20:03:11 +0200 Subject: [PATCH] =?UTF-8?q?fix(moonraker):=20Vendor-Match=20auch=20f=C3=BC?= =?UTF-8?q?r=20inkompatible/nicht-instantiierbare=20Base-Presets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass 1: kompatible + sichtbare Presets (wie bisher) Pass 2 (neu): wenn Pass 1 leer → alle Base-Presets des Vendors + Typs durchsuchen, unabhängig von is_compatible/is_visible. Behebt: Elegoo PLA (@base, instantiation=false) und ähnliche Hersteller die ein globales Base-Preset haben aber kein druckerspezifisches Profil für den Kobra X → bisher immer "Generic PLA", jetzt "Elegoo PLA". Co-Authored-By: Claude Sonnet 4.6 --- src/slic3r/Utils/MoonrakerPrinterAgent.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp index 7cc53d8b0a0..2624bc038e9 100644 --- a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp +++ b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp @@ -60,6 +60,7 @@ std::string find_closest_color_preset_by_vendor_and_type(const Slic3r::PresetCol unsigned int target = parse_color(color_rgba); + // Pass 1: compatible + visible presets (ideal match) for (const auto& p : filaments.get_presets()) { if (!(p.is_visible && p.is_compatible)) continue; if (filaments.get_preset_base(p) != &p) continue; @@ -76,6 +77,25 @@ std::string find_closest_color_preset_by_vendor_and_type(const Slic3r::PresetCol best_match_id = p.filament_id; } } + if (!best_match_id.empty()) return best_match_id; + + // Pass 2: fallback — any base preset matching vendor+type, even if not compatible/instantiatable. + // Covers vendors like Elegoo that have a @base preset but no printer-specific variant for this printer. + for (const auto& p : filaments.get_presets()) { + if (p.config.opt_string("filament_vendor", 0u) != vendor_name) continue; + if (p.config.opt_string("filament_type", 0u) != filament_type) continue; + if (p.filament_id.empty()) continue; + + unsigned int pc = parse_color(p.config.opt_string("default_filament_colour", 0u)); + int dr = ((target ) & 0xff) - ((pc ) & 0xff); + int dg = ((target >> 8) & 0xff) - ((pc >> 8) & 0xff); + int db = ((target >> 16) & 0xff) - ((pc >> 16) & 0xff); + unsigned int distance = dr * dr + dg * dg + db * db; + if (distance < (unsigned int)best_color_distance) { + best_color_distance = (int)distance; + best_match_id = p.filament_id; + } + } return best_match_id; }