From 1e3ce9b8c4910aa093cbb300285ce9741147ee63 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 23 Jun 2013 00:10:57 +0200 Subject: [PATCH] Complete retraction if the wipe path was too short for the full retract. #1264 --- lib/Slic3r/GCode.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 37a5f77d8..a067c9fad 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -441,9 +441,16 @@ sub retract { $self->speed('travel'); # subdivide the retraction + my $retracted = 0; for (1 .. $#$wipe_path) { my $segment_length = $wipe_path->[$_-1]->distance_to($wipe_path->[$_]); - $gcode .= $self->G1($wipe_path->[$_], undef, $retract->[2] * ($segment_length / $total_wipe_length), $retract->[3] . ";_WIPE"); + $retracted += my $e = $retract->[2] * ($segment_length / $total_wipe_length); + $gcode .= $self->G1($wipe_path->[$_], undef, $e, $retract->[3] . ";_WIPE"); + } + if ($retracted > $retract->[2]) { + # if we retracted less than we had to, retract the remainder + # TODO: add regression test + $gcode .= $self->G1(undef, undef, $retract->[2] - $retracted, $comment); } } else { $self->speed('retract');