ENH: object_skip: use identify_id for cli when skipping object

Change-Id: Ibbe3262b4817f82b7ac824ba6d4b3efd7f0ed886
This commit is contained in:
lane.wei 2023-06-27 12:16:46 +08:00 committed by Lane.Wei
parent e50513ff75
commit ef06dfc931
5 changed files with 21 additions and 14 deletions

View file

@ -2217,7 +2217,7 @@ int CLI::run(int argc, char **argv)
part_plate->set_tmp_gcode_path(outfile); part_plate->set_tmp_gcode_path(outfile);
} }
BOOST_LOG_TRIVIAL(info) << "process finished, will export gcode temporily to " << outfile << std::endl; BOOST_LOG_TRIVIAL(info) << "process finished, will export gcode temporily to " << outfile << std::endl;
outfile = (dynamic_cast<Print*>(print))->export_gcode(outfile, gcode_result, nullptr); outfile = (dynamic_cast<Print*>(print))->export_gcode(outfile, gcode_result, nullptr, true);
//outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile); //outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile);
//m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); }); //m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); });
}/* else { }/* else {

View file

@ -1048,7 +1048,7 @@ bool GCode::is_BBL_Printer()
return false; return false;
} }
void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb) void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
{ {
PROFILE_CLEAR(); PROFILE_CLEAR();
@ -1108,7 +1108,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
try { try {
m_placeholder_parser_failed_templates.clear(); m_placeholder_parser_failed_templates.clear();
this->_do_export(*print, file, thumbnail_cb); this->_do_export(*print, file, thumbnail_cb, using_identify_id);
file.flush(); file.flush();
if (file.is_error()) { if (file.is_error()) {
file.close(); file.close();
@ -1437,7 +1437,7 @@ static BambuBedType to_bambu_bed_type(BedType type)
return bambu_bed_type; return bambu_bed_type;
} }
void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb) void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
{ {
PROFILE_FUNC(); PROFILE_FUNC();
@ -1530,7 +1530,14 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_label_objects_ids.reserve(print.num_object_instances()); m_label_objects_ids.reserve(print.num_object_instances());
for (const PrintObject* print_object : print.objects()) for (const PrintObject* print_object : print.objects())
for (const PrintInstance& print_instance : print_object->instances()) for (const PrintInstance& print_instance : print_object->instances())
m_label_objects_ids.push_back(print_instance.model_instance->id().id); {
size_t instance_identify_id;
if (using_identify_id && print_instance.model_instance->loaded_id > 0)
instance_identify_id = print_instance.model_instance->loaded_id;
else
instance_identify_id = print_instance.model_instance->id().id;
m_label_objects_ids.push_back(instance_identify_id);
}
std::sort(m_label_objects_ids.begin(), m_label_objects_ids.end()); std::sort(m_label_objects_ids.begin(), m_label_objects_ids.end());
std::string objects_id_list = "; model label id: "; std::string objects_id_list = "; model label id: ";

View file

@ -167,7 +167,7 @@ public:
// throws std::runtime_exception on error, // throws std::runtime_exception on error,
// throws CanceledException through print->throw_if_canceled(). // throws CanceledException through print->throw_if_canceled().
void do_export(Print* print, const char* path, GCodeProcessorResult* result = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr); void do_export(Print* print, const char* path, GCodeProcessorResult* result = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr, bool using_identify_id = false);
//BBS: set offset for gcode writer //BBS: set offset for gcode writer
void set_gcode_offset(double x, double y) { m_writer.set_xy_offset(x, y); m_processor.set_xy_offset(x, y);} void set_gcode_offset(double x, double y) { m_writer.set_xy_offset(x, y); m_processor.set_xy_offset(x, y);}
@ -277,7 +277,7 @@ private:
FILE *f = nullptr; FILE *f = nullptr;
GCodeProcessor &m_processor; GCodeProcessor &m_processor;
}; };
void _do_export(Print &print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb); void _do_export(Print &print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id = false);
static std::vector<LayerToPrint> collect_layers_to_print(const PrintObject &object); static std::vector<LayerToPrint> collect_layers_to_print(const PrintObject &object);
static std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> collect_layers_to_print(const Print &print); static std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> collect_layers_to_print(const Print &print);

View file

@ -1754,7 +1754,7 @@ void Print::process(bool use_cache)
// The export_gcode may die for various reasons (fails to process filename_format, // The export_gcode may die for various reasons (fails to process filename_format,
// write error into the G-code, cannot execute post-processing scripts). // write error into the G-code, cannot execute post-processing scripts).
// It is up to the caller to show an error message. // It is up to the caller to show an error message.
std::string Print::export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb) std::string Print::export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
{ {
// output everything to a G-code file // output everything to a G-code file
// The following call may die if the filename_format template substitution fails. // The following call may die if the filename_format template substitution fails.
@ -1774,7 +1774,7 @@ std::string Print::export_gcode(const std::string& path_template, GCodeProcessor
//BBS: compute plate offset for gcode-generator //BBS: compute plate offset for gcode-generator
const Vec3d origin = this->get_plate_origin(); const Vec3d origin = this->get_plate_origin();
gcode.set_gcode_offset(origin(0), origin(1)); gcode.set_gcode_offset(origin(0), origin(1));
gcode.do_export(this, path.c_str(), result, thumbnail_cb); gcode.do_export(this, path.c_str(), result, thumbnail_cb, using_identify_id);
//BBS //BBS
result->conflict_result = m_conflict_result; result->conflict_result = m_conflict_result;
return path.c_str(); return path.c_str();

View file

@ -699,7 +699,7 @@ public:
void process(bool use_cache = false) override; void process(bool use_cache = false) override;
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file. // Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
// If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r). // If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
std::string export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr); std::string export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr, bool using_identify_id = false);
//return 0 means successful //return 0 means successful
int export_cached_data(const std::string& dir_path, bool with_space=false); int export_cached_data(const std::string& dir_path, bool with_space=false);
int load_cached_data(const std::string& directory); int load_cached_data(const std::string& directory);