Add Post-processing (#159)

It is now possible to call external  post-process scripts
This commit is contained in:
Patrice Côté 2023-01-12 06:42:31 -05:00 committed by GitHub
parent a3e5531e28
commit 540aa13e25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 6 deletions

View file

@ -1912,8 +1912,7 @@ int CLI::run(int argc, char **argv)
outfile = outfile_final; outfile = outfile_final;
}*/ }*/
// Run the post-processing scripts if defined. // 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; BOOST_LOG_TRIVIAL(info) << "Slicing result exported to " << outfile << std::endl;
part_plate->update_slice_result_valid_state(true); part_plate->update_slice_result_valid_state(true);
#if defined(__linux__) || defined(__LINUX__) #if defined(__linux__) || defined(__LINUX__)

View file

@ -749,7 +749,7 @@ static std::vector<std::string> s_Preset_print_options {
"wall_generator", "wall_transition_length", "wall_transition_filter_deviation", "wall_transition_angle", "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",
// SoftFever // SoftFever
"small_perimeter_speed", "small_perimeter_threshold","bridge_angle", "filter_out_gap_fill", "travel_acceleration","inner_wall_acceleration", "small_perimeter_speed", "small_perimeter_threshold","bridge_angle", "filter_out_gap_fill", "post_process", "travel_acceleration","inner_wall_acceleration",
"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "top_surface_jerk", "initial_layer_jerk","travel_jerk", "default_jerk", "outer_wall_jerk", "inner_wall_jerk", "top_surface_jerk", "initial_layer_jerk","travel_jerk",
"top_solid_infill_flow_ratio","bottom_solid_infill_flow_ratio","only_one_wall_first_layer", "top_solid_infill_flow_ratio","bottom_solid_infill_flow_ratio","only_one_wall_first_layer",
"print_flow_ratio" "print_flow_ratio"

View file

@ -84,6 +84,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"close_fan_the_first_x_layers", "close_fan_the_first_x_layers",
"machine_end_gcode", "machine_end_gcode",
"filament_end_gcode", "filament_end_gcode",
"post_process",
"extruder_clearance_height_to_rod", "extruder_clearance_height_to_rod",
"extruder_clearance_height_to_lid", "extruder_clearance_height_to_lid",
"extruder_clearance_radius", "extruder_clearance_radius",

View file

@ -2169,6 +2169,19 @@ void PrintConfigDef::init_fff_params()
def->max = 1000; def->max = 1000;
def->set_default_value(new ConfigOptionInt(2)); 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 they can access the Slic3r config settings by reading environment variables.");
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 = this->add("printer_model", coString);
//def->label = L("Printer type"); //def->label = L("Printer type");
//def->tooltip = L("Type of the printer"); //def->tooltip = L("Type of the printer");

View file

@ -921,6 +921,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionBool, reduce_infill_retraction)) ((ConfigOptionBool, reduce_infill_retraction))
((ConfigOptionBool, ooze_prevention)) ((ConfigOptionBool, ooze_prevention))
((ConfigOptionString, filename_format)) ((ConfigOptionString, filename_format))
((ConfigOptionStrings, post_process))
((ConfigOptionString, printer_model)) ((ConfigOptionString, printer_model))
((ConfigOptionFloat, resolution)) ((ConfigOptionFloat, resolution))
((ConfigOptionFloats, retraction_minimum_travel)) ((ConfigOptionFloats, retraction_minimum_travel))

View file

@ -769,8 +769,7 @@ void BackgroundSlicingProcess::finalize_gcode()
// is calculated for the unprocessed G-code and it references lines in the memory mapped G-code file by line numbers. // 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. // 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 //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 = run_post_process_scripts(output_path, true, "File", export_path, m_fff_print->full_print_config());
bool post_processed = false;
auto remove_post_processed_temp_file = [post_processed, &output_path]() { auto remove_post_processed_temp_file = [post_processed, &output_path]() {
if (post_processed) if (post_processed)
try { try {

View file

@ -2035,6 +2035,13 @@ void TabPrint::build()
// option.opt.height = 5; // option.opt.height = 5;
optgroup->append_single_option_line(option); 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 #if 0
//page = add_options_page(L("Dependencies"), "advanced.png"); //page = add_options_page(L("Dependencies"), "advanced.png");
// optgroup = page->new_optgroup(L("Profile dependencies")); // optgroup = page->new_optgroup(L("Profile dependencies"));