mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-20 14:39:06 +08:00
SPE-2636 Enforce z generation after layer change
There can be custom gcode that modifies the print head position.
This commit is contained in:
parent
419d857a4b
commit
57e984b083
@ -3235,7 +3235,7 @@ std::string GCodeGenerator::travel_to_first_position(const Vec3crd& point, const
|
|||||||
if (!EXTRUDER_CONFIG(travel_ramping_lift) && this->last_position) {
|
if (!EXTRUDER_CONFIG(travel_ramping_lift) && this->last_position) {
|
||||||
const Vec3crd from{to_3d(*this->last_position, scaled(from_z))};
|
const Vec3crd from{to_3d(*this->last_position, scaled(from_z))};
|
||||||
gcode = this->travel_to(
|
gcode = this->travel_to(
|
||||||
from, point, role, "travel to first layer point", insert_gcode
|
from, point, role, "travel to first layer point", insert_gcode, EnforceFirstZ::True
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
double lift{
|
double lift{
|
||||||
@ -3582,7 +3582,8 @@ std::string GCodeGenerator::_extrude(
|
|||||||
std::string GCodeGenerator::generate_travel_gcode(
|
std::string GCodeGenerator::generate_travel_gcode(
|
||||||
const Points3& travel,
|
const Points3& travel,
|
||||||
const std::string& comment,
|
const std::string& comment,
|
||||||
const std::function<std::string()>& insert_gcode
|
const std::function<std::string()>& insert_gcode,
|
||||||
|
const EnforceFirstZ enforce_first_z
|
||||||
) {
|
) {
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
|
|
||||||
@ -3606,7 +3607,18 @@ std::string GCodeGenerator::generate_travel_gcode(
|
|||||||
already_inserted = true;
|
already_inserted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gcode += this->m_writer.travel_to_xyz(gcode_point, comment);
|
if (enforce_first_z == EnforceFirstZ::True && i == 0) {
|
||||||
|
if (
|
||||||
|
std::abs(gcode_point.x() - m_writer.get_position().x()) < GCodeFormatter::XYZ_EPSILON
|
||||||
|
&& std::abs(gcode_point.y() - m_writer.get_position().y()) < GCodeFormatter::XYZ_EPSILON
|
||||||
|
) {
|
||||||
|
gcode += this->m_writer.travel_to_z_force(gcode_point.z(), comment);
|
||||||
|
} else {
|
||||||
|
gcode += this->m_writer.travel_to_xyz_force(gcode_point, comment);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gcode += this->m_writer.travel_to_xyz(gcode_point, comment);
|
||||||
|
}
|
||||||
this->last_position = point.head<2>();
|
this->last_position = point.head<2>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3704,7 +3716,8 @@ std::string GCodeGenerator::travel_to(
|
|||||||
const Vec3crd &end_point,
|
const Vec3crd &end_point,
|
||||||
ExtrusionRole role,
|
ExtrusionRole role,
|
||||||
const std::string &comment,
|
const std::string &comment,
|
||||||
const std::function<std::string()>& insert_gcode
|
const std::function<std::string()>& insert_gcode,
|
||||||
|
const GCodeGenerator::EnforceFirstZ enforce_first_z
|
||||||
) {
|
) {
|
||||||
const double initial_elevation{unscaled(start_point.z())};
|
const double initial_elevation{unscaled(start_point.z())};
|
||||||
|
|
||||||
@ -3771,7 +3784,7 @@ std::string GCodeGenerator::travel_to(
|
|||||||
}
|
}
|
||||||
travel.emplace_back(end_point);
|
travel.emplace_back(end_point);
|
||||||
|
|
||||||
return wipe_retract_gcode + generate_travel_gcode(travel, comment, insert_gcode);
|
return wipe_retract_gcode + generate_travel_gcode(travel, comment, insert_gcode, enforce_first_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCodeGenerator::retract_and_wipe(bool toolchange, bool reset_e)
|
std::string GCodeGenerator::retract_and_wipe(bool toolchange, bool reset_e)
|
||||||
|
@ -329,10 +329,16 @@ private:
|
|||||||
const std::vector<GCode::ExtrusionOrder::SupportPath> &support_extrusions
|
const std::vector<GCode::ExtrusionOrder::SupportPath> &support_extrusions
|
||||||
);
|
);
|
||||||
|
|
||||||
|
enum class EnforceFirstZ {
|
||||||
|
False,
|
||||||
|
True
|
||||||
|
};
|
||||||
|
|
||||||
std::string generate_travel_gcode(
|
std::string generate_travel_gcode(
|
||||||
const Points3& travel,
|
const Points3& travel,
|
||||||
const std::string& comment,
|
const std::string& comment,
|
||||||
const std::function<std::string()>& insert_gcode
|
const std::function<std::string()>& insert_gcode,
|
||||||
|
const EnforceFirstZ enforce_first_z = EnforceFirstZ::False
|
||||||
);
|
);
|
||||||
Polyline generate_travel_xy_path(
|
Polyline generate_travel_xy_path(
|
||||||
const Point& start,
|
const Point& start,
|
||||||
@ -340,12 +346,14 @@ private:
|
|||||||
const bool needs_retraction,
|
const bool needs_retraction,
|
||||||
bool& could_be_wipe_disabled
|
bool& could_be_wipe_disabled
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string travel_to(
|
std::string travel_to(
|
||||||
const Vec3crd &start_point,
|
const Vec3crd &start_point,
|
||||||
const Vec3crd &end_point,
|
const Vec3crd &end_point,
|
||||||
ExtrusionRole role,
|
ExtrusionRole role,
|
||||||
const std::string &comment,
|
const std::string &comment,
|
||||||
const std::function<std::string()>& insert_gcode
|
const std::function<std::string()>& insert_gcode,
|
||||||
|
const EnforceFirstZ enforce_first_z = EnforceFirstZ::False
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string travel_to_first_position(const Vec3crd& point, const double from_z, const ExtrusionRole role, const std::function<std::string()>& insert_gcode);
|
std::string travel_to_first_position(const Vec3crd& point, const double from_z, const ExtrusionRole role, const std::function<std::string()>& insert_gcode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user