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');