diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 9d2e14f8a8..a4506b791c 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1845,7 +1845,7 @@ static std::vector get_path_of_change_filament(const Print& print) std::string WipeTowerIntegration::finalize(GCode &gcodegen) { std::string gcode; - if (gcodegen.wipe_tower_type() == WipeTowerType::Type2) { + if (gcodegen.wipe_tower_type() == WipeTowerType::Type2 && !m_final_purge.gcode.empty()) { if (std::abs(gcodegen.writer().get_position().z() - m_final_purge.print_z) > EPSILON) gcode += gcodegen.change_layer(m_final_purge.print_z); gcode += append_tcr2(gcodegen, m_final_purge, -1); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 51b0a96b64..7c6290634b 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -4126,6 +4126,7 @@ void Print::_make_wipe_tower() // Unload the current filament over the purge tower. coordf_t layer_height = m_objects.front()->config().layer_height.value; + bool generate_final_purge = true; if (m_wipe_tower_data.tool_ordering.back().wipe_tower_partitions > 0) { // The wipe tower goes up to the last layer of the print. if (wipe_tower.layer_finished()) { @@ -4137,11 +4138,14 @@ void Print::_make_wipe_tower() // There is yet enough space at this layer of the wipe tower for the final purge. } } else { - // The wipe tower does not reach the last print layer, perform the pruge at the last print layer. + // The wipe tower does not reach the last print layer. + // Skip final purge to avoid generating purge lines in mid-air. assert(m_wipe_tower_data.tool_ordering.back().wipe_tower_partitions == 0); - wipe_tower.set_layer(float(m_wipe_tower_data.tool_ordering.back().print_z), float(layer_height), 0, false, true); + generate_final_purge = false; } - m_wipe_tower_data.final_purge = Slic3r::make_unique(wipe_tower.tool_change((unsigned int) (-1))); + m_wipe_tower_data.final_purge = generate_final_purge + ? Slic3r::make_unique(wipe_tower.tool_change((unsigned int)(-1))) + : Slic3r::make_unique(); m_wipe_tower_data.used_filament = wipe_tower.get_used_filament(); m_wipe_tower_data.number_of_toolchanges = wipe_tower.get_number_of_toolchanges(); @@ -4237,6 +4241,7 @@ void Print::_make_wipe_tower() // Unload the current filament over the purge tower. coordf_t layer_height = m_objects.front()->config().layer_height.value; + bool generate_final_purge = true; if (m_wipe_tower_data.tool_ordering.back().wipe_tower_partitions > 0) { // The wipe tower goes up to the last layer of the print. if (wipe_tower.layer_finished()) { @@ -4248,11 +4253,14 @@ void Print::_make_wipe_tower() // There is yet enough space at this layer of the wipe tower for the final purge. } } else { - // The wipe tower does not reach the last print layer, perform the pruge at the last print layer. + // The wipe tower does not reach the last print layer. + // Skip final purge to avoid generating purge lines in mid-air. assert(m_wipe_tower_data.tool_ordering.back().wipe_tower_partitions == 0); - wipe_tower.set_layer(float(m_wipe_tower_data.tool_ordering.back().print_z), float(layer_height), 0, false, true); + generate_final_purge = false; } - m_wipe_tower_data.final_purge = Slic3r::make_unique(wipe_tower.tool_change((unsigned int) (-1))); + m_wipe_tower_data.final_purge = generate_final_purge + ? Slic3r::make_unique(wipe_tower.tool_change((unsigned int)(-1))) + : Slic3r::make_unique(); m_wipe_tower_data.used_filament = wipe_tower.get_used_filament(); m_wipe_tower_data.number_of_toolchanges = wipe_tower.get_number_of_toolchanges();