FIX: generate a wipe tower when add filament

STUDIO-2538

Change-Id: I8cca134eb9302b2ff30252ef36ed8c24c834b22c
(cherry picked from commit aeb5408c9eee844970bbef94e49978568c1de541)
This commit is contained in:
zhimin.zeng 2023-03-23 10:48:56 +08:00 committed by Lane.Wei
parent 8ebd6cfc9e
commit 872a54303c
2 changed files with 10 additions and 5 deletions

View File

@ -342,9 +342,10 @@ std::vector<unsigned int> Print::extruders(bool conside_custom_gcode) const
if (conside_custom_gcode) {
//BBS
int num_extruders = m_config.filament_colour.size();
for (auto plate_data : m_model.plates_custom_gcodes) {
for (auto item : plate_data.second.gcodes) {
if (item.type == CustomGCode::Type::ToolChange)
if (item.type == CustomGCode::Type::ToolChange && item.extruder <= num_extruders)
extruders.push_back((unsigned int)(item.extruder - 1));
}
}

View File

@ -1256,10 +1256,14 @@ std::vector<int> PartPlate::get_extruders(bool conside_custom_gcode) const
if (conside_custom_gcode) {
//BBS
if (m_model->plates_custom_gcodes.find(m_plate_index) != m_model->plates_custom_gcodes.end()) {
for (auto item : m_model->plates_custom_gcodes.at(m_plate_index).gcodes) {
if (item.type == CustomGCode::Type::ToolChange)
plate_extruders.push_back(item.extruder);
int nums_extruders = 0;
if (const ConfigOptionStrings *color_option = dynamic_cast<const ConfigOptionStrings *>(wxGetApp().preset_bundle->project_config.option("filament_colour"))) {
nums_extruders = color_option->values.size();
if (m_model->plates_custom_gcodes.find(m_plate_index) != m_model->plates_custom_gcodes.end()) {
for (auto item : m_model->plates_custom_gcodes.at(m_plate_index).gcodes) {
if (item.type == CustomGCode::Type::ToolChange && item.extruder <= nums_extruders)
plate_extruders.push_back(item.extruder);
}
}
}
}