New --retract-lift option to lift Z while doing travel moves. #25

This commit is contained in:
Alessandro Ranellucci 2011-11-07 15:58:47 +01:00
parent 71a44e253c
commit b4e268efad
5 changed files with 27 additions and 3 deletions

View File

@ -75,6 +75,7 @@ our $retract_length = 1; # mm
our $retract_restart_extra = 0; # mm our $retract_restart_extra = 0; # mm
our $retract_speed = 40; # mm/sec our $retract_speed = 40; # mm/sec
our $retract_before_travel = 2; # mm our $retract_before_travel = 2; # mm
our $retract_lift = 0; # mm
# skirt options # skirt options
our $skirts = 1; our $skirts = 1;

View File

@ -116,6 +116,10 @@ our $Options = {
label => 'Minimum travel after retraction (mm)', label => 'Minimum travel after retraction (mm)',
type => 'f', type => 'f',
}, },
'retract_lift' => {
label => 'Lift Z (mm)',
type => 'f',
},
# skirt options # skirt options
'skirts' => { 'skirts' => {

View File

@ -8,6 +8,7 @@ has 'flow_ratio' => (is => 'rw', default => sub {1});
has 'extrusion_distance' => (is => 'rw', default => sub {0} ); has 'extrusion_distance' => (is => 'rw', default => sub {0} );
has 'retracted' => (is => 'rw', default => sub {1} ); # this spits out some plastic at start 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_pos' => (is => 'rw', default => sub { [0,0] } );
has 'last_f' => (is => 'rw', default => sub {0}); has 'last_f' => (is => 'rw', default => sub {0});
has 'dec' => (is => 'ro', default => sub { 3 } ); has 'dec' => (is => 'ro', default => sub { 3 } );
@ -43,7 +44,7 @@ sub move_z {
my $gcode = ""; my $gcode = "";
$gcode .= $self->retract; $gcode .= $self->retract(dont_lift => 1);
$gcode .= $self->G1(undef, $z, 0, 'move to next layer'); $gcode .= $self->G1(undef, $z, 0, 'move to next layer');
return $gcode; return $gcode;
@ -119,12 +120,19 @@ sub extrude {
sub retract { sub retract {
my $self = shift; my $self = shift;
my %params = @_;
return "" unless $Slic3r::retract_length > 0 return "" unless $Slic3r::retract_length > 0
&& !$self->retracted; && !$self->retracted;
$self->retracted(1); $self->retracted(1);
my $gcode = $self->G1(undef, undef, -$Slic3r::retract_length, "retract"); 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 # reset extrusion distance during retracts
# this makes sure we leave sufficient precision in the firmware # this makes sure we leave sufficient precision in the firmware
if (!$Slic3r::use_relative_e_distances) { if (!$Slic3r::use_relative_e_distances) {
@ -138,8 +146,17 @@ sub retract {
sub unretract { sub unretract {
my $self = shift; my $self = shift;
$self->retracted(0); $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"); "compensate retraction");
return $gcode;
} }
sub G1 { sub G1 {

View File

@ -37,7 +37,7 @@ sub new {
), ),
retract => Slic3r::GUI::OptionsGroup->new($self, retract => Slic3r::GUI::OptionsGroup->new($self,
title => 'Retraction', 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, skirt => Slic3r::GUI::OptionsGroup->new($self,
title => 'Skirt', title => 'Skirt',

View File

@ -58,6 +58,7 @@ GetOptions(
'retract-speed=i' => \$Slic3r::retract_speed, 'retract-speed=i' => \$Slic3r::retract_speed,
'retract-restart-extra=f' => \$Slic3r::retract_restart_extra, 'retract-restart-extra=f' => \$Slic3r::retract_restart_extra,
'retract-before-travel=f' => \$Slic3r::retract_before_travel, 'retract-before-travel=f' => \$Slic3r::retract_before_travel,
'retract-lift=f' => \$Slic3r::retract_lift,
# skirt options # skirt options
'skirts=i' => \$Slic3r::skirts, 'skirts=i' => \$Slic3r::skirts,
@ -175,6 +176,7 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
compensating retraction (default: $Slic3r::retract_restart_extra) compensating retraction (default: $Slic3r::retract_restart_extra)
--retract-before-travel --retract-before-travel
Only retract before travel moves of this length (default: $Slic3r::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: Skirt options:
--skirts Number of skirts to draw (default: $Slic3r::skirts) --skirts Number of skirts to draw (default: $Slic3r::skirts)