From bb6c3a2d794bb2c570056ed91a3684b17136c6b8 Mon Sep 17 00:00:00 2001 From: remi durand Date: Thu, 24 Jun 2021 18:50:27 +0200 Subject: [PATCH] fix Z offset: fix crash (comes from commit 0a65e1b0d6a234bb9c9d58047940bed85260d700) fix slicing preview also fix a toolchange missing (just notifying the writer) supermerill/SuperSlicer#1347 --- src/libslic3r/GCode.cpp | 6 +++--- src/slic3r/GUI/GUI_Preview.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 5d019fdb1..efcf9610b 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1451,7 +1451,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu for (LayerToPrint <p : layers_to_print) { std::vector lrs; lrs.emplace_back(std::move(ltp)); - this->process_layer(file, print, print.m_print_statistics, lrs, tool_ordering.tools_for_layer(ltp.print_z() + print.config().z_offset), nullptr, *print_object_instance_sequential_active - object.instances().data()); + this->process_layer(file, print, print.m_print_statistics, lrs, tool_ordering.tools_for_layer(ltp.print_z()), nullptr, *print_object_instance_sequential_active - object.instances().data()); print.throw_if_canceled(); } #ifdef HAS_PRESSURE_EQUALIZER @@ -4059,7 +4059,7 @@ std::string GCode::set_extruder(uint16_t extruder_id, double print_z, bool no_to } if (!no_toolchange) { gcode+=toolchange(extruder_id, print_z); - } + }else m_writer.toolchange(extruder_id); return gcode; } @@ -4094,7 +4094,7 @@ std::string GCode::set_extruder(uint16_t extruder_id, double print_z, bool no_to if (!no_toolchange) { gcode += toolchange(extruder_id, print_z); - } + }else m_writer.toolchange(extruder_id); // Set the temperature if the wipe tower didn't (not needed for non-single extruder MM) // supermerill change: try to set the good temp, because the wipe tower don't use the gcode writer and so can write wrong stuff. diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 498b2ff34..d6e8cc242 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -663,7 +663,7 @@ wxBoxSizer* Preview::create_layers_slider_sizer() Info custom_gcode_per_print_z = m_layers_slider->GetTicksValues(); //remove z-shift from gcode output const float z_shift = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_float("z_offset"); - if (can_display_gcode() && z_shift != 0) { + if (can_display_gcode() && z_shift != 0 && ForceState::ForceExtrusions != current_force_state) { for (CustomGCode::Item& tick : custom_gcode_per_print_z.gcodes) { tick.print_z -= z_shift; } @@ -751,7 +751,7 @@ void Preview::update_layers_slider(const std::vector& layers_z, bool kee { //add z-shift from gcode output const float z_shift = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_float("z_offset"); - if (can_display_gcode() && z_shift != 0) { + if (can_display_gcode() && z_shift != 0 && ForceState::ForceExtrusions != current_force_state) { for (CustomGCode::Item& tick : ticks_info_from_model.gcodes) { tick.print_z += z_shift; }