diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index e6b33b3bf..c082060c8 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -393,7 +393,7 @@ sub retract { $gcode .= $self->writer->reset_e; $gcode .= $self->writer->lift - if $self->writer->extruder->retract_length > 0; + if $self->writer->extruder->retract_length > 0 || $self->config->use_firmware_retraction; return $gcode; } diff --git a/t/retraction.t b/t/retraction.t index 8cacf686f..f1656bc7f 100644 --- a/t/retraction.t +++ b/t/retraction.t @@ -1,4 +1,4 @@ -use Test::More tests => 18; +use Test::More tests => 19; use strict; use warnings; @@ -182,6 +182,24 @@ use Slic3r::Test qw(_eq); is $double_unretractions, 0, 'no double unretractions'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('use_firmware_retraction', 1); + $config->set('retract_length', [0]); + + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + my $retracted = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'G10') { + $retracted = 1; + } + }); + + ok $retracted, 'retracting also when --retract-length is 0 but --use-firmware-retraction is enabled'; +} + { my $config = Slic3r::Config->new_from_defaults; $config->set('only_retract_when_crossing_perimeters', 1); diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp index 6554de342..c36ca4f45 100644 --- a/xs/src/libslic3r/GCodeWriter.cpp +++ b/xs/src/libslic3r/GCodeWriter.cpp @@ -417,6 +417,12 @@ std::string GCodeWriter::_retract(double length, double restart_extra, const std::string &comment) { std::ostringstream gcode; + + /* If firmware retraction is enabled, we use a fake value of 1 + since we ignore the actual configured retract_length which + might be 0, in which case the retraction logic gets skipped. */ + if (this->config.use_firmware_retraction) length = 1; + double dE = this->_extruder->retract(length, restart_extra); if (dE != 0) { if (this->config.use_firmware_retraction) {