From 73e32dfe5dac245eaa5e0e3a291a661857027973 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 3 May 2015 20:18:34 +0200 Subject: [PATCH] Use unique continuous numbering for layer numbers in case of support material layers. #2634 --- lib/Slic3r/GCode.pm | 8 ++++---- lib/Slic3r/Print/GCode.pm | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 27f5dbe53..5398be0a8 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -21,7 +21,7 @@ has 'avoid_crossing_perimeters' => (is => 'rw', default => sub { Slic3r::GCode:: has 'enable_loop_clipping' => (is => 'rw', default => sub {1}); has 'enable_cooling_markers' => (is =>'rw', default => sub {0}); has 'layer_count' => (is => 'ro'); -has '_layer_index' => (is => 'rw', default => sub {-1}); # just a counter +has 'layer_index' => (is => 'rw', default => sub {-1}); # just a counter has 'layer' => (is => 'rw'); has '_seam_position' => (is => 'ro', default => sub { {} }); # $object => pos has 'first_layer' => (is => 'rw', default => sub {0}); # this flag triggers first layer speeds @@ -76,7 +76,7 @@ sub change_layer { my ($self, $layer) = @_; $self->layer($layer); - $self->_layer_index($self->_layer_index + 1); + $self->layer_index($self->layer_index + 1); $self->first_layer($layer->id == 0); # avoid computing islands and overhangs if they're not needed @@ -88,14 +88,14 @@ sub change_layer { my $gcode = ""; if (defined $self->layer_count) { - $gcode .= $self->writer->update_progress($self->_layer_index, $self->layer_count); + $gcode .= $self->writer->update_progress($self->layer_index, $self->layer_count); } my $z = $layer->print_z + $self->config->z_offset; # in unscaled coordinates if ($self->config->get_at('retract_layer_change', $self->writer->extruder->id) && $self->writer->will_move_z($z)) { $gcode .= $self->retract; } - $gcode .= $self->writer->travel_to_z($z, 'move to next layer (' . $self->layer->id . ')'); + $gcode .= $self->writer->travel_to_z($z, 'move to next layer (' . $self->layer_index . ')'); # forget last wiping path as wiping after raising Z is pointless $self->wipe->path(undef); diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index 8c7c7627f..871ca8b05 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -327,12 +327,12 @@ sub process_layer { # set new layer - this will change Z and force a retraction if retract_layer_change is enabled $gcode .= $self->_gcodegen->placeholder_parser->process($self->print->config->before_layer_gcode, { - layer_num => $layer->id, + layer_num => $self->_gcodegen->layer_index + 1, layer_z => $layer->print_z, }) . "\n" if $self->print->config->before_layer_gcode; - $gcode .= $self->_gcodegen->change_layer($layer); + $gcode .= $self->_gcodegen->change_layer($layer); # this will increase $self->_gcodegen->layer_index $gcode .= $self->_gcodegen->placeholder_parser->process($self->print->config->layer_gcode, { - layer_num => $layer->id, + layer_num => $self->_gcodegen->layer_index, layer_z => $layer->print_z, }) . "\n" if $self->print->config->layer_gcode;