FIX: error retract length of prime tower

github: 6733
Change-Id: I83cd50b9054de887a89389ccbeeb9fbc6de679d6
This commit is contained in:
zhimin.zeng 2025-04-28 20:46:53 +08:00 committed by lane.wei
parent 5d4dc53bdc
commit 6d2f21ef4c

View File

@ -579,6 +579,9 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
throw Slic3r::InvalidArgument("Error: WipeTowerIntegration::append_tcr was asked to do a toolchange it didn't expect."); throw Slic3r::InvalidArgument("Error: WipeTowerIntegration::append_tcr was asked to do a toolchange it didn't expect.");
int new_extruder_id = get_extruder_index(*m_print_config, new_filament_id); int new_extruder_id = get_extruder_index(*m_print_config, new_filament_id);
bool is_nozzle_change = !tcr.nozzle_change_result.gcode.empty() && (gcodegen.config().nozzle_diameter.size() > 1);
std::string gcode; std::string gcode;
// Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines) // Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines)
@ -662,7 +665,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
auto_lift_type = LiftType::SpiralLift; auto_lift_type = LiftType::SpiralLift;
// BBS: should be placed before toolchange parsing // BBS: should be placed before toolchange parsing
std::string toolchange_retract_str = gcodegen.retract(true, false, auto_lift_type, true); std::string toolchange_retract_str = gcodegen.retract(tcr.is_tool_change && !is_nozzle_change, false, auto_lift_type, true);
check_add_eol(toolchange_retract_str); check_add_eol(toolchange_retract_str);
// Process the custom change_filament_gcode. If it is empty, provide a simple Tn command to change the filament. // Process the custom change_filament_gcode. If it is empty, provide a simple Tn command to change the filament.
@ -673,7 +676,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
// add nozzle change gcode into change filament gcode // add nozzle change gcode into change filament gcode
std::string nozzle_change_gcode_trans; std::string nozzle_change_gcode_trans;
if (!tcr.nozzle_change_result.gcode.empty() && (gcodegen.config().nozzle_diameter.size() > 1)) { if (is_nozzle_change) {
// move to start_pos before nozzle change // move to start_pos before nozzle change
std::string start_pos_str; std::string start_pos_str;
start_pos_str = gcodegen.travel_to(wipe_tower_point_to_object_point(gcodegen, transform_wt_pt(tcr.nozzle_change_result.start_pos) + plate_origin_2d), erMixed, start_pos_str = gcodegen.travel_to(wipe_tower_point_to_object_point(gcodegen, transform_wt_pt(tcr.nozzle_change_result.start_pos) + plate_origin_2d), erMixed,
@ -686,7 +689,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
gcodegen.m_wipe.reset_path(); gcodegen.m_wipe.reset_path();
for (const Vec2f& wipe_pt : tcr.nozzle_change_result.wipe_path) for (const Vec2f& wipe_pt : tcr.nozzle_change_result.wipe_path)
gcodegen.m_wipe.path.points.emplace_back(wipe_tower_point_to_object_point(gcodegen, transform_wt_pt(wipe_pt) + plate_origin_2d)); gcodegen.m_wipe.path.points.emplace_back(wipe_tower_point_to_object_point(gcodegen, transform_wt_pt(wipe_pt) + plate_origin_2d));
nozzle_change_gcode_trans += gcodegen.retract(true, false, auto_lift_type, true); nozzle_change_gcode_trans += gcodegen.retract(tcr.is_tool_change, false, auto_lift_type, true);
end_filament_gcode_str = nozzle_change_gcode_trans + end_filament_gcode_str; end_filament_gcode_str = nozzle_change_gcode_trans + end_filament_gcode_str;
} }
@ -904,7 +907,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
gcodegen.m_wipe.reset_path(); gcodegen.m_wipe.reset_path();
for (const Vec2f& wipe_pt : tcr.wipe_path) for (const Vec2f& wipe_pt : tcr.wipe_path)
gcodegen.m_wipe.path.points.emplace_back(wipe_tower_point_to_object_point(gcodegen, transform_wt_pt(wipe_pt) + plate_origin_2d)); gcodegen.m_wipe.path.points.emplace_back(wipe_tower_point_to_object_point(gcodegen, transform_wt_pt(wipe_pt) + plate_origin_2d));
gcode += gcodegen.retract(true, false, auto_lift_type, true); gcode += gcodegen.retract(false, false, auto_lift_type, true);
} }
// Let the planner know we are traveling between objects. // Let the planner know we are traveling between objects.