From b5fb069c548d17d109193f6eb98c12e3f822cf22 Mon Sep 17 00:00:00 2001 From: viewit Date: Tue, 2 Jun 2026 12:43:57 +0200 Subject: [PATCH] =?UTF-8?q?fix(moonraker):=20Zwei-Pass-Suche=20in=20filame?= =?UTF-8?q?nt=5Fid=5Fby=5Fname=20=E2=80=94=20kompatibel=20first,=20dann=20?= =?UTF-8?q?alle=20sichtbaren?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass 1: nur is_compatible Presets (wie bisher) Pass 2: alle sichtbaren Presets unabhängig von is_compatible Behebt: Hersteller wie eSUN, Eryone, Elegoo haben globale Base-Presets aber keine druckerspezifischen Profile für den Kobra X → is_compatible=false → bisher immer Generic PLA. Mit Pass 2 werden diese Base-Presets als Fallback gefunden. --- src/slic3r/Utils/MoonrakerPrinterAgent.cpp | 70 +++++++++++++--------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp index c5eaccaf324..ae0b1e95ca6 100644 --- a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp +++ b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp @@ -185,37 +185,53 @@ std::string filament_id_by_name(const Slic3r::PresetCollection& filaments, BOOST_LOG_TRIVIAL(debug) << "MoonrakerPrinterAgent: filament matcher lookup requested='" << filament_name << "' normalized='" << wanted << "' vendor_filters=" << normalized_vendor_filters.size(); - for (size_t i = 0; i < filaments.size(); ++i) { - const auto& preset = filaments.preset(i); - if (!preset.is_visible || !preset.is_compatible || preset.filament_id.empty()) { - BOOST_LOG_TRIVIAL(debug) << "MoonrakerPrinterAgent: filament matcher skip preset='" << preset.name - << "' visible=" << preset.is_visible << " compatible=" << preset.is_compatible - << " filament_id_empty=" << preset.filament_id.empty(); - continue; - } - if (!normalized_vendor_filters.empty()) { - const std::string preset_vendor = normalize_filament_name_for_match(preset.config.opt_string("filament_vendor", 0u)); - bool vendor_match = false; - for (const auto& vendor_filter : normalized_vendor_filters) { - if (preset_vendor == vendor_filter) { - vendor_match = true; - break; + + // Two-pass search: Pass 1 = compatible presets only (ideal), Pass 2 = all visible presets + // (fallback for vendors like eSUN/Eryone that have no printer-specific Kobra X profile). + for (int pass = 1; pass <= 2; ++pass) { + for (size_t i = 0; i < filaments.size(); ++i) { + const auto& preset = filaments.preset(i); + if (!preset.is_visible || preset.filament_id.empty()) { + if (pass == 1) { + BOOST_LOG_TRIVIAL(debug) << "MoonrakerPrinterAgent: filament matcher skip preset='" << preset.name + << "' visible=" << preset.is_visible + << " filament_id_empty=" << preset.filament_id.empty(); } - } - if (!vendor_match) { - BOOST_LOG_TRIVIAL(debug) << "MoonrakerPrinterAgent: filament matcher skip preset='" << preset.name - << "' reason=vendor_filter_miss preset_vendor='" << preset_vendor << "'"; continue; } + if (pass == 1 && !preset.is_compatible) { + continue; // Pass 1: only compatible presets + } + if (!normalized_vendor_filters.empty()) { + const std::string preset_vendor = normalize_filament_name_for_match(preset.config.opt_string("filament_vendor", 0u)); + bool vendor_match = false; + for (const auto& vendor_filter : normalized_vendor_filters) { + if (preset_vendor == vendor_filter) { + vendor_match = true; + break; + } + } + if (!vendor_match) { + if (pass == 1) { + BOOST_LOG_TRIVIAL(debug) << "MoonrakerPrinterAgent: filament matcher skip preset='" << preset.name + << "' reason=vendor_filter_miss preset_vendor='" << preset_vendor << "'"; + } + continue; + } + } + const std::string candidate = normalize_filament_name_for_match(preset.name); + BOOST_LOG_TRIVIAL(debug) << "MoonrakerPrinterAgent: filament matcher compare (pass=" << pass << ") preset='" << preset.name + << "' normalized='" << candidate << "' filament_id='" << preset.filament_id << "'"; + if (filament_name_match_relaxed(wanted, candidate)) { + BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent: filament matcher matched (pass=" << pass << ") requested='" << filament_name + << "' normalized='" << wanted << "' to preset='" << preset.name + << "' filament_id='" << preset.filament_id << "'"; + return preset.filament_id; + } } - const std::string candidate = normalize_filament_name_for_match(preset.name); - BOOST_LOG_TRIVIAL(debug) << "MoonrakerPrinterAgent: filament matcher compare preset='" << preset.name - << "' normalized='" << candidate << "' filament_id='" << preset.filament_id << "'"; - if (filament_name_match_relaxed(wanted, candidate)) { - BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent: filament matcher matched requested='" << filament_name - << "' normalized='" << wanted << "' to preset='" << preset.name - << "' filament_id='" << preset.filament_id << "'"; - return preset.filament_id; + if (pass == 1) { + BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent: filament matcher pass 1 (compatible) found no match for '" + << filament_name << "', trying pass 2 (all visible)"; } } BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent: filament matcher found no match for requested='" << filament_name