diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index f3e423fba..39eeafa9f 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -153,6 +153,10 @@ sub export { foreach my $start_gcode (@{ $self->config->start_filament_gcode }) { # process filament gcode in order $include_start_extruder_temp = $include_start_extruder_temp && ($start_gcode !~ /M(?:109|104)/i); } + my $include_end_extruder_temp = $self->config->end_gcode !~ /M(?:109|104)/i; + foreach my $end_gcode (@{ $self->config->end_filament_gcode }) { # process filament gcode in order + $include_end_extruder_temp = $include_end_extruder_temp && ($end_gcode !~ /M(?:109|104)/i); + } $self->_print_first_layer_temperature(0) if $include_start_extruder_temp; printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($self->config->start_gcode)); @@ -301,6 +305,12 @@ sub export { printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($end_gcode)); } printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($self->config->end_gcode)); + + $self->_print_off_temperature(0) + if $include_end_extruder_temp; + print $fh $self->_gcodegen->writer->set_bed_temperature(0, 0) + if $include_end_extruder_temp; + print $fh $gcodegen->writer->update_progress($gcodegen->layer_count, $gcodegen->layer_count, 1); # 100% print $fh $gcodegen->writer->postamble; @@ -356,6 +366,16 @@ sub _print_first_layer_temperature { } } +sub _print_off_temperature { + my ($self, $wait) = @_; + + for my $t (@{$self->print->extruders}) { + printf {$self->fh} $self->_gcodegen->writer->set_temperature(0, $wait, $t) + } +} + + + # Called per object's layer. # First a $gcode string is collected, # then filtered and finally written to a file $fh. diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index aeb240792..0287c12bf 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -221,7 +221,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("end_gcode", coString); def->label = "End G-code"; - def->tooltip = "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings."; + def->tooltip = "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings. If Slic3r detects M104, M109, M140 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions."; def->cli = "end-gcode=s"; def->multiline = true; def->full_width = true; @@ -230,7 +230,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("end_filament_gcode", coStrings); def->label = "End G-code"; - def->tooltip = "This end procedure is inserted at the end of the output file, before the printer end gcode. Note that you can use placeholder variables for all Slic3r settings. If you have multiple extruders, the gcode is processed in extruder order."; + def->tooltip = "This end procedure is inserted at the end of the output file, before the printer end gcode. Note that you can use placeholder variables for all Slic3r settings. If you have multiple extruders, the gcode is processed in extruder order. If Slic3r detects M104, M109, M140 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions."; def->cli = "end-filament-gcode=s@"; def->multiline = true; def->full_width = true;