From 3c2464abf9455bbb9750251990dbdc2f3845765b Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 22 Aug 2012 17:58:38 +0200 Subject: [PATCH] Bugfix: crazy temperatures were written when using sequential printing. #625 --- lib/Slic3r/Print.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index ace8c5b07..314e08c12 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -571,11 +571,14 @@ sub write_gcode { # write start commands to file printf $fh $gcodegen->set_bed_temperature($Slic3r::Config->first_layer_bed_temperature, 1), - if $Slic3r::Config->first_layer_bed_temperature && $Slic3r::Config->start_gcode !~ /M190/i; - for my $t (grep $Slic3r::extruders->[$_], 0 .. $#{$Slic3r::Config->first_layer_temperature}) { - printf $fh $gcodegen->set_temperature($Slic3r::extruders->[$t]->first_layer_temperature, 0, $t) - if $Slic3r::extruders->[$t]->first_layer_temperature; - } + if $Slic3r::Config->first_layer_bed_temperature && $Slic3r::Config->start_gcode !~ /M190/i; + my $print_first_layer_temperature = sub { + for my $t (grep $Slic3r::extruders->[$_], 0 .. $#{$Slic3r::Config->first_layer_temperature}) { + printf $fh $gcodegen->set_temperature($Slic3r::extruders->[$t]->first_layer_temperature, 0, $t) + if $Slic3r::extruders->[$t]->first_layer_temperature; + } + }; + $print_first_layer_temperature->(); printf $fh "%s\n", $Slic3r::Config->replace_options($Slic3r::Config->start_gcode); for my $t (grep $Slic3r::extruders->[$_], 0 .. $#{$Slic3r::Config->first_layer_temperature}) { printf $fh $gcodegen->set_temperature($Slic3r::extruders->[$t]->first_layer_temperature, 1, $t) @@ -740,8 +743,7 @@ sub write_gcode { if ($layer_id == 0 && $finished_objects > 0) { printf $fh $gcodegen->set_bed_temperature($Slic3r::Config->first_layer_bed_temperature), if $Slic3r::Config->first_layer_bed_temperature; - printf $fh $gcodegen->set_temperature($Slic3r::Config->first_layer_temperature) - if $Slic3r::Config->first_layer_temperature; + $print_first_layer_temperature->(); } print $fh $extrude_layer->($layer_id, [[ $obj_idx, $copy ]]); }