From 00cead17f4effa642c0fc4fb9df5624270729a09 Mon Sep 17 00:00:00 2001 From: Wang Yile <108109393+wyl2003@users.noreply.github.com> Date: Tue, 2 Dec 2025 23:53:23 +0800 Subject: [PATCH] Implement post-processing before sending to printer Added post-processing script execution before sending G-code to the printer. --- .../GUI/print_manage/App/SendToPrinter.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/print_manage/App/SendToPrinter.cpp b/src/slic3r/GUI/print_manage/App/SendToPrinter.cpp index 088c2515..8388fc2c 100644 --- a/src/slic3r/GUI/print_manage/App/SendToPrinter.cpp +++ b/src/slic3r/GUI/print_manage/App/SendToPrinter.cpp @@ -28,6 +28,7 @@ #include "slic3r/GUI/PartPlate.hpp" #include "slic3r/GUI/AnalyticsDataUploadManager.hpp" #include "libslic3r/Print.hpp" +#include "libslic3r/GCode/PostProcessor.hpp" #include #include #include "../data/DataCenter.hpp" @@ -916,6 +917,20 @@ void CxSentToPrinterDialog::handle_send_gcode(const nlohmann::json& json_data) else{ gcodeFilePath = _L(plate->get_tmp_gcode_path()).ToUTF8(); } + + // Run post-processing scripts before sending to printer + if (!m_plater->only_gcode_mode()) { + try { + Slic3r::Print* print = nullptr; + plate->get_print((Slic3r::PrintBase**)&print, nullptr, nullptr); + if (print) { + std::string output_name = gcodeFilePath; + run_post_process_scripts(gcodeFilePath, false, "File", output_name, print->full_print_config()); + } + } catch (const std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "Post-processing script failed when sending to printer: " << e.what(); + } + } m_uploadingIp = ipAddress; RemotePrint::RemotePrinterManager::getInstance().pushUploadTasks( @@ -1830,4 +1845,4 @@ int CxSentToPrinterDialog::load_machine_preset_data() } } // namespace GUI -} // namespace Slic3r \ No newline at end of file +} // namespace Slic3r