diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 5739b2498..229383e99 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -97,6 +97,7 @@ our $solid_fill_pattern = 'rectilinear'; our $fill_density = 0.4; # 1 = 100% our $fill_angle = 45; our $support_material = 0; +our $support_material_tool = 0; our $start_gcode = "G28 ; home all axes"; our $end_gcode = <<"END"; M104 S0 ; turn off temperature diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 6e8579a90..268441d22 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -220,6 +220,13 @@ our $Options = { cli => 'support-material', type => 'bool', }, + 'support_material_tool' => { + label => 'Tool used to extrude support material', + cli => 'support-material-tool=i', + type => 'select', + values => [0,1], + labels => [qw(Primary Secondary)], + }, 'start_gcode' => { label => 'Start GCODE', cli => 'start-gcode=s', diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index 59efadf97..6057ae71c 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -326,4 +326,11 @@ sub _Gx { return "$gcode\n"; } +sub set_tool { + my $self = shift; + my ($tool) = @_; + + return sprintf "T%d%s\n", $tool, ($Slic3r::gcode_comments ? ' ; change tool' : ''); +} + 1; diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 0c9ebf721..f420d9e1e 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -41,7 +41,7 @@ sub new { }, print => { title => 'Print settings', - options => [qw(perimeters solid_layers fill_density fill_angle fill_pattern solid_fill_pattern support_material)], + options => [qw(perimeters solid_layers fill_density fill_angle fill_pattern solid_fill_pattern support_material support_material_tool)], }, retract => { title => 'Retraction', diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index b1f8f2285..2f5c40705 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -566,6 +566,9 @@ sub export_gcode { # set up our extruder object my $extruder = Slic3r::Extruder->new; + if ($Slic3r::support_material && $Slic3r::support_material_tool > 0) { + print $fh $extruder->set_tool(0); + } # write gcode commands layer by layer foreach my $layer (@{ $self->layers }) { @@ -594,8 +597,12 @@ sub export_gcode { # extrude support material if ($layer->support_fills) { + print $fh $extruder->set_tool($Slic3r::support_material_tool) + if $Slic3r::support_material_tool > 0; print $fh $extruder->extrude_path($_, 'support material') for $layer->support_fills->shortest_path($extruder->last_pos); + print $fh $extruder->set_tool(0) + if $Slic3r::support_material_tool > 0; } } }