diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index f0540d2359..71cfd16329 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -3019,25 +3019,20 @@ std::string GCodeGenerator::travel_to_first_position(const Vec3crd& point) { const Vec3d gcode_point = to_3d(this->point_to_gcode(point.head<2>()), unscaled(point.z())); - if (!this->last_position) { - double lift{ - EXTRUDER_CONFIG(travel_ramping_lift) ? EXTRUDER_CONFIG(travel_max_lift) : - EXTRUDER_CONFIG(retract_lift)}; - const double upper_limit = EXTRUDER_CONFIG(retract_lift_below); - const double lower_limit = EXTRUDER_CONFIG(retract_lift_above); - if ((lower_limit > 0 && gcode_point.z() < lower_limit) || - (upper_limit > 0 && gcode_point.z() > upper_limit)) { - lift = 0.0; - } - gcode += this->writer().get_travel_to_z_gcode(gcode_point.z() + lift, "lift"); + double lift{ + EXTRUDER_CONFIG(travel_ramping_lift) ? EXTRUDER_CONFIG(travel_max_lift) : + EXTRUDER_CONFIG(retract_lift)}; + const double upper_limit = EXTRUDER_CONFIG(retract_lift_below); + const double lower_limit = EXTRUDER_CONFIG(retract_lift_above); + if ((lower_limit > 0 && gcode_point.z() < lower_limit) || + (upper_limit > 0 && gcode_point.z() > upper_limit)) { + lift = 0.0; } - if (!EXTRUDER_CONFIG(travel_ramping_lift)) { - if (!this->last_position || - EXTRUDER_CONFIG(retract_before_travel) < - (this->point_to_gcode(*this->last_position) - gcode_point.head<2>()).norm()) { + if (EXTRUDER_CONFIG(retract_length) > 0 && (!this->last_position || (!EXTRUDER_CONFIG(travel_ramping_lift)))) { + if (!this->last_position || EXTRUDER_CONFIG(retract_before_travel) < (this->point_to_gcode(*this->last_position) - gcode_point.head<2>()).norm()) { gcode += this->writer().retract(); - gcode += this->writer().get_travel_to_z_gcode(gcode_point.z() + EXTRUDER_CONFIG(retract_lift), "lift"); + gcode += this->writer().get_travel_to_z_gcode(gcode_point.z() + lift, "lift"); } } this->last_position = point.head<2>(); diff --git a/tests/fff_print/test_gcode.cpp b/tests/fff_print/test_gcode.cpp index 593723a272..a87e6dc317 100644 --- a/tests/fff_print/test_gcode.cpp +++ b/tests/fff_print/test_gcode.cpp @@ -130,7 +130,8 @@ TEST_CASE("Extrusion, travels, temeperatures", "[GCode]") { { "layer_height", 0.4 }, { "first_layer_height", 0.4 }, { "temperature", "200" }, - { "first_layer_temperature", "210" } + { "first_layer_temperature", "210" }, + { "retract_length", "0" } }); std::vector z_moves; diff --git a/tests/fff_print/test_layers.cpp b/tests/fff_print/test_layers.cpp index 6523d1318b..87accd3aaf 100644 --- a/tests/fff_print/test_layers.cpp +++ b/tests/fff_print/test_layers.cpp @@ -42,6 +42,7 @@ TEST_CASE("Layer heights are correct", "[Layers]") { { "start_gcode", "" }, { "layer_height", 0.3 }, { "first_layer_height", 0.2 }, + { "retract_length", "0" } }); SECTION("Absolute first layer height") { diff --git a/tests/fff_print/test_retraction.cpp b/tests/fff_print/test_retraction.cpp index f75df4d42c..97ea0c5cf6 100644 --- a/tests/fff_print/test_retraction.cpp +++ b/tests/fff_print/test_retraction.cpp @@ -14,7 +14,7 @@ using namespace Slic3r; using namespace Test; -constexpr bool debug_files {false}; +constexpr bool debug_files {true}; void check_gcode(std::initializer_list meshes, const DynamicPrintConfig& config, const unsigned duplicate) { constexpr std::size_t tools_count = 4; @@ -177,7 +177,7 @@ TEST_CASE("Z moves", "[retraction]") { { "start_gcode", "" }, // To avoid dealing with the nozzle lift in start G-code { "retract_length", "0" }, { "retract_layer_change", "0" }, - { "retract_lift", "0.2" }, + { "retract_lift", "0.2" } }); bool retracted = false; @@ -214,8 +214,8 @@ TEST_CASE("Z moves", "[retraction]") { CHECK(layer_changes_with_retraction == 0); INFO("no retractions"); CHECK(retractions == 0); - INFO("no lift other than for the first move"); - CHECK(z_restores == 1); + INFO("no lift"); + CHECK(z_restores == 0); } TEST_CASE("Firmware retraction handling", "[retraction]") {