diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index ce6702ad5..4b0245ee5 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -10,6 +10,7 @@ use Slic3r::Surface ':types'; has 'config' => (is => 'ro', required => 1); has 'extruders' => (is => 'ro', required => 1); has 'multiple_extruders' => (is => 'lazy'); +has 'standby_points' => (is => 'rw'); has 'enable_loop_clipping' => (is => 'rw', default => sub {1}); has 'enable_wipe' => (is => 'lazy'); # at least one extruder has wipe enabled has 'layer_count' => (is => 'ro', required => 1 ); @@ -396,7 +397,7 @@ sub travel_to { || ($self->config->only_retract_when_crossing_perimeters && (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->_upper_layer_islands}) && (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->_layer_islands})) - || ($role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->layer->support_islands})) + || (defined $role && $role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->layer->support_islands})) ) { $self->straight_once(0); $self->speed('travel'); @@ -665,6 +666,9 @@ sub set_extruder { # set the current extruder to the standby temperature if ($self->config->standby_temperature && defined $self->extruder) { + # move to the nearest standby point + $gcode .= $self->travel_to($self->last_pos->nearest_point($self->standby_points)); + my $temp = defined $self->layer && $self->layer->id == 0 ? $self->extruder->first_layer_temperature : $self->extruder->temperature; diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index bd6ef9343..d2264bdfe 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -270,6 +270,13 @@ sub init_extruders { role => 'support_material', )); } + + # enforce tall skirt if using standby_temperature + # NOTE: this is not idempotent (i.e. switching standby_temperature off will not revert skirt settings) + if ($self->config->standby_temperature) { + $self->config->set('skirt_height', 9999999999); + $self->config->set('skirts', 1) if $self->config->skirts == 0; + } } sub layer_count { @@ -562,7 +569,8 @@ EOF sub make_skirt { my $self = shift; - return unless $Slic3r::Config->skirts > 0; + return unless $Slic3r::Config->skirts > 0 + || ($Slic3r::Config->standby_temperature && @{$self->extruders} > 1); # collect points from all layers contained in skirt height my @points = (); @@ -787,6 +795,12 @@ sub write_gcode { )); } + # calculate wiping points if needed + if ($self->config->standby_temperature) { + my $outer_skirt = Slic3r::Polygon->new(@{convex_hull([ map $_->pp, map @$_, @{$self->skirt} ])}); + $gcodegen->standby_points([ map $_->clone, map @$_, @{offset([$outer_skirt], scale 3)} ]); + } + # prepare the layer processor my $layer_gcode = Slic3r::GCode::Layer->new( print => $self,