mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00:00
FIX: The retract error generated by the travel
When the retraction setting is larger than the retraction during the material change, the travel triggered during the material change will make up for the retraction interpolation, but the retracted extruder head will be the wrong one. By moving the travel part in the extruder switch Gcode to after the traditional head change (where m_curr_extruder_id in writer() is updated), the old ID is avoided during travel. jira: STUDIO-14764 Change-Id: I8af8f66af180f01de2fef5760601ee54e73548c4 (cherry picked from commit 008c436803cdf48d3bdcf6fcd85596fc91b3fc70)
This commit is contained in:
@@ -815,6 +815,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||||||
|
|
||||||
end_filament_gcode_str = toolchange_retract_str + end_filament_gcode_str;
|
end_filament_gcode_str = toolchange_retract_str + end_filament_gcode_str;
|
||||||
|
|
||||||
|
bool need_travel_after_change_filament_gcode = false; // travel need be after the filament changed to get the correct "m_curr_extruder_id"
|
||||||
if (! change_filament_gcode.empty()) {
|
if (! change_filament_gcode.empty()) {
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
int old_filament_id = gcodegen.writer().filament() ? (int)gcodegen.writer().filament()->id() : -1;
|
int old_filament_id = gcodegen.writer().filament() ? (int)gcodegen.writer().filament()->id() : -1;
|
||||||
@@ -934,7 +935,19 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||||||
gcodegen.writer().set_position(pos);
|
gcodegen.writer().set_position(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
need_travel_after_change_filament_gcode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string toolchange_command;
|
||||||
|
if (tcr.priming || (new_filament_id >= 0 && gcodegen.writer().need_toolchange(new_filament_id)))
|
||||||
|
toolchange_command = gcodegen.writer().toolchange(new_filament_id);
|
||||||
|
if (!custom_gcode_changes_tool(toolchange_gcode_str, gcodegen.writer().toolchange_prefix(), new_filament_id))
|
||||||
|
toolchange_gcode_str += toolchange_command;
|
||||||
|
else {
|
||||||
|
// We have informed the m_writer about the current extruder_id, we can ignore the generated G-code.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (need_travel_after_change_filament_gcode) {
|
||||||
// move to start_pos for wiping after toolchange
|
// move to start_pos for wiping after toolchange
|
||||||
if (!is_used_travel_avoid_perimeter) {
|
if (!is_used_travel_avoid_perimeter) {
|
||||||
std::string start_pos_str = gcodegen.travel_to(wipe_tower_point_to_object_point(gcodegen, tool_change_start_pos + plate_origin_2d), erMixed, "Move to start pos");
|
std::string start_pos_str = gcodegen.travel_to(wipe_tower_point_to_object_point(gcodegen, tool_change_start_pos + plate_origin_2d), erMixed, "Move to start pos");
|
||||||
@@ -949,19 +962,17 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||||||
Point start_wipe_pos = wipe_tower_point_to_object_point(gcodegen, tool_change_start_pos + plate_origin_2d);
|
Point start_wipe_pos = wipe_tower_point_to_object_point(gcodegen, tool_change_start_pos + plate_origin_2d);
|
||||||
BoundingBox avoid_bbx, printer_bbx;
|
BoundingBox avoid_bbx, printer_bbx;
|
||||||
{
|
{
|
||||||
//set printer_bbx
|
// set printer_bbx
|
||||||
Pointfs bed_pointsf = gcodegen.m_config.printable_area.values;
|
Pointfs bed_pointsf = gcodegen.m_config.printable_area.values;
|
||||||
Points bed_points;
|
Points bed_points;
|
||||||
for (auto p : bed_pointsf) {
|
for (auto p : bed_pointsf) { bed_points.push_back(wipe_tower_point_to_object_point(gcodegen, p.cast<float>() + plate_origin_2d)); }
|
||||||
bed_points.push_back(wipe_tower_point_to_object_point(gcodegen, p.cast<float>() + plate_origin_2d));
|
|
||||||
}
|
|
||||||
printer_bbx = BoundingBox(bed_points);
|
printer_bbx = BoundingBox(bed_points);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
//set avoid_bbx
|
// set avoid_bbx
|
||||||
avoid_bbx = scaled(m_wipe_tower_bbx);
|
avoid_bbx = scaled(m_wipe_tower_bbx);
|
||||||
Polygon avoid_points = avoid_bbx.polygon();
|
Polygon avoid_points = avoid_bbx.polygon();
|
||||||
for (auto& p : avoid_points.points) {
|
for (auto &p : avoid_points.points) {
|
||||||
Vec2f pp = transform_wt_pt(unscale(p).cast<float>());
|
Vec2f pp = transform_wt_pt(unscale(p).cast<float>());
|
||||||
p = wipe_tower_point_to_object_point(gcodegen, pp + plate_origin_2d);
|
p = wipe_tower_point_to_object_point(gcodegen, pp + plate_origin_2d);
|
||||||
}
|
}
|
||||||
@@ -978,15 +989,6 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toolchange_command;
|
|
||||||
if (tcr.priming || (new_filament_id >= 0 && gcodegen.writer().need_toolchange(new_filament_id)))
|
|
||||||
toolchange_command = gcodegen.writer().toolchange(new_filament_id);
|
|
||||||
if (!custom_gcode_changes_tool(toolchange_gcode_str, gcodegen.writer().toolchange_prefix(), new_filament_id))
|
|
||||||
toolchange_gcode_str += toolchange_command;
|
|
||||||
else {
|
|
||||||
// We have informed the m_writer about the current extruder_id, we can ignore the generated G-code.
|
|
||||||
}
|
|
||||||
|
|
||||||
// do unretract after setting current extruder_id
|
// do unretract after setting current extruder_id
|
||||||
std::string toolchange_unretract_str = gcodegen.unretract();
|
std::string toolchange_unretract_str = gcodegen.unretract();
|
||||||
check_add_eol(toolchange_unretract_str);
|
check_add_eol(toolchange_unretract_str);
|
||||||
|
|||||||
Reference in New Issue
Block a user