mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-28 08:09:55 -05:00
Fix Kobra 2 layer-change G-code comments
This commit is contained in:
1 parent
461275d9bb
commit
19dc9e1f33
4 files changed
+52
-4
No files matched your search
@@ -2,7 +2,10 @@
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include <catch2/catch_message.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include "libslic3r/BoundingBox.hpp"
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/GCodeReader.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/ModelArrange.hpp"
|
||||
#include "libslic3r/Print.hpp"
|
||||
@@ -12,11 +15,56 @@
|
||||
|
||||
#include "libslic3r/TriangleMesh.hpp"
|
||||
#include "libslic3r/Point.hpp"
|
||||
#include <cctype>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
TEST_CASE("Kobra 2 layer-change templates do not emit numeric commands", "[GCode][Kobra2][Regression]")
|
||||
{
|
||||
const char *template_key = GENERATE("before_layer_change_gcode", "layer_change_gcode");
|
||||
const std::string profile_path = std::string(PROFILES_DIR) + "/Anycubic/machine/Anycubic Kobra 2 0.4 nozzle.json";
|
||||
// CI test artifacts may omit the shipped profiles.
|
||||
if (!boost::filesystem::exists(profile_path))
|
||||
SKIP("shipped profile not present: " << profile_path);
|
||||
|
||||
DynamicPrintConfig machine;
|
||||
ConfigSubstitutionContext substitutions{ForwardCompatibilitySubstitutionRule::Enable};
|
||||
std::map<std::string, std::string> metadata;
|
||||
std::string reason;
|
||||
machine.load_from_json(profile_path, substitutions, false, metadata, reason);
|
||||
INFO("profile: " << profile_path << "\nload reason: " << reason);
|
||||
REQUIRE(machine.has(template_key));
|
||||
REQUIRE_FALSE(machine.opt_string(template_key).empty());
|
||||
|
||||
auto config = Test::multifilament_config(1, {
|
||||
{"gcode_flavor", "marlin"},
|
||||
{"layer_height", "0.2"},
|
||||
{"first_layer_height", "0.2"},
|
||||
{"use_relative_e_distances", "0"},
|
||||
{"machine_start_gcode", ""},
|
||||
{"machine_end_gcode", ""},
|
||||
{"before_layer_change_gcode", ""},
|
||||
{"layer_change_gcode", ""},
|
||||
});
|
||||
// Exercise each shipped template separately through a real G-code export.
|
||||
config.set_key_value(template_key, machine.option(template_key)->clone());
|
||||
const std::string gcode = Test::slice({Test::cube(1.)}, config);
|
||||
INFO("template: " << template_key);
|
||||
REQUIRE(gcode.find(";LAYER_CHANGE") != std::string::npos);
|
||||
|
||||
GCodeReader reader;
|
||||
reader.parse_buffer(gcode, [](GCodeReader &, const GCodeReader::GCodeLine &line) {
|
||||
const auto command = line.cmd();
|
||||
if (!command.empty()) {
|
||||
INFO("executable line: " << line.raw());
|
||||
CHECK_FALSE(std::isdigit(static_cast<unsigned char>(command.front())));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
TEST_CASE("Klipper object labels name each copy without the characters Klipper cannot parse", "[GCode]")
|
||||
{
|
||||
const auto [name, label] = GENERATE(table<std::string, std::string>({
|
||||
|
||||
Reference in new issue
Block a user