diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 6fd99d4c8..f83f4ea5f 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -544,7 +544,7 @@ sub _G0_G1 { sub _Gx { my ($self, $gcode, $e, $F, $comment) = @_; - use XXX; ZZZ "here" if $F =~ /move/i; + $gcode .= sprintf " F%.3f", $F; # output extrusion distance @@ -583,7 +583,13 @@ sub set_extruder { # set the current extruder to the standby temperature if ($self->standby_points && defined $self->extruder) { # move to the nearest standby point - $gcode .= $self->travel_to($self->last_pos->nearest_point($self->standby_points)); + { + my $last_pos = $self->last_pos->clone; + $last_pos->translate(scale +$self->shift_x, scale +$self->shift_y); + my $standby_point = $last_pos->nearest_point($self->standby_points); + $standby_point->translate(scale -$self->shift_x, scale -$self->shift_y); + $gcode .= $self->travel_to($standby_point); + } my $temp = defined $self->layer && $self->layer->id == 0 ? $self->extruder->first_layer_temperature diff --git a/t/multi.t b/t/multi.t index fe1f81848..b57415d46 100644 --- a/t/multi.t +++ b/t/multi.t @@ -1,4 +1,4 @@ -use Test::More tests => 12; +use Test::More tests => 13; use strict; use warnings; @@ -10,6 +10,7 @@ BEGIN { use List::Util qw(first); use Slic3r; use Slic3r::Geometry qw(scale convex_hull); +use Slic3r::Geometry::Clipper qw(offset); use Slic3r::Test; { @@ -39,9 +40,11 @@ use Slic3r::Test; : $config->temperature->[$tool]; die 'standby temperature was not set before toolchange' if $tool_temp[$tool] != $expected_temp + $config->standby_temperature_delta; + + # ignore initial toolchange + push @toolchange_points, Slic3r::Point->new_scale($self->X, $self->Y); } $tool = $1; - push @toolchange_points, Slic3r::Point->new_scale($self->X, $self->Y); } elsif ($cmd eq 'M104' || $cmd eq 'M109') { my $t = $args->{T} // $tool; if ($tool_temp[$t] == 0) { @@ -55,7 +58,12 @@ use Slic3r::Test; } }); my $convex_hull = convex_hull(\@extrusion_points); - ok !(first { $convex_hull->contains_point($_) } @toolchange_points), 'all toolchanges happen outside skirt'; + ok !(defined first { $convex_hull->contains_point($_) } @toolchange_points), 'all toolchanges happen outside skirt'; + + # offset the skirt by the maximum displacement between extruders plus a safety extra margin + my $delta = scale(20 * sqrt(2) + 1); + my $outer_convex_hull = offset([$convex_hull], +$delta)->[0]; + ok !(defined first { !$outer_convex_hull->contains_point($_) } @toolchange_points), 'all toolchanges happen within expected area'; } {