Fix first travel to wipe tower after layer change

This commit is contained in:
Martin Šach 2024-08-07 14:24:52 +02:00 committed by Lukas Matena
parent b94213bd35
commit 6cfad69a5a
3 changed files with 16 additions and 9 deletions

View File

@ -2564,7 +2564,7 @@ LayerResult GCodeGenerator::process_layer(
}
this->set_origin({0, 0});
bool moved_to_first_point{false};
this->m_moved_to_first_layer_point = false;
// Extrude the skirt, brim, support, perimeters, infill ordered by the extruders.
for (const ExtruderExtrusions &extruder_extrusions : extrusions)
@ -2589,7 +2589,7 @@ LayerResult GCodeGenerator::process_layer(
this->m_label_objects.update(nullptr);
}
if (!moved_to_first_point) {
if (!this->m_moved_to_first_layer_point) {
const Vec3crd point{to_3d(first_point, scaled(print_z))};
gcode += this->travel_to_first_position(point, print_z, ExtrusionRole::Mixed, [this]() {
@ -2598,7 +2598,6 @@ LayerResult GCodeGenerator::process_layer(
}
return m_label_objects.maybe_change_instance(m_writer);
});
moved_to_first_point = true;
}
if (!extruder_extrusions.skirt.empty()) {
@ -3116,6 +3115,7 @@ std::string GCodeGenerator::travel_to_first_position(const Vec3crd& point, const
this->writer().update_position(gcode_point);
}
this->m_moved_to_first_layer_point = true;
return gcode;
}

View File

@ -429,6 +429,8 @@ private:
std::optional<Vec3d> m_previous_layer_last_position;
std::optional<Vec3d> m_previous_layer_last_position_before_wipe;
bool m_moved_to_first_layer_point{false};
// This needs to be populated during the layer processing!
std::unique_ptr<CoolingBuffer> m_cooling_buffer;
std::unique_ptr<SpiralVase> m_spiral_vase;

View File

@ -68,6 +68,10 @@ std::string WipeTowerIntegration::append_tcr(GCodeGenerator &gcodegen, const Wip
gcode += gcodegen.retract_and_wipe();
gcodegen.m_avoid_crossing_perimeters.use_external_mp_once = true;
const std::string comment{"Travel to a Wipe Tower"};
if (!gcodegen.m_moved_to_first_layer_point) {
const Vec3crd point = to_3d(xy_point, scaled(z));
gcode += gcodegen.travel_to_first_position(point, current_z, ExtrusionRole::Mixed, [](){return "";});
} else {
if (gcodegen.last_position) {
gcode += gcodegen.travel_to(
*gcodegen.last_position, xy_point, ExtrusionRole::Mixed, comment, [](){return "";}
@ -76,6 +80,7 @@ std::string WipeTowerIntegration::append_tcr(GCodeGenerator &gcodegen, const Wip
gcode += gcodegen.writer().travel_to_xy(gcodegen.point_to_gcode(xy_point), comment);
gcode += gcodegen.writer().get_travel_to_z_gcode(z, comment);
}
}
gcode += gcodegen.unretract();
} else {
// When this is multiextruder printer without any ramming, we can just change