Reset E and compensate retraction after changing extruder

This commit is contained in:
Alessandro Ranellucci 2012-07-06 19:57:58 +02:00
parent 96574e601f
commit 3c00573805
2 changed files with 14 additions and 7 deletions

View File

@ -247,10 +247,7 @@ sub retract {
# reset extrusion distance during retracts
# this makes sure we leave sufficient precision in the firmware
if (!$Slic3r::use_relative_e_distances && $Slic3r::gcode_flavor !~ /^(?:mach3|makerbot)$/) {
$gcode .= "G92 " . $Slic3r::extrusion_axis . "0\n" if $Slic3r::extrusion_axis;
$self->extrusion_distance(0);
}
$gcode .= $self->reset_e if $Slic3r::gcode_flavor !~ /^(?:mach3|makerbot)$/;
return $gcode;
}
@ -272,6 +269,14 @@ sub unretract {
return $gcode;
}
sub reset_e {
my $self = shift;
$self->extrusion_distance(0);
return "G92 %s0%s\n", $Slic3r::extrusion_axis, ($Slic3r::gcode_comments ? ' ; reset extrusion distance' : '')
if $Slic3r::extrusion_axis && !$Slic3r::use_relative_e_distances;
}
sub set_acceleration {
my $self = shift;
my ($acceleration) = @_;
@ -382,7 +387,10 @@ sub set_tool {
return "" if $self->extruder_idx == $tool;
$self->extruder_idx($tool);
return $self->retract . sprintf "T%d%s\n", $tool, ($Slic3r::gcode_comments ? ' ; change tool' : '');
return $self->retract
. sprintf "T%d%s\n", $tool, ($Slic3r::gcode_comments ? ' ; change tool' : '')
. $self->reset_e
. $self->unretract;
}
sub set_fan {

View File

@ -530,8 +530,7 @@ sub write_gcode {
print $fh "G90 ; use absolute coordinates\n";
print $fh "G21 ; set units to millimeters\n";
if ($Slic3r::gcode_flavor =~ /^(?:reprap|teacup)$/) {
printf $fh "G92 %s0 ; reset extrusion distance\n", $Slic3r::extrusion_axis
if $Slic3r::extrusion_axis && !$Slic3r::use_relative_e_distances;
printf $fh $gcodegen->reset_e;
if ($Slic3r::gcode_flavor =~ /^(?:reprap|makerbot)$/) {
if ($Slic3r::use_relative_e_distances) {
print $fh "M83 ; use relative distances for extrusion\n";