Enhance GCode handling for Z-axis movements (#10803)

* Enhance GCode handling for Z-axis movements

- Updated `travel_to_z` method to include a `force` parameter, allowing forced Z movements.
- Modified GCode generation logic to ensure Z position is restored after unknown last positions.
- Enforce z restoreation after tool changer

* Improve filament_multitool_ramming logic

* fix indent
This commit is contained in:
SoftFever 2025-09-21 22:03:54 +08:00 committed by GitHub
parent 23ee1daac0
commit b483dff617
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 21 additions and 9 deletions

View file

@ -633,12 +633,12 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co
return out_string;
}
std::string GCodeWriter::travel_to_z(double z, const std::string &comment)
std::string GCodeWriter::travel_to_z(double z, const std::string &comment, bool force)
{
/* If target Z is lower than current Z but higher than nominal Z
we don't perform the move but we only adjust the nominal Z by
reducing the lift amount that will be used for unlift. */
if (!this->will_move_z(z)) {
if (!force && !this->will_move_z(z)) {
double nominal_z = m_pos(2) - m_lifted;
m_lifted -= (z - nominal_z);
if (std::abs(m_lifted) < EPSILON)