From b73c301c5582af7945e656978a946c39f5b64d5e Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 11 Mar 2013 17:06:05 +0100 Subject: [PATCH] Bugfix: double lift at toolchange. #953 --- lib/Slic3r/GCode.pm | 16 +++++++++------- t/retraction.t | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 1cb2783a7..c3501d437 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -350,7 +350,7 @@ sub retract { # prepare moves $self->speed('retract'); my $retract = [undef, undef, -$length, $comment]; - my $lift = ($self->extruder->retract_lift == 0 || defined $params{move_z}) + my $lift = ($self->extruder->retract_lift == 0 || defined $params{move_z}) && !$self->lifted ? undef : [undef, $self->z + $self->extruder->retract_lift, 0, 'lift plate during travel']; @@ -371,12 +371,14 @@ sub retract { $gcode .= $self->G0(@$travel); } else { $gcode .= $self->G1(@$retract); - if (defined $params{move_z} && $self->extruder->retract_lift > 0) { - my $travel = [undef, $params{move_z} + $self->extruder->retract_lift, 0, 'move to next layer (' . $self->layer->id . ') and lift']; - $gcode .= $self->G0(@$travel); - $self->lifted($self->extruder->retract_lift); - } elsif ($lift) { - $gcode .= $self->G1(@$lift); + if (!$self->lifted) { + if (defined $params{move_z} && $self->extruder->retract_lift > 0) { + my $travel = [undef, $params{move_z} + $self->extruder->retract_lift, 0, 'move to next layer (' . $self->layer->id . ') and lift']; + $gcode .= $self->G0(@$travel); + $self->lifted($self->extruder->retract_lift); + } elsif ($lift) { + $gcode .= $self->G1(@$lift); + } } } $self->extruder->retracted($self->extruder->retracted + $length); diff --git a/t/retraction.t b/t/retraction.t index 3b90dfda7..f89700e94 100644 --- a/t/retraction.t +++ b/t/retraction.t @@ -43,6 +43,7 @@ my $test = sub { if (_eq($info->{dist_Z}, $print->extruders->[$tool]->retract_lift) || (_eq($info->{dist_Z}, $conf->layer_height + $print->extruders->[$tool]->retract_lift) && $print->extruders->[$tool]->retract_lift > 0)) { fail 'only lifting while retracted' if !$retracted[$tool] && !($conf->g0 && $info->{retracting}); + fail 'double lift' if $lifted; $lifted = 1; } if ($info->{dist_Z} < 0) {