From b94dee2460eec7f4f163258e8daab09a2c822aa1 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Wed, 16 Aug 2023 14:36:22 +0800 Subject: [PATCH] ENH: CLI: add a flag to allow minimum size save JIRA: STUDIO-3752 Change-Id: I0277c34d108185d10130630a72811122f8ee9ae2 --- src/BambuStudio.cpp | 14 +++++++++++--- src/BambuStudio.hpp | 2 +- src/libslic3r/PrintConfig.cpp | 6 ++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index 5a9f3c2a8..30f003b48 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -559,7 +559,7 @@ int CLI::run(int argc, char **argv) PlateDataPtrs plate_data_src; int arrange_option; int plate_to_slice = 0, filament_count = 0, duplicate_count = 0, real_duplicate_count = 0; - bool first_file = true, is_bbl_3mf = false, need_arrange = true, has_thumbnails = false, up_config_to_date = false, normative_check = true, duplicate_single_object = false, use_first_fila_as_default = false; + bool first_file = true, is_bbl_3mf = false, need_arrange = true, has_thumbnails = false, up_config_to_date = false, normative_check = true, duplicate_single_object = false, use_first_fila_as_default = false, minimum_save = false; Semver file_version; std::map orients_requirement; std::vector project_presets; @@ -588,6 +588,10 @@ int CLI::run(int argc, char **argv) if (load_defaultfila_option) use_first_fila_as_default = load_defaultfila_option->value; + ConfigOptionBool* min_save_option = m_config.option("min_save"); + if (min_save_option) + minimum_save = min_save_option->value; + ConfigOptionString* pipe_option = m_config.option("pipe"); if (pipe_option) { pipe_name = pipe_option->value; @@ -2692,6 +2696,8 @@ int CLI::run(int argc, char **argv) } } else if (opt_key == "uptodate") { //already processed before + } else if (opt_key == "min_save") { + //already processed before } else if (opt_key == "load_defaultfila") { //already processed before } else if (opt_key == "mtcpp") { @@ -3631,7 +3637,7 @@ int CLI::run(int argc, char **argv) BOOST_LOG_TRIVIAL(info) << "will export 3mf to " << export_3mf_file << std::endl; if (! this->export_project(&m_models[0], export_3mf_file, plate_data_list, project_presets, thumbnails, top_thumbnails, pick_thumbnails, - calibration_thumbnails, plate_bboxes, &m_print_config)) + calibration_thumbnails, plate_bboxes, &m_print_config, minimum_save)) { release_PlateData_list(plate_data_list); record_exit_reson(outfile_dir, CLI_EXPORT_3MF_ERROR, 0, cli_errors[CLI_EXPORT_3MF_ERROR]); @@ -3854,7 +3860,7 @@ bool CLI::export_models(IO::ExportFormat format) //BBS: add export_project function bool CLI::export_project(Model *model, std::string& path, PlateDataPtrs &partplate_data, std::vector& project_presets, std::vector& thumbnails, std::vector& top_thumbnails, std::vector& pick_thumbnails, - std::vector& calibration_thumbnails, std::vector& plate_bboxes, const DynamicPrintConfig* config) + std::vector& calibration_thumbnails, std::vector& plate_bboxes, const DynamicPrintConfig* config, bool minimum_save) { //const std::string path = this->output_filepath(*model, IO::TMF); bool success = false; @@ -3871,6 +3877,8 @@ bool CLI::export_project(Model *model, std::string& path, PlateDataPtrs &partpla store_params.calibration_thumbnail_data = calibration_thumbnails; store_params.id_bboxes = plate_bboxes; store_params.strategy = SaveStrategy::Silence|SaveStrategy::WithGcode|SaveStrategy::SplitModel|SaveStrategy::UseLoadedId|SaveStrategy::ShareMesh; + if (minimum_save) + store_params.strategy = store_params.strategy | SaveStrategy::SkipModel; success = Slic3r::store_bbs_3mf(store_params); diff --git a/src/BambuStudio.hpp b/src/BambuStudio.hpp index 71507738d..ba4fcf969 100644 --- a/src/BambuStudio.hpp +++ b/src/BambuStudio.hpp @@ -41,7 +41,7 @@ private: bool export_project(Model *model, std::string& path, PlateDataPtrs &partplate_data, std::vector& project_presets, std::vector& thumbnails, std::vector& top_thumbnails, std::vector& pick_thumbnails, std::vector& calibration_thumbnails, - std::vector& plate_bboxes, const DynamicPrintConfig* config); + std::vector& plate_bboxes, const DynamicPrintConfig* config, bool minimum_save); bool has_print_action() const { return m_config.opt_bool("export_gcode") || m_config.opt_bool("export_sla"); } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 7af99c373..692da86f2 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -5014,6 +5014,12 @@ CLIActionsConfigDef::CLIActionsConfigDef() def->cli_params = "option"; def->set_default_value(new ConfigOptionBool(false)); + def = this->add("min_save", coBool); + def->label = L("Minimum save"); + def->tooltip = L("export 3mf with minimum size."); + def->cli_params = "option"; + def->set_default_value(new ConfigOptionBool(false)); + def = this->add("mtcpp", coInt); def->label = L("mtcpp"); def->tooltip = L("max triangle count per plate for slicing.");