From 887634e1e2174b1bee55f4a3d37056ab57c2f4b7 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 29 Oct 2012 19:54:04 +0100 Subject: [PATCH] Use G92 to apply Z offset. #486 --- lib/Slic3r/GCode.pm | 2 +- lib/Slic3r/Print.pm | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 658fca26a..a127c9bfb 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -71,7 +71,7 @@ sub move_z { my $self = shift; my ($z, $comment) = @_; - $z = $Slic3r::Config->z_offset + $z * &Slic3r::SCALING_FACTOR; + $z = $z * &Slic3r::SCALING_FACTOR; my $gcode = ""; $gcode .= $self->retract(move_z => $z); diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 05eef7479..e6a1990e7 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -705,6 +705,14 @@ sub write_gcode { } } + # apply Z offset + if ($Slic3r::Config->z_offset > 0) { + printf $fh "G1 Z%s ; set Z offset\n", $Slic3r::Config->z_offset; + print $fh "G92 Z0 ; set Z offset\n"; + } elsif ($Slic3r::Config->z_offset < 0) { + printf $fh "G92 Z%s ; set Z offset\n", 1*(-$Slic3r::Config->z_offset); + } + # calculate X,Y shift to center print around specified origin my @print_bb = $self->bounding_box; my @shift = (