From 5ba71e1198ef7352f6de1f7da21f70db182dae45 Mon Sep 17 00:00:00 2001 From: Kevin Lynagh Date: Mon, 6 Apr 2026 06:40:36 +0200 Subject: [PATCH] Allow printing even if nozzle info isn't reported by firmware. (#12814) * Don't assume 0.4mm nozzle; format as "unknown" if not defined. * Skip nozzle diameter and hardness checks if nozzle info unknown. --------- Co-authored-by: SoftFever --- src/slic3r/GUI/DeviceCore/DevNozzleSystem.h | 2 +- src/slic3r/GUI/GUI_Utils.cpp | 10 +++++++ src/slic3r/GUI/GUI_Utils.hpp | 1 + src/slic3r/GUI/PrintOptionsDialog.cpp | 14 +++++----- src/slic3r/GUI/PrintOptionsDialog.hpp | 3 +-- src/slic3r/GUI/SelectMachine.cpp | 29 ++++++++++++++++----- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h index 1dbff547b2..db786cf966 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h +++ b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h @@ -15,7 +15,7 @@ namespace Slic3r int m_nozzle_id = -1; NozzleFlowType m_nozzle_flow = NozzleFlowType::S_FLOW;// 0-common 1-high flow NozzleType m_nozzle_type = NozzleType::ntUndefine;// 0-stainless_steel 1-hardened_steel 5-tungsten_carbide - float m_diameter = 0.4f;// 0.2mm 0.4mm 0.6mm 0.8mm + float m_diameter = 0.0f;// unknown until reported by the printer }; class DevNozzleSystem diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index 5d7dde4d93..3f60f4a409 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -1,6 +1,7 @@ #include "GUI.hpp" #include "GUI_Utils.hpp" #include "GUI_App.hpp" +#include "I18N.hpp" #include #include @@ -32,6 +33,15 @@ wxDEFINE_EVENT(EVT_VOLUME_ATTACHED, VolumeAttachedEvent); wxDEFINE_EVENT(EVT_VOLUME_DETACHED, VolumeDetachedEvent); #endif // _WIN32 +wxString format_nozzle_diameter(float diameter) +{ + if (diameter <= 0.0f) { + return _L("Unknown"); + } + + return wxString::Format("%smm", wxString::FromDouble(diameter)); +} + CopyFileResult copy_file_gui(const std::string &from, const std::string &to, std::string& error_message, const bool with_check) { #ifdef WIN32 diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index a3c6d1ce64..7e62d00c23 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -66,6 +66,7 @@ wxDECLARE_EVENT(EVT_VOLUME_DETACHED, VolumeDetachedEvent); #endif /* _WIN32 */ wxTopLevelWindow* find_toplevel_parent(wxWindow *window); +wxString format_nozzle_diameter(float diameter); void on_window_geometry(wxTopLevelWindow *tlw, std::function callback); diff --git a/src/slic3r/GUI/PrintOptionsDialog.cpp b/src/slic3r/GUI/PrintOptionsDialog.cpp index f6681e9d7a..3268a6ee9c 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.cpp +++ b/src/slic3r/GUI/PrintOptionsDialog.cpp @@ -1345,7 +1345,7 @@ bool PrinterPartsDialog::Show(bool show) auto type = obj->GetExtderSystem()->GetNozzleType(MAIN_EXTRUDER_ID); auto diameter = obj->GetExtderSystem()->GetNozzleDiameter(MAIN_EXTRUDER_ID); nozzle_type_checkbox->SetValue(GetString(type)); - nozzle_diameter_checkbox->SetValue(GetString(diameter)); + nozzle_diameter_checkbox->SetValue(format_nozzle_diameter(diameter)); // nozzle flow type nozzle_flow_type_label->Show(obj->is_nozzle_flow_type_supported()); @@ -1369,7 +1369,7 @@ bool PrinterPartsDialog::Show(bool show) auto diameter = obj->GetExtderSystem()->GetNozzleDiameter(DEPUTY_EXTRUDER_ID); auto flow_type = obj->GetExtderSystem()->GetNozzleFlowType(DEPUTY_EXTRUDER_ID); multiple_left_nozzle_type_checkbox->SetValue(GetString(type)); - multiple_left_nozzle_diameter_checkbox->SetValue(GetString(diameter)); + multiple_left_nozzle_diameter_checkbox->SetValue(format_nozzle_diameter(diameter)); multiple_left_nozzle_flow_checkbox->SetValue(GetString(flow_type)); //right @@ -1377,7 +1377,7 @@ bool PrinterPartsDialog::Show(bool show) diameter = obj->GetExtderSystem()->GetNozzleDiameter(MAIN_EXTRUDER_ID); flow_type = obj->GetExtderSystem()->GetNozzleFlowType(MAIN_EXTRUDER_ID); multiple_right_nozzle_type_checkbox->SetValue(GetString(type)); - multiple_right_nozzle_diameter_checkbox->SetValue(GetString(diameter)); + multiple_right_nozzle_diameter_checkbox->SetValue(format_nozzle_diameter(diameter)); multiple_right_nozzle_flow_checkbox->SetValue(GetString(flow_type)); if (obj->is_support_refresh_nozzle) { @@ -1421,7 +1421,7 @@ wxString PrinterPartsDialog::GetString(NozzleType nozzle_type) const { default: break; } - return wxEmptyString; + return _L("Unknown"); } wxString PrinterPartsDialog::GetString(NozzleFlowType nozzle_flow_type) const { @@ -1483,7 +1483,7 @@ void PrinterPartsDialog::UpdateNozzleInfo(){ auto type = obj->GetExtderSystem()->GetNozzleType(MAIN_EXTRUDER_ID); auto diameter = obj->GetExtderSystem()->GetNozzleDiameter(MAIN_EXTRUDER_ID); nozzle_type_checkbox->SetValue(GetString(type)); - nozzle_diameter_checkbox->SetValue(GetString(diameter)); + nozzle_diameter_checkbox->SetValue(format_nozzle_diameter(diameter)); // nozzle flow type nozzle_flow_type_label->Show(obj->is_nozzle_flow_type_supported()); @@ -1499,7 +1499,7 @@ void PrinterPartsDialog::UpdateNozzleInfo(){ auto diameter = obj->GetExtderSystem()->GetNozzleDiameter(DEPUTY_EXTRUDER_ID); auto flow_type = obj->GetExtderSystem()->GetNozzleFlowType(DEPUTY_EXTRUDER_ID); multiple_left_nozzle_type_checkbox->SetValue(GetString(type)); - multiple_left_nozzle_diameter_checkbox->SetValue(GetString(diameter)); + multiple_left_nozzle_diameter_checkbox->SetValue(format_nozzle_diameter(diameter)); multiple_left_nozzle_flow_checkbox->SetValue(GetString(flow_type)); //right @@ -1507,7 +1507,7 @@ void PrinterPartsDialog::UpdateNozzleInfo(){ diameter = obj->GetExtderSystem()->GetNozzleDiameter(MAIN_EXTRUDER_ID); flow_type = obj->GetExtderSystem()->GetNozzleFlowType(MAIN_EXTRUDER_ID); multiple_right_nozzle_type_checkbox->SetValue(GetString(type)); - multiple_right_nozzle_diameter_checkbox->SetValue(GetString(diameter)); + multiple_right_nozzle_diameter_checkbox->SetValue(format_nozzle_diameter(diameter)); multiple_right_nozzle_flow_checkbox->SetValue(GetString(flow_type)); } diff --git a/src/slic3r/GUI/PrintOptionsDialog.hpp b/src/slic3r/GUI/PrintOptionsDialog.hpp index 9918cfb80e..9fd6a5c83d 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.hpp +++ b/src/slic3r/GUI/PrintOptionsDialog.hpp @@ -68,8 +68,7 @@ private: wxString GetString(NozzleType nozzle_type) const; wxString GetString(NozzleFlowType nozzle_flow_type) const; - wxString GetString(float diameter) const { return wxString::FromDouble(diameter); }; -}; + }; class PrintOptionsDialog : public DPIDialog diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 464a1332c2..3495fca1a6 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -1823,7 +1823,15 @@ static bool _is_same_nozzle_diameters(MachineObject* obj, float &tag_nozzle_diam } tag_nozzle_diameter = float(opt_nozzle_diameters->get_at(used_nozzle_idx)); - if (tag_nozzle_diameter != obj->GetExtderSystem()->GetNozzleDiameter(used_nozzle_idx)) + auto machine_nozzle_diameter = obj->GetExtderSystem()->GetNozzleDiameter(used_nozzle_idx); + + // Assume matching if diameter is unknown + if (machine_nozzle_diameter == 0.0f) + { + continue; + } + + if (tag_nozzle_diameter != machine_nozzle_diameter) { mismatch_nozzle_id = used_nozzle_idx; return false; @@ -1840,7 +1848,16 @@ static bool _is_same_nozzle_diameters(MachineObject* obj, float &tag_nozzle_diam bool SelectMachineDialog::is_nozzle_hrc_matched(const DevExtder* extruder, std::string& filament_type) const { - auto printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(extruder->GetNozzleType()); + if (extruder == nullptr) return false; + + auto printer_nozzle_type = extruder->GetNozzleType(); + + // Assume matching if nozzle type unknown + if (printer_nozzle_type == NozzleType::ntUndefine) { + return true; + } + + auto printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(printer_nozzle_type); auto preset_bundle = wxGetApp().preset_bundle; MaterialHash::const_iterator iter = m_materialList.begin(); @@ -5154,13 +5171,11 @@ static wxString _get_tips(MachineObject* obj_) wxString ext_diameter; if (obj_->GetExtderSystem()->GetTotalExtderCount() == 1) { - ext_diameter += wxString::FromDouble(obj_->GetExtderSystem()->GetNozzleDiameter(0)); - ext_diameter += "mm"; + ext_diameter += format_nozzle_diameter(obj_->GetExtderSystem()->GetNozzleDiameter(0)); } else if (obj_->GetExtderSystem()->GetTotalExtderCount() == 2) { - ext_diameter += wxString::FromDouble(obj_->GetExtderSystem()->GetNozzleDiameter(1));//Left + ext_diameter += format_nozzle_diameter(obj_->GetExtderSystem()->GetNozzleDiameter(1));//Left ext_diameter += "/"; - ext_diameter += wxString::FromDouble(obj_->GetExtderSystem()->GetNozzleDiameter(0)); - ext_diameter += "mm"; + ext_diameter += format_nozzle_diameter(obj_->GetExtderSystem()->GetNozzleDiameter(0)); } else { assert(0); }