From 19548fe301040b61e41ccbfa4a9bf7298038f096 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 24 Dec 2014 12:02:42 +0100 Subject: [PATCH] Don't perform wiping if we have just changed layer and no extrusions were performed before the first retraction. Includes regression test. #2214 --- lib/Slic3r/GCode.pm | 4 ++++ t/gcode.t | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 2e189c4996..6f6ba2dab1 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -96,6 +96,10 @@ sub change_layer { $gcode .= $self->retract; } $gcode .= $self->writer->travel_to_z($z, 'move to next layer (' . $self->layer->id . ')'); + + # forget last wiping path as wiping after raising Z is pointless + $self->wipe->path(undef); + return $gcode; } diff --git a/t/gcode.t b/t/gcode.t index 17393e7cf0..aa15098a0e 100644 --- a/t/gcode.t +++ b/t/gcode.t @@ -1,4 +1,4 @@ -use Test::More tests => 19; +use Test::More tests => 20; use strict; use warnings; @@ -24,14 +24,24 @@ use Slic3r::Test; { my $config = Slic3r::Config->new_from_defaults; $config->set('wipe', [1]); + $config->set('retract_layer_change', [0]); my $print = Slic3r::Test::init_print('20mm_cube', config => $config); my $have_wipe = 0; my @retract_speeds = (); + my $extruded_on_this_layer = 0; + my $wiping_on_new_layer = 0; Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { my ($self, $cmd, $args, $info) = @_; - if ($info->{retracting} && $info->{dist_XY} > 0) { + + if ($info->{travel} && $info->{dist_Z}) { + # changing layer + $extruded_on_this_layer = 0; + } elsif ($info->{extruding} && $info->{dist_XY}) { + $extruded_on_this_layer = 1; + } elsif ($info->{retracting} && $info->{dist_XY} > 0) { $have_wipe = 1; + $wiping_on_new_layer = 1 if !$extruded_on_this_layer; my $move_time = $info->{dist_XY} / ($args->{F} // $self->F); push @retract_speeds, abs($info->{dist_E}) / $move_time; } @@ -39,6 +49,7 @@ use Slic3r::Test; ok $have_wipe, "wipe"; ok !defined (first { abs($_ - $config->retract_speed->[0]*60) < 5 } @retract_speeds), 'wipe moves don\'t retract faster than configured speed'; + ok !$wiping_on_new_layer, 'no wiping after layer change'; } {