diff --git a/deps/+LibBGCode/LibBGCode.cmake b/deps/+LibBGCode/LibBGCode.cmake index 56f5525b7e..b4cf62f12f 100644 --- a/deps/+LibBGCode/LibBGCode.cmake +++ b/deps/+LibBGCode/LibBGCode.cmake @@ -1,8 +1,8 @@ set(LibBGCode_SOURCE_DIR "" CACHE PATH "Optionally specify local LibBGCode source directory") set(_source_dir_line - URL https://github.com/prusa3d/libbgcode/archive/d33a277a3ce2c0a7f9ba325caac6d730e0f7a412.zip - URL_HASH SHA256=0db3b0852df8d3ae32a4283884bc4ad6f1dd4d3c748ed679491f70b1e1d1acd5) + URL https://github.com/prusa3d/libbgcode/archive/5041c093b33e2748e76d6b326f2251310823f3df.zip + URL_HASH SHA256=c323aa196a82d75f08a5b114c95f2d1a019e84b555a196e55d8ea52e5787284c) if (LibBGCode_SOURCE_DIR) set(_source_dir_line "SOURCE_DIR;${LibBGCode_SOURCE_DIR};BUILD_ALWAYS;ON") diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 3906a05304..493b8fed6d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -930,6 +930,18 @@ static inline std::optional find_M84(const std::string &gcode) { void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb) { const bool export_to_binary_gcode = print.full_print_config().option("binary_gcode")->value; + + std::string prepared_by_info; + if (const char* extras = boost::nowide::getenv("SLIC3R_PREPARED_BY_INFO"); extras) { + std::string str(extras); + if (str.size() < 50 && std::all_of(str.begin(), str.end(), [](char c) { return c < 127 && c != '\n' && c != '\r'; })) + prepared_by_info = extras; + else { + BOOST_LOG_TRIVIAL(error) << "Value in SLIC3R_PREPARED_BY_INFO env variable is invalid. Closing."; + std::terminate(); + } + } + // if exporting gcode in binary format: // we generate here the data to be passed to the post-processor, who is responsible to export them to file // 1) generate the thumbnails @@ -955,6 +967,8 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail // file data binary_data.file_metadata.raw_data.emplace_back("Producer", std::string(SLIC3R_APP_NAME) + " " + std::string(SLIC3R_VERSION)); binary_data.file_metadata.raw_data.emplace_back("Produced on", Utils::utc_timestamp()); + if (! prepared_by_info.empty()) + binary_data.file_metadata.raw_data.emplace_back("Prepared by", prepared_by_info); // config data encode_full_config(*m_print, binary_data.slicer_metadata.raw_data); @@ -1024,9 +1038,13 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail this->m_avoid_crossing_curled_overhangs.init_bed_shape(get_bed_shape(print.config())); } - if (!export_to_binary_gcode) + if (!export_to_binary_gcode) { // Write information on the generator. - file.write_format("; %s\n\n", Slic3r::header_slic3r_generated().c_str()); + file.write_format("; %s\n", Slic3r::header_slic3r_generated().c_str()); + if (! prepared_by_info.empty()) + file.write_format("; prepared by %s\n", prepared_by_info.c_str()); + file.write_format("\n"); + } if (! export_to_binary_gcode) { // if exporting gcode in ascii format, generate the thumbnails here