From 1a06e35687722c514794b980014c81eab1cb7ccd Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 26 Mar 2012 12:14:15 +0200 Subject: [PATCH] New option to specify G-code to be used at layer change. #279 --- README.markdown | 4 ++-- lib/Slic3r.pm | 1 + lib/Slic3r/Config.pm | 16 +++++++++++++--- lib/Slic3r/Extruder.pm | 3 +++ lib/Slic3r/GUI/SkeinPanel.pm | 2 +- slic3r.pl | 8 ++++---- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.markdown b/README.markdown index 98cf1e4c2..3abd61d7a 100644 --- a/README.markdown +++ b/README.markdown @@ -143,8 +143,7 @@ The author is Alessandro Ranellucci (me). Infill every N layers (default: 1) Print options: - --perimeters Number of perimeters/horizontal skins (range: 0+, - default: 3) + --perimeters Number of perimeters/horizontal skins (range: 0+, default: 3) --solid-layers Number of solid layers to do for top/bottom surfaces (range: 1+, default: 3) --fill-density Infill density (range: 0-1, default: 0.4) @@ -156,6 +155,7 @@ The author is Alessandro Ranellucci (me). --end-gcode Load final gcode from the supplied file. This will overwrite the default commands (turn off temperature [M104 S0], home X axis [G28 X], disable motors [M84]). + --layer-gcode Load layer-change G-code from the supplied file (default: nothing). --support-material Generate support material for overhangs Retraction options: diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 851e8ce3d..5c5e3b063 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -109,6 +109,7 @@ M104 S0 ; turn off temperature G28 X0 ; home X axis M84 ; disable motors END +our $layer_gcode = ''; # retraction options our $retract_length = 1; # mm diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 2b8e74e6d..3f6713afc 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -255,7 +255,7 @@ our $Options = { type => 's', multiline => 1, width => 350, - height => 150, + height => 120, serialize => sub { join '\n', split /\R+/, $_[0] }, deserialize => sub { join "\n", split /\\n/, $_[0] }, }, @@ -265,7 +265,17 @@ our $Options = { type => 's', multiline => 1, width => 350, - height => 150, + height => 120, + serialize => sub { join '\n', split /\R+/, $_[0] }, + deserialize => sub { join "\n", split /\\n/, $_[0] }, + }, + 'layer_gcode' => { + label => 'Layer Change GCODE', + cli => 'layer-gcode=s', + type => 's', + multiline => 1, + width => 350, + height => 50, serialize => sub { join '\n', split /\R+/, $_[0] }, deserialize => sub { join "\n", split /\\n/, $_[0] }, }, @@ -475,7 +485,7 @@ sub validate_cli { my $class = shift; my ($opt) = @_; - for (qw(start end)) { + for (qw(start end layer)) { if (defined $opt->{$_."_gcode"}) { if ($opt->{$_."_gcode"} eq "") { set($_."_gcode", ""); diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index 5d846f767..ea0ec35ef 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -49,6 +49,9 @@ sub change_layer { $gcode .= $self->G0(undef, $z, 0, 'move to next layer') if $self->z != $z; + $gcode .= Slic3r::Config->replace_options($Slic3r::layer_gcode) . "\n" + if $Slic3r::layer_gcode; + return $gcode; } diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 526495d65..bb6e6d24c 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -64,7 +64,7 @@ sub new { }, gcode => { title => 'Custom GCODE', - options => [qw(start_gcode end_gcode gcode_comments post_process)], + options => [qw(start_gcode end_gcode layer_gcode gcode_comments post_process)], }, extrusion => { title => 'Extrusion', diff --git a/slic3r.pl b/slic3r.pl index 4156dd024..567ac0bdd 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -161,19 +161,19 @@ Usage: slic3r.pl [ OPTIONS ] file.stl Infill every N layers (default: $Slic3r::infill_every_layers) Print options: - --perimeters Number of perimeters/horizontal skins (range: 0+, - default: $Slic3r::perimeters) + --perimeters Number of perimeters/horizontal skins (range: 0+, default: $Slic3r::perimeters) --solid-layers Number of solid layers to do for top/bottom surfaces (range: 1+, default: $Slic3r::solid_layers) --fill-density Infill density (range: 0-1, default: $Slic3r::fill_density) --fill-angle Infill angle in degrees (range: 0-90, default: $Slic3r::fill_angle) --fill-pattern Pattern to use to fill non-solid layers (default: $Slic3r::fill_pattern) --solid-fill-pattern Pattern to use to fill solid layers (default: $Slic3r::solid_fill_pattern) - --start-gcode Load initial gcode from the supplied file. This will overwrite + --start-gcode Load initial G-code from the supplied file. This will overwrite the default command (home all axes [G28]). - --end-gcode Load final gcode from the supplied file. This will overwrite + --end-gcode Load final G-code from the supplied file. This will overwrite the default commands (turn off temperature [M104 S0], home X axis [G28 X], disable motors [M84]). + --layer-gcode Load layer-change G-code from the supplied file (default: nothing). --support-material Generate support material for overhangs Retraction options: