Fix nozzle diameter guards for printers that don't report nozzle info (#13255)

Fix nozzle diameter guards for printers that don't report nozzle info (#13236)

PR #12814 changed DevNozzle::m_diameter default from 0.4f to 0.0f to
mean "unknown" when firmware doesn't push nozzle info, and guarded two
call sites in SelectMachine.cpp. PR #13330 introduced
DevExtderSystem::NozzleDiameterMatchesOrUnknown() and adopted it in
get_printer_preset / CalibUtils / CalibrationWizardPresetPage. A few
reachable sites were still left out and now report "mismatch" / fail
silently for every non-BBL printer (Klipper/Moonraker, RRF, Marlin,
etc.) that doesn't push BBL nozzle data.

The most visible symptom: the "Sync filament colors from AMS" button on
Moonraker printers with AMS/AFC silently does nothing, because
get_printer_preset() couldn't find a matching system preset (fixed in
#13330, but the lookup-string sites below kept the bug visible
elsewhere).

Apply NozzleDiameterMatchesOrUnknown at the two remaining comparison
sites:

  src/slic3r/GUI/Plater.cpp
    - file-load printer-mismatch dialog — don't prompt on every load
    - on_select_preset sync_extruder_list gate — skip 0.0 extruders

For the three filament-lookup string-builder sites, fall back to the
currently-selected printer preset's nozzle diameter so the dropdown
isn't empty when firmware hasn't reported a diameter:

  src/slic3r/GUI/AMSMaterialsSetting.cpp (Popup + on_select_filament)
  src/slic3r/GUI/CaliHistoryDialog.cpp (get_all_filaments)

Also remove the dead SyncAmsInfoDialog::is_same_nozzle_diameters method
surfaced while auditing the affected sites — it was introduced
2024-12-30 in commit ad79ed6d93 ("ENH:add SyncAmsInfoDialog",
cherry-picked from Bambu's internal branch) but a caller was never
wired up on the OrcaSlicer side. Dead since introduction.

Fixes #13236
Refs #12814 #13330

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Clifford
2026-05-27 08:41:15 -04:00
committed by GitHub
parent 957d3017b4
commit 04aa26da9a
5 changed files with 31 additions and 60 deletions

View File

@@ -1912,58 +1912,6 @@ bool SyncAmsInfoDialog::is_blocking_printing(MachineObject *obj_)
return false;
}
bool SyncAmsInfoDialog::is_same_nozzle_diameters(NozzleType &tag_nozzle_type, float &nozzle_diameter)
{
bool is_same_nozzle_diameters = true;
float preset_nozzle_diameters;
std::string preset_nozzle_type;
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return true;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) return true;
try {
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
auto opt_nozzle_diameters = preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloats>("nozzle_diameter");
const ConfigOptionEnumsGenericNullable *nozzle_type = preset_bundle->printers.get_edited_preset().config.option<ConfigOptionEnumsGenericNullable>("nozzle_type");
std::vector<std::string> preset_nozzle_types(nozzle_type->size());
for (size_t idx = 0; idx < nozzle_type->size(); ++idx) preset_nozzle_types[idx] = NozzleTypeEumnToStr[NozzleType(nozzle_type->values[idx])];
std::vector<std::string> machine_nozzle_types(obj_->GetExtderSystem()->GetTotalExtderCount());
for (size_t idx = 0; idx < obj_->GetExtderSystem()->GetTotalExtderCount(); ++idx) machine_nozzle_types[idx] = obj_->GetExtderSystem()->GetNozzleType(idx);
auto used_filaments = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_filaments(); // 1 based
auto filament_maps = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_real_filament_maps(preset_bundle->project_config); // 1 based
std::vector<int> used_extruders; // 0 based
for (auto f : used_filaments) {
int filament_extruder = filament_maps[f - 1] - 1;
if (std::find(used_extruders.begin(), used_extruders.end(), filament_extruder) == used_extruders.end()) used_extruders.emplace_back(filament_extruder);
}
std::sort(used_extruders.begin(), used_extruders.end());
// TODO [tao wang] : add idx mapping
tag_nozzle_type = obj_->GetExtderSystem()->GetNozzleType(0);
if (opt_nozzle_diameters != nullptr) {
for (auto i = 0; i < used_extruders.size(); i++) {
auto extruder = used_extruders[i];
preset_nozzle_diameters = float(opt_nozzle_diameters->get_at(extruder));
if (preset_nozzle_diameters != obj_->GetExtderSystem()->GetNozzleDiameter(0)) { is_same_nozzle_diameters = false; }
}
}
} catch (...) {}
nozzle_diameter = preset_nozzle_diameters;
return is_same_nozzle_diameters;
}
bool SyncAmsInfoDialog::is_same_nozzle_type(std::string &filament_type, NozzleType &tag_nozzle_type)
{
bool is_same_nozzle_type = true;