From 8da4151c6d911e7a3772a0784939e6a7016a9973 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 28 Oct 2012 19:24:24 +0100 Subject: [PATCH] Fix regression causing skirt to be printed at Z = 0 after a recent commit --- lib/Slic3r/GCode.pm | 6 +++--- lib/Slic3r/Print.pm | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index c1bb3e0dd..dde29a5f5 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -9,7 +9,7 @@ has 'multiple_extruders' => (is => 'ro', default => sub {0} ); has 'layer' => (is => 'rw'); # this is not very correct, we should replace it with explicit layer_id and avoid using $self->layer->flow at all here because it's too general has 'shift_x' => (is => 'rw', default => sub {0} ); has 'shift_y' => (is => 'rw', default => sub {0} ); -has 'z' => (is => 'rw', default => sub {0} ); +has 'z' => (is => 'rw'); has 'speed' => (is => 'rw'); has 'extruder' => (is => 'rw'); @@ -76,7 +76,7 @@ sub move_z { my $gcode = ""; $gcode .= $self->retract(move_z => $z); $gcode .= $self->G0(undef, $z, 0, $comment || 'move to next layer (' . $self->layer->id . ')') - if $self->z != $z && !$self->lifted; + if (!defined $self->z || $self->z != $z) && !$self->lifted; return $gcode; } @@ -319,7 +319,7 @@ sub _G0_G1 { ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $self->extruder->extruder_offset->[Y]; #** $self->last_pos($point); } - if (defined $z && $z != $self->z) { + if (defined $z && (!defined $self->z || $z != $self->z)) { $self->z($z); $gcode .= sprintf " Z%.${dec}f", $z; } diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 8cf66cc8a..023a649fc 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -709,6 +709,8 @@ sub write_gcode { if ($skirt_done < $Slic3r::Config->skirt_height) { $gcodegen->shift_x($shift[X]); $gcodegen->shift_y($shift[Y]); + $gcode .= $gcodegen->set_extruder($self->extruders->[0]); # move_z requires extruder + $gcode .= $gcodegen->move_z($gcodegen->layer->print_z); $gcode .= $gcodegen->set_acceleration($Slic3r::Config->perimeter_acceleration); # skip skirt if we have a large brim if ($layer_id < $Slic3r::Config->skirt_height) { @@ -723,6 +725,7 @@ sub write_gcode { # extrude brim if ($layer_id == 0 && !$brim_done) { + $gcode .= $gcodegen->move_z($gcodegen->layer->print_z); $gcode .= $gcodegen->set_extruder($self->extruders->[$Slic3r::Config->support_material_extruder-1]); $gcodegen->shift_x($shift[X]); $gcodegen->shift_y($shift[Y]);