mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 17:39:04 +08:00
Emit additional M84 after prusaslicer_config for MK2 and MK3.
This commit is contained in:
parent
fad1b1e8b4
commit
3bc2a37eaa
@ -901,6 +901,31 @@ static inline GCode::SmoothPathCache smooth_path_interpolate_global(const Print&
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool is_mk2_or_mk3(const std::string &printer_model) {
|
||||||
|
if (boost::starts_with(printer_model, "MK2")) {
|
||||||
|
return true;
|
||||||
|
} else if (boost::starts_with(printer_model, "MK3") && (printer_model.size() <= 3 || printer_model[3] != '.')) {
|
||||||
|
// Ignore MK3.5 and MK3.9.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline std::optional<std::string> find_M84(const std::string &gcode) {
|
||||||
|
std::istringstream gcode_is(gcode);
|
||||||
|
std::string gcode_line;
|
||||||
|
while (std::getline(gcode_is, gcode_line)) {
|
||||||
|
boost::trim(gcode_line);
|
||||||
|
|
||||||
|
if (gcode_line == "M84" || boost::starts_with(gcode_line, "M84 ") || boost::starts_with(gcode_line, "M84;")) {
|
||||||
|
return gcode_line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb)
|
void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||||
{
|
{
|
||||||
const bool export_to_binary_gcode = print.full_print_config().option<ConfigOptionBool>("binary_gcode")->value;
|
const bool export_to_binary_gcode = print.full_print_config().option<ConfigOptionBool>("binary_gcode")->value;
|
||||||
@ -1434,6 +1459,11 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
|
|||||||
file.write(full_config);
|
file.write(full_config);
|
||||||
file.write("; prusaslicer_config = end\n");
|
file.write("; prusaslicer_config = end\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (std::optional<std::string> line_M84 = find_M84(print.config().end_gcode);
|
||||||
|
is_mk2_or_mk3(print.config().printer_model) && line_M84.has_value()) {
|
||||||
|
file.writeln(*line_M84);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print.throw_if_canceled();
|
print.throw_if_canceled();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user