Prime layer_z and layer_num for end gcode in C++ PrintGcode.

This commit is contained in:
Joseph Lenox 2018-09-02 11:49:49 -05:00
parent 6303d0a59a
commit 880e9a52c3
2 changed files with 19 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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();