From fb96cdec76009335189f5bb2171ab3f419894e46 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 28 Jun 2012 16:48:56 +0200 Subject: [PATCH] Command line options to assign perimeters and infill to different extruders --- README.markdown | 7 +++++++ lib/Slic3r.pm | 6 +++++- lib/Slic3r/Config.pm | 32 +++++++++++++++++++++++--------- lib/Slic3r/Print.pm | 3 ++- slic3r.pl | 7 +++++++ 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index 6878773be..18fd8f2dc 100644 --- a/README.markdown +++ b/README.markdown @@ -240,6 +240,13 @@ The author is Alessandro Ranellucci. --support-material-extrusion-width Set a different extrusion width for support material --bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: 1) + + Multiple extruder options: + --perimeters-extruder + Extruder to use for perimeters (1+, default: 1) + --infill-extruder Extruder to use for infill (1+, default: 1) + --support-material-extruder + Extruder to use for support material (1+, default: 1) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 2bc73ea0b..42702898b 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -81,6 +81,11 @@ our $extrusion_multiplier = [1]; our $temperature = [200]; our $first_layer_temperature= []; +# extruder mapping (1-based indexes) +our $perimeters_extruder = 1; +our $infill_extruder = 1; +our $support_material_extruder = 1; + # speed options our $travel_speed = 130; # mm/s our $perimeter_speed = 30; # mm/s @@ -134,7 +139,6 @@ our $support_material_threshold = 45; our $support_material_pattern = 'rectilinear'; our $support_material_spacing = 2.5; our $support_material_angle = 0; -our $support_material_extruder = 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 3aa96c64b..b348c379b 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -121,6 +121,23 @@ our $Options = { deserialize => sub { [ split /,/, $_[0] ] }, }, + # extruder mapping + 'perimeters_extruder' => { + label => 'Perimeters extruder', + cli => 'perimeters-extruder=i', + type => 'i', + }, + 'infill_extruder' => { + label => 'Infill extruder', + cli => 'infill-extruder=i', + type => 'i', + }, + 'support_material_extruder' => { + label => 'Extruder', + cli => 'support-material-extruder=i', + type => 'i', + }, + # filament options 'first_layer_bed_temperature' => { label => 'First layer bed temperature (°C)', @@ -329,11 +346,6 @@ our $Options = { cli => 'support-material-angle=i', type => 'i', }, - 'support_material_extruder' => { - label => 'Extruder', - cli => 'support-material-extruder=i', - type => 'i', - }, 'start_gcode' => { label => 'Start G-code', cli => 'start-gcode=s', @@ -688,7 +700,7 @@ sub validate { # initialize extruder(s) $Slic3r::extruders = []; - for my $t (0, $Slic3r::support_material_extruder-1) { + for my $t (0, map $_-1, $Slic3r::perimeters_extruder, $Slic3r::infill_extruder, $Slic3r::support_material_extruder) { $Slic3r::extruders->[$t] ||= Slic3r::Extruder->new( map { $_ => Slic3r::Config->get($_)->[$t] // Slic3r::Config->get($_)->[0] } #/ qw(nozzle_diameter filament_diameter extrusion_multiplier temperature first_layer_temperature) @@ -703,9 +715,11 @@ sub validate { width => $Slic3r::first_layer_extrusion_width, ); } - $Slic3r::perimeters_flow = $Slic3r::extruders->[0]->make_flow(width => $Slic3r::perimeters_extrusion_width || $Slic3r::extrusion_width); - $Slic3r::infill_flow = $Slic3r::extruders->[0]->make_flow(width => $Slic3r::infill_extrusion_width || $Slic3r::extrusion_width); - $Slic3r::support_material_flow = $Slic3r::extruders->[ $Slic3r::support_material_extruder ] + $Slic3r::perimeters_flow = $Slic3r::extruders->[ $Slic3r::perimeters_extruder-1 ] + ->make_flow(width => $Slic3r::perimeters_extrusion_width || $Slic3r::extrusion_width); + $Slic3r::infill_flow = $Slic3r::extruders->[ $Slic3r::infill_extruder-1 ] + ->make_flow(width => $Slic3r::infill_extrusion_width || $Slic3r::extrusion_width); + $Slic3r::support_material_flow = $Slic3r::extruders->[ $Slic3r::support_material_extruder-1 ] ->make_flow(width => $Slic3r::support_material_extrusion_width || $Slic3r::extrusion_width); Slic3r::debugf "Default flow width = %s, spacing = %s, min_spacing = %s\n", diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 411bf931c..ed5964bc6 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -596,9 +596,11 @@ sub write_gcode { $gcodegen->shift_y($shift[Y] + unscale $copy->[Y]); # extrude perimeters + $gcode .= $gcodegen->set_tool($Slic3r::perimeters_extruder-1); $gcode .= $gcodegen->extrude($_, 'perimeter') for @{ $layer->perimeters }; # extrude fills + $gcode .= $gcodegen->set_tool($Slic3r::infill_extruder-1); $gcode .= $gcodegen->set_acceleration($Slic3r::infill_acceleration); for my $fill (@{ $layer->fills }) { $gcode .= $gcodegen->extrude_path($_, 'fill') @@ -610,7 +612,6 @@ sub write_gcode { $gcode .= $gcodegen->set_tool($Slic3r::support_material_extruder-1); $gcode .= $gcodegen->extrude_path($_, 'support material') for $layer->support_fills->shortest_path($gcodegen->last_pos); - $gcode .= $gcodegen->set_tool(0); } } return if !$gcode; diff --git a/slic3r.pl b/slic3r.pl index d532fbe66..6cf704ad7 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -285,6 +285,13 @@ $j --support-material-extrusion-width Set a different extrusion width for support material --bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: $Slic3r::bridge_flow_ratio) + + Multiple extruder options: + --perimeters-extruder + Extruder to use for perimeters (1+, default: 1) + --infill-extruder Extruder to use for infill (1+, default: 1) + --support-material-extruder + Extruder to use for support material (1+, default: 1) EOF exit ($exit_code || 0);