Fix export all exporting the same gcode

This commit is contained in:
Martin Šach 2024-12-06 12:39:53 +01:00 committed by Lukas Matena
parent 34242a1932
commit 96da3bd3e3
2 changed files with 12 additions and 3 deletions

View File

@ -136,7 +136,10 @@ void GLCanvas3D::select_bed(int i, bool triggered_by_user)
if (wxGetApp().plater()->is_preview_shown()) {
s_reload_preview_after_switching_beds = true;
wxPostEvent(wxGetApp().plater(), SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW));
wxGetApp().plater()->get_camera().translate_world(s_multiple_beds.get_bed_translation(i) - s_multiple_beds.get_bed_translation(old_bed));
wxGetApp().plater()->get_camera().translate_world(
s_multiple_beds.get_bed_translation(i)
- s_multiple_beds.get_bed_translation(old_bed)
);
}
wxGetApp().plater()->schedule_background_process();
wxGetApp().plater()->object_list_changed(); // Updates Slice Now / Export buttons.

View File

@ -5928,6 +5928,7 @@ struct PrintToExport {
std::reference_wrapper<Slic3r::Print> print;
std::reference_wrapper<Slic3r::GCodeProcessorResult> processor_result;
boost::filesystem::path output_path;
std::size_t bed{};
};
void Plater::export_all_gcodes(bool prefer_removable) {
@ -5959,7 +5960,7 @@ void Plater::export_all_gcodes(bool prefer_removable) {
+ default_output_file.extension().string()
};
const fs::path output_file{output_dir / filename};
prints_to_export.push_back({*print, this->p->gcode_results[print_index], output_file});
prints_to_export.push_back({*print, this->p->gcode_results[print_index], output_file, print_index});
paths.push_back(output_file);
}
@ -5976,14 +5977,17 @@ void Plater::export_all_gcodes(bool prefer_removable) {
Print *original_print{&active_fff_print()};
GCodeProcessorResult *original_result{this->p->background_process.get_gcode_result()};
const int original_bed{s_multiple_beds.get_active_bed()};
ScopeGuard guard{[&](){
this->p->background_process.set_fff_print(original_print);
this->p->background_process.set_gcode_result(original_result);
s_multiple_beds.set_active_bed(original_bed);
}};
for (const PrintToExport &print_to_export : prints_to_export) {
this->p->background_process.set_fff_print(&print_to_export.print.get());
this->p->background_process.set_gcode_result(&print_to_export.processor_result.get());
this->p->background_process.set_temp_output_path(print_to_export.bed);
export_gcode_to_path(
print_to_export.output_path,
[&](const bool on_removable){
@ -6573,17 +6577,19 @@ void Plater::connect_gcode_all() {
const PrusaConnectNew connect{*print_host_ptr};
Print *original_print{&active_fff_print()};
const int original_bed{s_multiple_beds.get_active_bed()};
ScopeGuard guard{[&](){
this->p->background_process.set_fff_print(original_print);
s_multiple_beds.set_active_bed(original_bed);
}};
for (std::size_t print_index{0}; print_index < this->get_fff_prints().size(); ++print_index) {
const std::unique_ptr<Print> &print{this->get_fff_prints()[print_index]};
if (!print || print->empty()) {
continue;
}
this->p->background_process.set_fff_print(print.get());
this->p->background_process.set_temp_output_path(print_index);
PrintHostJob upload_job;
upload_job.upload_data = upload_job_template.upload_data;