FIX: the API return wrong extruder number; remove the assert

jira: [STUDIO-9532]
Change-Id: Ia91a1d277e35f17588de417aee68f418eceb0a11
This commit is contained in:
xin.zhang 2025-01-06 22:02:21 +08:00 committed by lane.wei
parent 6687bd048e
commit 2034cadb56
4 changed files with 17 additions and 7 deletions

View File

@ -6216,7 +6216,6 @@ void MachineObject::check_ams_filament_valid()
stream << std::fixed << std::setprecision(1) << diameter; stream << std::fixed << std::setprecision(1) << diameter;
std::string nozzle_diameter_str = stream.str(); std::string nozzle_diameter_str = stream.str();
if (m_nozzle_filament_data.find(nozzle_diameter_str) == m_nozzle_filament_data.end()) { if (m_nozzle_filament_data.find(nozzle_diameter_str) == m_nozzle_filament_data.end()) {
assert(false);
continue; continue;
} }
auto &data = m_nozzle_filament_data[nozzle_diameter_str]; auto &data = m_nozzle_filament_data[nozzle_diameter_str];

View File

@ -1259,16 +1259,27 @@ std::vector<int> PartPlate::get_extruders_without_support(bool conside_custom_gc
return plate_extruders; return plate_extruders;
} }
/* -1 is invalid, return extruder 0 or 1*/ /* -1 is invalid, return physical extruder idx*/
int PartPlate::get_used_nozzle_by_filament_id(int idx) const /* logical extruder: 1-left, 2-right*/
/* physical extruder: 0-right, 1-left*/
int PartPlate::get_physical_extruder_by_filament_id(const DynamicConfig& g_config, int idx) const
{ {
const std::vector<int>& filament_map = get_filament_maps(); const std::vector<int>& filament_map = get_real_filament_maps(g_config);
if (filament_map.size() < idx) if (filament_map.size() < idx)
{ {
return -1; return -1;
} }
return filament_map[idx - 1] - 1; int logical_ext_idx = filament_map[idx - 1];
switch (logical_ext_idx)
{
case 1: return 1;
case 2: return 0;
default: break;
}
assert(0);
return -1;
} }
std::vector<int> PartPlate::get_used_filaments() std::vector<int> PartPlate::get_used_filaments()

View File

@ -310,7 +310,7 @@ public:
std::vector<int> get_extruders_without_support(bool conside_custom_gcode = false) const; std::vector<int> get_extruders_without_support(bool conside_custom_gcode = false) const;
// get used filaments, 1 based idx // get used filaments, 1 based idx
std::vector<int> get_used_filaments(); std::vector<int> get_used_filaments();
int get_used_nozzle_by_filament_id(int idx) const; int get_physical_extruder_by_filament_id(const DynamicConfig& g_config, int idx) const;
bool check_tpu_printable_status(const DynamicPrintConfig & config, const std::vector<int> &tpu_filaments); bool check_tpu_printable_status(const DynamicPrintConfig & config, const std::vector<int> &tpu_filaments);
/* instance related operations*/ /* instance related operations*/

View File

@ -1993,7 +1993,7 @@ bool SelectMachineDialog::is_same_nozzle_diameters(float& tag_nozzle_diameter) c
auto used_filament_idxs = cur_plate->get_used_filaments();/*the index is started from 1*/ auto used_filament_idxs = cur_plate->get_used_filaments();/*the index is started from 1*/
for (int used_filament_idx : used_filament_idxs) for (int used_filament_idx : used_filament_idxs)
{ {
int used_nozzle_idx = cur_plate->get_used_nozzle_by_filament_id(used_filament_idx); int used_nozzle_idx = cur_plate->get_physical_extruder_by_filament_id(preset_bundle->project_config, used_filament_idx);
if (used_nozzle_idx == -1) if (used_nozzle_idx == -1)
{ {
assert(0); assert(0);