From 6e7eeb08b840b9aed6190c8e75933f5ee88785ed Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Mon, 13 Jan 2025 18:57:26 +0800 Subject: [PATCH] ENH: cli: add more information into result.json jira: no-jira Change-Id: I59d5a249663f79bfd3fe830abd2587cc9e618593 --- src/BambuStudio.cpp | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index f2bb9b3d1..dd67d8ceb 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -1334,19 +1334,19 @@ int CLI::run(int argc, char **argv) /*BOOST_LOG_TRIVIAL(info) << "begin to setup params, argc=" << argc << std::endl; for (int index=0; index < argc; index++) BOOST_LOG_TRIVIAL(info) << "index="<< index <<", arg is "<< argv[index] <setup(debug_argc, debug_argv))*/ if (!this->setup(argc, argv)) @@ -5997,21 +5997,17 @@ int CLI::run(int argc, char **argv) //get predication and filament change PrintEstimatedStatistics& print_estimated_stat = gcode_result->print_statistics; const PrintEstimatedStatistics::Mode& time_mode = print_estimated_stat.modes[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)]; - auto it_wipe = std::find_if(time_mode.roles_times.begin(), time_mode.roles_times.end(), [](const std::pair& item) { return ExtrusionRole::erWipeTower == item.first; }); + auto it = std::find_if(time_mode.roles_times.begin(), time_mode.roles_times.end(), [](const std::pair& item) { return ExtrusionRole::erWipeTower == item.first; }); sliced_plate_info.total_predication = time_mode.time; sliced_plate_info.main_predication = time_mode.time - time_mode.prepare_time; - sliced_plate_info.filament_change_times = print_estimated_stat.total_filamentchanges; - if (it_wipe != time_mode.roles_times.end()) { + sliced_plate_info.filament_change_times = print_estimated_stat.total_filament_changes; + if (it != time_mode.roles_times.end()) { //filament changes time will be included in prime tower time later //ConfigOptionFloat* machine_load_filament_time_opt = m_print_config.option("machine_load_filament_time"); //ConfigOptionFloat* machine_unload_filament_time_opt = m_print_config.option("machine_unload_filament_time"); - sliced_plate_info.main_predication -= it_wipe->second; + sliced_plate_info.main_predication -= it->second; //sliced_plate_info.main_predication -= sliced_plate_info.filament_change_times * (machine_load_filament_time_opt->value + machine_unload_filament_time_opt->value); } - auto it_flush = std::find_if(time_mode.roles_times.begin(), time_mode.roles_times.end(), [](const std::pair& item) { return ExtrusionRole::erFlush == item.first; }); - if (it_flush != time_mode.roles_times.end()) { - sliced_plate_info.main_predication -= it_flush->second; - } bool has_tool_change = false; auto custom_gcodes_iter = model.plates_custom_gcodes.find(index); if (custom_gcodes_iter != model.plates_custom_gcodes.end()) @@ -6024,7 +6020,7 @@ int CLI::run(int argc, char **argv) } } if (has_tool_change) - sliced_plate_info.layer_filament_change = print_estimated_stat.total_filamentchanges; + sliced_plate_info.layer_filament_change = print_estimated_stat.total_filament_changes; //filaments auto* filament_ids = dynamic_cast(m_print_config.option("filament_ids")); @@ -6038,10 +6034,7 @@ int CLI::run(int argc, char **argv) filament_info.id = iter.first + 1; filament_info.total_used_g = iter.second; - if (filament_ids && (filament_info.id <= filament_ids->values.size())) - filament_info.filament_id = filament_ids->values[iter.first]; - else - filament_info.filament_id = "unknown"; + filament_info.filament_id = (filament_info.id <= filament_ids->values.size())? filament_ids->values[iter.first] : "unknown"; auto main_iter = print_estimated_stat.model_volumes_per_extruder.find(iter.first); if (main_iter != print_estimated_stat.model_volumes_per_extruder.end()) @@ -7174,8 +7167,8 @@ std::string CLI::output_filepath(const ModelObject &object, unsigned int index, // use --outputdir when available file_name = object.name.empty()?object.input_file:object.name; file_name = "obj_"+std::to_string(index)+"_"+file_name; - size_t pos = file_name.rfind(ext), ext_pos = file_name.size() - ext.size(); - if ((pos == std::string::npos) || (pos != ext_pos)) + size_t pos = file_name.find_last_of(ext), ext_pos = file_name.size() - 1; + if (pos != ext_pos) file_name += ext; BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": dir = "<< path_dir<<", file_name="<