From 460e169c678474aa7e57fdb57d95e1e9058720d3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 9 Mar 2013 20:05:43 +0100 Subject: [PATCH] New option to disable retraction on layer change --- README.markdown | 2 ++ lib/Slic3r/Config.pm | 11 ++++++++++- lib/Slic3r/Extruder.pm | 2 +- lib/Slic3r/GCode.pm | 2 +- lib/Slic3r/GUI/Tab.pm | 4 ++-- slic3r.pl | 2 ++ 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index bf9b0c5e8..17976e39f 100644 --- a/README.markdown +++ b/README.markdown @@ -232,6 +232,8 @@ The author of the Silk icon set is Mark James. --retract-before-travel Only retract before travel moves of this length in mm (default: 2) --retract-lift Lift Z by the given distance in mm when retracting (default: 0) + --retract-layer-change + Enforce a retraction before each Z move (default: yes) Retraction options for multi-extruder setups: --retract-length-toolchange diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 324a51975..811ad7c58 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -745,6 +745,15 @@ END deserialize => $deserialize_comma, default => [0], }, + 'retract_layer_change' => { + label => 'Retract on layer change', + tooltip => 'This flag enforces a retraction whenever a Z move is done.', + cli => 'retract-layer-change!', + type => 'bool', + serialize => $serialize_comma, + deserialize => $deserialize_comma, + default => [1], + }, 'retract_length_toolchange' => { label => 'Length', tooltip => 'When retraction is triggered before changing tool, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder).', @@ -1012,7 +1021,7 @@ sub new_from_cli { } $args{$_} = $Options->{$_}{deserialize}->($args{$_}) - for grep exists $args{$_}, qw(print_center bed_size duplicate_grid extruder_offset); + for grep exists $args{$_}, qw(print_center bed_size duplicate_grid extruder_offset retract_layer_change); return $class->new(%args); } diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index ece4be017..bc124dad2 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -7,7 +7,7 @@ use constant OPTIONS => [qw( extruder_offset nozzle_diameter filament_diameter extrusion_multiplier temperature first_layer_temperature retract_length retract_lift retract_speed retract_restart_extra retract_before_travel - retract_length_toolchange retract_restart_extra_toolchange + retract_layer_change retract_length_toolchange retract_restart_extra_toolchange )]; has 'id' => (is => 'rw', required => 1); diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 08da0d09b..48b55bc33 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -103,7 +103,7 @@ sub move_z { my $gcode = ""; my $current_z = $self->z; if (!defined $current_z || $current_z != ($z + $self->lifted)) { - $gcode .= $self->retract(move_z => $z); + $gcode .= $self->retract(move_z => $z) if $self->extruder->retract_layer_change; $self->speed('travel'); $gcode .= $self->G0(undef, $z, 0, $comment || ('move to next layer (' . $self->layer->id . ')')) unless ($current_z // -1) != ($self->z // -1); diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 647d053be..eac4f9d57 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -687,7 +687,7 @@ sub build { } sub _extruder_options { qw(nozzle_diameter extruder_offset retract_length retract_lift retract_speed retract_restart_extra retract_before_travel - retract_length_toolchange retract_restart_extra_toolchange) } + retract_layer_change retract_length_toolchange retract_restart_extra_toolchange) } sub config { my $self = shift; @@ -720,7 +720,7 @@ sub _build_extruder_pages { title => 'Retraction', options => [ map "${_}#${extruder_idx}", - qw(retract_length retract_lift retract_speed retract_restart_extra retract_before_travel) + qw(retract_length retract_lift retract_speed retract_restart_extra retract_before_travel retract_layer_change) ], }, { diff --git a/slic3r.pl b/slic3r.pl index b450c0bb3..12173aa12 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -285,6 +285,8 @@ $j --retract-before-travel Only retract before travel moves of this length in mm (default: $config->{retract_before_travel}[0]) --retract-lift Lift Z by the given distance in mm when retracting (default: $config->{retract_lift}[0]) + --retract-layer-change + Enforce a retraction before each Z move (default: yes) Retraction options for multi-extruder setups: --retract-length-toolchange