diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 256085e8e..380da3d94 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -75,6 +75,7 @@ our $retract_length = 1; # mm our $retract_restart_extra = 0; # mm our $retract_speed = 40; # mm/sec our $retract_before_travel = 2; # mm +our $retract_lift = 0; # mm # skirt options our $skirts = 1; diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 8db8a2dd4..aa640bdc0 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -116,6 +116,10 @@ our $Options = { label => 'Minimum travel after retraction (mm)', type => 'f', }, + 'retract_lift' => { + label => 'Lift Z (mm)', + type => 'f', + }, # skirt options 'skirts' => { diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index 42fe15a63..704a3d5a2 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -8,6 +8,7 @@ has 'flow_ratio' => (is => 'rw', default => sub {1}); has 'extrusion_distance' => (is => 'rw', default => sub {0} ); has 'retracted' => (is => 'rw', default => sub {1} ); # this spits out some plastic at start +has 'lifted' => (is => 'rw', default => sub {0} ); has 'last_pos' => (is => 'rw', default => sub { [0,0] } ); has 'last_f' => (is => 'rw', default => sub {0}); has 'dec' => (is => 'ro', default => sub { 3 } ); @@ -43,7 +44,7 @@ sub move_z { my $gcode = ""; - $gcode .= $self->retract; + $gcode .= $self->retract(dont_lift => 1); $gcode .= $self->G1(undef, $z, 0, 'move to next layer'); return $gcode; @@ -119,12 +120,19 @@ sub extrude { sub retract { my $self = shift; + my %params = @_; + return "" unless $Slic3r::retract_length > 0 && !$self->retracted; $self->retracted(1); my $gcode = $self->G1(undef, undef, -$Slic3r::retract_length, "retract"); + unless ($params{dont_lift} || $Slic3r::retract_lift == 0) { + $gcode .= $self->G1(undef, $self->z + $Slic3r::retract_lift, 0, 'lift plate during retraction'); + $self->lifted(1); + } + # reset extrusion distance during retracts # this makes sure we leave sufficient precision in the firmware if (!$Slic3r::use_relative_e_distances) { @@ -138,8 +146,17 @@ sub retract { sub unretract { my $self = shift; $self->retracted(0); - return $self->G1(undef, undef, ($Slic3r::retract_length + $Slic3r::retract_restart_extra), + my $gcode = ""; + + if ($self->lifted) { + $gcode .= $self->G1(undef, $self->z - $Slic3r::retract_lift, 0, 'restore layer Z'); + $self->lifted(0); + } + + $gcode .= $self->G1(undef, undef, ($Slic3r::retract_length + $Slic3r::retract_restart_extra), "compensate retraction"); + + return $gcode; } sub G1 { diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index f45382985..ab338498d 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -37,7 +37,7 @@ sub new { ), retract => Slic3r::GUI::OptionsGroup->new($self, title => 'Retraction', - options => [qw(retract_length retract_speed retract_restart_extra retract_before_travel)], + options => [qw(retract_length retract_lift retract_speed retract_restart_extra retract_before_travel)], ), skirt => Slic3r::GUI::OptionsGroup->new($self, title => 'Skirt', diff --git a/slic3r.pl b/slic3r.pl index bd245f714..a711d6f1b 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -58,6 +58,7 @@ GetOptions( 'retract-speed=i' => \$Slic3r::retract_speed, 'retract-restart-extra=f' => \$Slic3r::retract_restart_extra, 'retract-before-travel=f' => \$Slic3r::retract_before_travel, + 'retract-lift=f' => \$Slic3r::retract_lift, # skirt options 'skirts=i' => \$Slic3r::skirts, @@ -175,6 +176,7 @@ Usage: slic3r.pl [ OPTIONS ] file.stl compensating retraction (default: $Slic3r::retract_restart_extra) --retract-before-travel Only retract before travel moves of this length (default: $Slic3r::retract_before_travel) + --retract-lift Lift Z by the given distance in mm when retracting (default: $Slic3r::retract_lift) Skirt options: --skirts Number of skirts to draw (default: $Slic3r::skirts)