This commit is contained in:
SoftFever 2024-10-06 10:49:58 +08:00
parent a5d2fa1aed
commit 6f3c701a32
2 changed files with 11 additions and 5 deletions

View file

@ -729,6 +729,9 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
gcode += gcodegen.writer().unlift(); // Make sure there is no z-hop (in most cases, there isn't). gcode += gcodegen.writer().unlift(); // Make sure there is no z-hop (in most cases, there isn't).
double current_z = gcodegen.writer().get_position().z(); double current_z = gcodegen.writer().get_position().z();
gcode += gcodegen.writer().travel_to_z(current_z);
if (z == -1.) // in case no specific z was provided, print at current_z pos if (z == -1.) // in case no specific z was provided, print at current_z pos
z = current_z; z = current_z;
@ -4516,10 +4519,8 @@ std::string GCode::change_layer(coordf_t print_z)
comment << "move to next layer (" << m_layer_index << ")"; comment << "move to next layer (" << m_layer_index << ")";
gcode += m_writer.travel_to_z(z, comment.str()); gcode += m_writer.travel_to_z(z, comment.str());
} }
else {
//BBS: set m_need_change_layer_lift_z to be true so that z lift can be done in travel_to() function
m_need_change_layer_lift_z = true; m_need_change_layer_lift_z = true;
}
m_writer.get_position().z() = z; m_writer.get_position().z() = z;
@ -6036,6 +6037,11 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
} }
this->set_last_pos(travel.points.back()); this->set_last_pos(travel.points.back());
} }
if (m_need_change_layer_lift_z) {
gcode += m_writer._travel_to_z(m_writer.get_position().z(), comment + " travel_to_z");
m_need_change_layer_lift_z = false;
}
return gcode; return gcode;
} }

View file

@ -119,6 +119,7 @@ public:
// Returns whether this flavor supports separate print and travel acceleration. // Returns whether this flavor supports separate print and travel acceleration.
static bool supports_separate_travel_acceleration(GCodeFlavor flavor); static bool supports_separate_travel_acceleration(GCodeFlavor flavor);
std::string _travel_to_z(double z, const std::string &comment);
private: private:
// Extruders are sorted by their ID, so that binary search is possible. // Extruders are sorted by their ID, so that binary search is possible.
std::vector<Extruder> m_extruders; std::vector<Extruder> m_extruders;
@ -172,7 +173,6 @@ public:
Print Print
}; };
std::string _travel_to_z(double z, const std::string &comment);
std::string _spiral_travel_to_z(double z, const Vec2d &ij_offset, const std::string &comment); std::string _spiral_travel_to_z(double z, const Vec2d &ij_offset, const std::string &comment);
std::string _retract(double length, double restart_extra, const std::string &comment); std::string _retract(double length, double restart_extra, const std::string &comment);
std::string set_acceleration_internal(Acceleration type, unsigned int acceleration); std::string set_acceleration_internal(Acceleration type, unsigned int acceleration);