diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 46fd3c5b3..982a5067c 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -1114,6 +1114,7 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line) case 21: { process_G21(line); break; } // Set Units to Millimeters case 22: { process_G22(line); break; } // Firmware controlled retract case 23: { process_G23(line); break; } // Firmware controlled unretract + case 28: { process_G28(line); break; } // Move to origin case 90: { process_G90(line); break; } // Set to Absolute Positioning case 91: { process_G91(line); break; } // Set to Relative Positioning case 92: { process_G92(line); break; } // Set Position @@ -2147,6 +2148,32 @@ void GCodeProcessor::process_G23(const GCodeReader::GCodeLine& line) store_move_vertex(EMoveType::Unretract); } +void GCodeProcessor::process_G28(const GCodeReader::GCodeLine& line) +{ + std::string_view cmd = line.cmd(); + std::string new_line_raw = { cmd.data(), cmd.size() }; + bool found = false; + if (line.has_x()) { + new_line_raw += " X0"; + found = true; + } + if (line.has_y()) { + new_line_raw += " Y0"; + found = true; + } + if (line.has_z()) { + new_line_raw += " Z0"; + found = true; + } + if (!found) + new_line_raw += " X0 Y0 Z0"; + + GCodeReader::GCodeLine new_line; + GCodeReader reader; + reader.parse_line(new_line_raw.c_str(), new_line, [](GCodeReader&, const GCodeReader::GCodeLine&) {}); + process_G1(new_line); +} + void GCodeProcessor::process_G90(const GCodeReader::GCodeLine& line) { m_global_positioning_type = EPositioningType::Absolute; diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index f619864c4..c1497edda 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -572,6 +572,9 @@ namespace Slic3r { // Firmware controlled Unretract void process_G23(const GCodeReader::GCodeLine& line); + // Move to origin + void process_G28(const GCodeReader::GCodeLine& line); + // Set to Absolute Positioning void process_G90(const GCodeReader::GCodeLine& line);