FIX: move the lift gcode from change_filament_gcode to GCode.cpp

and delete ;nozzle_change_gcode of change_filament_gcode
jira:none

Change-Id: I79c2896afe15b59ba3932240edcb6330e230470f
This commit is contained in:
zhimin.zeng 2024-08-12 15:02:11 +08:00 committed by lane.wei
parent c1dec339dd
commit 8cf72ab46c
1 changed files with 18 additions and 9 deletions

View File

@ -82,6 +82,11 @@ static const size_t g_max_label_object = 64;
static const double smooth_speed_step = 10;
static const double not_split_length = scale_(1.0);
static const std::string lift_gcode_after_printing_object = "{if toolchange_count > 1 && (z_hop_types[current_extruder] == 0 || z_hop_types[current_extruder] == 3)}\n"
"G17\n"
"G2 Z{z_after_toolchange + 0.4} I0.86 J0.86 P1 F10000 ; spiral lift a little from second lift\n"
"{endif}\n";
Vec2d travel_point_1;
Vec2d travel_point_2;
Vec2d travel_point_3;
@ -508,8 +513,14 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
// Process the custom change_filament_gcode. If it is empty, provide a simple Tn command to change the filament.
// Otherwise, leave control to the user completely.
std::string toolchange_gcode_str;
const std::string& change_filament_gcode = gcodegen.config().change_filament_gcode.value;
// m_max_layer_z = std::max(m_max_layer_z, tcr.print_z);
std::string change_filament_gcode = gcodegen.config().change_filament_gcode.value;
std::string prefix_gcode = lift_gcode_after_printing_object;
if (gcodegen.config().nozzle_diameter.size() > 1) {
prefix_gcode += nozzle_change_gcode_trans;
}
change_filament_gcode = prefix_gcode + change_filament_gcode;
if (! change_filament_gcode.empty()) {
DynamicConfig config;
int old_filament_id = gcodegen.writer().filament() ? (int)gcodegen.writer().filament()->id() : -1;
@ -590,12 +601,6 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
}
toolchange_gcode_str = gcodegen.placeholder_parser_process("change_filament_gcode", change_filament_gcode, new_filament_id, &config);
std::string target_str = ";nozzle_change_gcode";
size_t pos = toolchange_gcode_str.find(target_str);
if (pos != std::string::npos) {
toolchange_gcode_str.replace(pos, target_str.length(), nozzle_change_gcode_trans);
}
check_add_eol(toolchange_gcode_str);
// retract before toolchange
@ -5557,7 +5562,11 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
}
// Process the custom change_filament_gcode.
const std::string& change_filament_gcode = m_config.change_filament_gcode.value;
std::string change_filament_gcode = m_config.change_filament_gcode.value;
// Move the lift gcode here which is in the change_filament_gcode originally
change_filament_gcode = lift_gcode_after_printing_object + change_filament_gcode;
std::string toolchange_gcode_parsed;
if (!change_filament_gcode.empty()) {
toolchange_gcode_parsed = placeholder_parser_process("change_filament_gcode", change_filament_gcode, new_filament_id, &dyn_config);