From 7d8261668eeab042300eda42e17e8e7046885683 Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Thu, 8 Oct 2026 20:29:47 +0800 Subject: [PATCH] fix: use extruder count for bbl and m_nozzle_book for non bbl --- src/slic3r/GUI/Widgets/AMSControl.cpp | 24 +++++++++++++++--------- src/slic3r/GUI/Widgets/AMSControl.hpp | 5 +++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/Widgets/AMSControl.cpp b/src/slic3r/GUI/Widgets/AMSControl.cpp index bbdce0e12b..32bdf416fd 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.cpp +++ b/src/slic3r/GUI/Widgets/AMSControl.cpp @@ -671,6 +671,12 @@ void AMSControl::restore_legacy_ams_layout() m_down_road->SetNozzleCount(m_total_ext_count); } +bool AMSControl::use_multi_nozzle_layout() const +{ + const bool is_bbl = wxGetApp().preset_bundle && wxGetApp().preset_bundle->is_bbl_vendor(); + return is_bbl ? m_total_ext_count > 2 : m_nozzle_book != nullptr; +} + void AMSControl::CreateAmsMultiNozzle(const std::string &series_name, const std::string &printer_type) { const size_t pane_count = static_cast(std::max(m_total_ext_count, 0)); m_nozzle_panes.resize(pane_count); @@ -1286,9 +1292,9 @@ void AMSControl::AddAmsPreview(AMSinfo info, AMSModel type) { AMSPreview *ams_prv = nullptr; - // Match AddAms: the generic multi-nozzle layout's preview panel is the visible one at any - // extruder count, not only above two. - if (m_nozzle_book) { + // Match AddAms: the generic multi-nozzle layout's preview panel is the visible one for + // non-Bambu vendors at any extruder count, not only above two. + if (use_multi_nozzle_layout()) { const int nozzle_id = std::clamp(info.nozzle_id, 0, m_total_ext_count - 1); auto &pane = m_nozzle_panes[nozzle_id]; ams_prv = new AMSPreview(pane.preview_panel, wxID_ANY, info, type); @@ -1469,7 +1475,7 @@ void AMSControl::AddAms(AMSinfo info, AMSPanelPos pos) // The generic multi-nozzle layout (non-Bambu vendors) owns the only visible book; a unit must // land there for any extruder count. Keying off m_total_ext_count instead sent 1- and 2-extruder // generic printers into the legacy simplebooks that CreateAmsMultiNozzle hides. - if (m_nozzle_book) { + if (use_multi_nozzle_layout()) { const int nozzle_id = std::clamp(info.nozzle_id, 0, m_total_ext_count - 1); auto &pane = m_nozzle_panes[nozzle_id]; pane.item_ids.push_back(info.ams_id); @@ -1523,7 +1529,7 @@ void AMSControl::AddAms(std::vector single_info, const std::string &ser if (single_info.size() <= 0){ return; } - if (m_total_ext_count > 2) { + if (use_multi_nozzle_layout()) { const int nozzle_id = std::clamp(single_info.front().nozzle_id, 0, m_total_ext_count - 1); auto &pane = m_nozzle_panes[nozzle_id]; for (const auto &info : single_info) { @@ -1591,7 +1597,7 @@ void AMSControl::AddAms(std::vector single_info, const std::string &ser void AMSControl::AddAmsPreview(std::vectorsingle_info, AMSPanelPos pos) { if (single_info.size() <= 0) return; - if (m_total_ext_count > 2) { + if (use_multi_nozzle_layout()) { const int nozzle_id = std::clamp(single_info.front().nozzle_id, 0, m_total_ext_count - 1); auto &pane = m_nozzle_panes[nozzle_id]; for (const auto &info : single_info) { @@ -1672,7 +1678,7 @@ void AMSControl::SelectNozzle(int nozzle_id) void AMSControl::SwitchAms(std::string ams_id) { - if (m_total_ext_count > 2) { + if (use_multi_nozzle_layout()) { NozzleAmsPane *pane = nullptr; int nozzle_id = -1; for (int index = 0; index < static_cast(m_nozzle_panes.size()); ++index) { @@ -1877,7 +1883,7 @@ void AMSControl::SetExtruder(bool on_off, int nozzle_id, std::string ams_id, std AmsItem *item = nullptr; if (m_ams_item_list.find(ams_id) != m_ams_item_list.end()) { item = m_ams_item_list[ams_id]; } - if (m_total_ext_count > 2) { + if (use_multi_nozzle_layout()) { if (nozzle_id < 0 || nozzle_id >= static_cast(m_nozzle_panes.size())) return; @@ -2016,7 +2022,7 @@ void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadTy return; } - if (m_total_ext_count > 2) { + if (use_multi_nozzle_layout()) { const int nozzle_id = std::clamp(ams->get_nozzle_id(), 0, m_total_ext_count - 1); if (nozzle_id >= static_cast(m_nozzle_panes.size())) return; diff --git a/src/slic3r/GUI/Widgets/AMSControl.hpp b/src/slic3r/GUI/Widgets/AMSControl.hpp index 4d35d8326e..ef2b6e579c 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.hpp +++ b/src/slic3r/GUI/Widgets/AMSControl.hpp @@ -256,6 +256,11 @@ public: private: std::string get_filament_id(const std::string& ams_id, const std::string& can_id); + // True when AMS units are laid out on the generic multi-nozzle book. Bambu + // printers keep the legacy count-based single/double-nozzle layout at any + // extruder count; other vendors use the book created for them. + bool use_multi_nozzle_layout() const; + public: std::string m_current_select; };