diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index a58c3d3c9..8be5a4eaa 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -2038,8 +2038,7 @@ int CLI::run(int argc, char **argv) outfile = outfile_final; }*/ // Run the post-processing scripts if defined. - //BBS: TODO, maybe need to open this function later - //run_post_process_scripts(outfile, print->full_print_config()); + run_post_process_scripts(outfile, print->full_print_config()); BOOST_LOG_TRIVIAL(info) << "Slicing result exported to " << outfile << std::endl; part_plate->update_slice_result_valid_state(true); #if defined(__linux__) || defined(__LINUX__) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index bff33c4af..167d57b4f 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -747,7 +747,7 @@ static std::vector s_Preset_print_options { "initial_layer_infill_speed", "only_one_wall_top", "timelapse_type", "internal_bridge_support_thickness", "wall_generator", "wall_transition_length", "wall_transition_filter_deviation", "wall_transition_angle", - "wall_distribution_count", "min_feature_size", "min_bead_width" + "wall_distribution_count", "min_feature_size", "min_bead_width", "post_process" }; static std::vector s_Preset_filament_options { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 02755f8db..5dbe8574b 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -86,6 +86,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "close_fan_the_first_x_layers", "machine_end_gcode", "filament_end_gcode", + "post_process", "extruder_clearance_height_to_rod", "extruder_clearance_height_to_lid", "extruder_clearance_radius", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index ee3cb4436..c69ddad90 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2028,6 +2028,19 @@ void PrintConfigDef::init_fff_params() def->max = 1000; def->set_default_value(new ConfigOptionInt(2)); + def = this->add("post_process", coStrings); + def->label = L("Post-processing Scripts"); + def->tooltip = L("If you want to process the output G-code through custom scripts, " + "just list their absolute paths here. Separate multiple scripts with a semicolon. " + "Scripts will be passed the absolute path to the G-code file as the first argument, " + "and variables of settings also can be read"); + def->gui_flags = "serialized"; + def->multiline = true; + def->full_width = true; + def->height = 6; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionStrings()); + def = this->add("printer_model", coString); //def->label = L("Printer type"); //def->tooltip = L("Type of the printer"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index c04340431..e83c91a6e 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -906,6 +906,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionBool, reduce_infill_retraction)) ((ConfigOptionBool, ooze_prevention)) ((ConfigOptionString, filename_format)) + ((ConfigOptionStrings, post_process)) ((ConfigOptionString, printer_model)) ((ConfigOptionFloat, resolution)) ((ConfigOptionFloats, retraction_minimum_travel)) diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index ce1be6991..5124aa8ea 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -763,9 +763,7 @@ void BackgroundSlicingProcess::finalize_gcode() // collide with the G-code viewer memory mapping of the unprocessed G-code. G-code viewer maps unprocessed G-code, because m_gcode_result // is calculated for the unprocessed G-code and it references lines in the memory mapped G-code file by line numbers. // export_path may be changed by the post-processing script as well if the post processing script decides so, see GH #6042. - //BBS: don't support running post process scripts - //bool post_processed = run_post_process_scripts(output_path, true, "File", export_path, m_fff_print->full_print_config()); - bool post_processed = false; + bool post_processed = run_post_process_scripts(output_path, true, "File", export_path, m_fff_print->full_print_config()); auto remove_post_processed_temp_file = [post_processed, &output_path]() { if (post_processed) try { diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 349f0d388..ea5a7d823 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2023,6 +2023,13 @@ void TabPrint::build() option.opt.full_width = true; optgroup->append_single_option_line(option); + optgroup = page->new_optgroup(L("Post-processing scripts"), L"param_gcode", 0); + option = optgroup->get_option("post_process"); + option.opt.full_width = true; + option.opt.is_code = true; + option.opt.height = 15; + optgroup->append_single_option_line(option); + #if 0 //page = add_options_page(L("Dependencies"), "advanced.png"); // optgroup = page->new_optgroup(L("Profile dependencies"));