diff --git a/src/test/libslic3r/test_printgcode.cpp b/src/test/libslic3r/test_printgcode.cpp index 34c529ed6..67577875b 100644 --- a/src/test/libslic3r/test_printgcode.cpp +++ b/src/test/libslic3r/test_printgcode.cpp @@ -208,6 +208,23 @@ SCENARIO( "PrintGCode basic functionality") { } } + + WHEN("end_gcode exists with layer_num and layer_z") { + config->set("end_gcode", "; Layer_num [layer_num]\n; Layer_z [layer_z]"); + config->set("layer_height", 0.1); + config->set("first_layer_height", 0.1); + + Slic3r::Model model; + auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + Slic3r::Test::gcode(gcode, print); + + auto exported {gcode.str()}; + THEN("layer_num and layer_z are processed in the end gcode") {\ + REQUIRE(exported.find("; Layer_num 199") != std::string::npos); + REQUIRE(exported.find("; Layer_z 20") != std::string::npos); + } + } + gcode.clear(); } } diff --git a/xs/src/libslic3r/PrintGCode.cpp b/xs/src/libslic3r/PrintGCode.cpp index 179943679..0af21863c 100644 --- a/xs/src/libslic3r/PrintGCode.cpp +++ b/xs/src/libslic3r/PrintGCode.cpp @@ -269,6 +269,8 @@ PrintGCode::output() this->process_layer(idx, layer, layer->object()->_shifted_copies); } } + gcodegen.placeholder_parser->set("layer_z", unscale(print_z)); + gcodegen.placeholder_parser->set("layer_num", gcodegen.layer_index); } this->flush_filters();