diff --git a/resources/profiles/Anycubic.json b/resources/profiles/Anycubic.json index 1d8f8e70cf..739b41b9ae 100644 --- a/resources/profiles/Anycubic.json +++ b/resources/profiles/Anycubic.json @@ -1,6 +1,6 @@ { "name": "Anycubic", - "version": "02.04.00.09", + "version": "02.04.00.10", "force_update": "0", "description": "Anycubic configurations", "machine_model_list": [ diff --git a/resources/profiles/Anycubic/machine/Anycubic Kobra 2 0.4 nozzle.json b/resources/profiles/Anycubic/machine/Anycubic Kobra 2 0.4 nozzle.json index a804761c28..34afd51a7b 100644 --- a/resources/profiles/Anycubic/machine/Anycubic Kobra 2 0.4 nozzle.json +++ b/resources/profiles/Anycubic/machine/Anycubic Kobra 2 0.4 nozzle.json @@ -108,7 +108,7 @@ ], "machine_start_gcode": "G90 ;Use absolute coordinates\nM83 ;Extruder relative mode\nM104 S[first_layer_temperature] ;Set extruder temp\nM140 S[first_layer_bed_temperature] ;Set bed temp\nM190 S[first_layer_bed_temperature] ;Wait for bed temp\nM109 S[first_layer_temperature] ;Wait for extruder temp\nG28 ;Move X/Y/Z to min endstops\nG1 Z0.28 ;Lift nozzle a bit\nG92 E0 ;Specify current extruder position as zero\nG1 Y3 F1800 ;Move Y to purge point\nG1 X60 E25 F500 ;Extrude 25mm of filament in a 5cm line\nG92 E0 ;Zero the extruded length again\nG1 E-2 F500 ;Retract a little\nG1 X70 F4000 ;Quickly wipe away from the filament line\nM117", "machine_end_gcode": "M104 S0 ;Extruder off\nM140 S0 ;Heatbed off\nM107 ;Fan off\nG91 ;Relative positioning\nG1 E-5 F3000 ;Retract filament\nG1 Z+0.3 F3000 ;Lift print head\nG28 X0 F3000 ;Home X axis\nM84 ;Disable stepper motors", - "before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n[layer_num] @ [layer_z]mm\nG92 E0", - "layer_change_gcode": ";AFTER_LAYER_CHANGE\n[layer_num] @ [layer_z]mm", + "before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_num] @ [layer_z]mm\nG92 E0", + "layer_change_gcode": ";AFTER_LAYER_CHANGE\n;[layer_num] @ [layer_z]mm", "scan_first_layer": "0" } diff --git a/tests/fff_print/test_gcode.cpp b/tests/fff_print/test_gcode.cpp index 7bd36481db..6450ee0b53 100644 --- a/tests/fff_print/test_gcode.cpp +++ b/tests/fff_print/test_gcode.cpp @@ -2,7 +2,10 @@ #include #include +#include #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 +#include #include #include 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 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(command.front()))); + } + }); +} + TEST_CASE("Klipper object labels name each copy without the characters Klipper cannot parse", "[GCode]") { const auto [name, label] = GENERATE(table({ diff --git a/tests/fff_print/test_gcodewriter.cpp b/tests/fff_print/test_gcodewriter.cpp index 170dfabae3..110d75a4ab 100644 --- a/tests/fff_print/test_gcodewriter.cpp +++ b/tests/fff_print/test_gcodewriter.cpp @@ -873,7 +873,7 @@ static std::string shipped_change_filament_gcode(const std::string &printer) const std::string template_name = "Bambu Lab " + printer + " 0.4 nozzle template change_filament_gcode"; // PROFILES_DIR is an absolute path baked in at build time; a sparse test checkout // without resources/ leaves it missing. Skip rather than dereference a config that - // never loaded - this is the only fff_print test that reads a shipped profile. + // never loaded. if (!boost::filesystem::exists(machine_path)) SKIP("shipped profile not present in this checkout: " << machine_path);