Print the brim using the support material extruder if we have a raft. #2957

This commit is contained in:
Alessandro Ranellucci 2017-03-13 23:47:52 +01:00
parent 3e8e0ec02f
commit 662031bc2d
2 changed files with 39 additions and 2 deletions

View File

@ -462,7 +462,11 @@ sub process_layer {
# extrude brim
if (!$self->_brim_done) {
$gcode .= $self->_gcodegen->set_extruder($self->print->regions->[0]->config->perimeter_extruder-1);
my $extr = $self->print->regions->[0]->config->perimeter_extruder-1;
if (my $o = first { $_->config->raft_layers > 0 } @{$self->objects}) {
$extr = $o->config->support_material_extruder-1;
}
$gcode .= $self->_gcodegen->set_extruder($extr);
$self->_gcodegen->set_origin(Slic3r::Pointf->new(0,0));
$self->_gcodegen->avoid_crossing_perimeters->set_use_external_mp(1);
$gcode .= $self->_gcodegen->extrude($_, 'brim', $object->config->support_material_speed)

View File

@ -1,4 +1,4 @@
use Test::More tests => 6;
use Test::More tests => 8;
use strict;
use warnings;
@ -89,6 +89,39 @@ use Slic3r::Test;
ok Slic3r::Test::gcode($print), 'successful G-code generation when skirt_height = 0 and skirts > 0';
}
{
my $config = Slic3r::Config->new_from_defaults;
$config->set('skirts', 0);
$config->set('brim_width', 5);
$config->set('perimeter_extruder', 2);
$config->set('support_material_extruder', 3);
my $test = sub {
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
my $tool = undef;
my $brim_tool = undef;
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
my ($self, $cmd, $args, $info) = @_;
if ($cmd =~ /^T(\d+)/) {
$tool = $1;
} elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
if (!defined $brim_tool) {
# first extrusion is brim
$brim_tool = $tool;
}
}
});
return $brim_tool;
};
is $test->(), $config->perimeter_extruder-1,
'brim is printed with the extruder used for the perimeters of first object';
$config->set('raft_layers', 1);
is $test->(), $config->support_material_extruder-1,
'if raft is enabled, brim is printed with the extruder used for it';
}
{
my $config = Slic3r::Config->new_from_defaults;
$config->set('layer_height', 0.4);