Permalink
Browse files

New toolchange_gcode option. #547

  • Loading branch information...
alexrj committed Dec 23, 2012
1 parent db754dc commit e59ed7efb726810c07a6b0028d67532ee9f680e7
Showing with 28 additions and 1 deletion.
  1. +1 −0 README.markdown
  2. +13 −1 lib/Slic3r/Config.pm
  3. +8 −0 lib/Slic3r/GCode.pm
  4. +5 −0 lib/Slic3r/GUI/Tab.pm
  5. +1 −0 slic3r.pl
View
@@ -176,6 +176,7 @@ The author of the Silk icon set is Mark James.
the default commands (turn off temperature [M104 S0],
home X axis [G28 X], disable motors [M84]).
--layer-gcode Load layer-change G-code from the supplied file (default: nothing).
+ --toolchange-gcode Load tool-change G-code from the supplied file (default: nothing).
--extra-perimeters Add more perimeters when needed (default: yes)
--randomize-start Randomize starting point across layers (default: yes)
--only-retract-when-crossing-perimeters
View
@@ -607,6 +607,18 @@ END
deserialize => sub { join "\n", split /\\n/, $_[0] },
default => '',
},
+ 'toolchange_gcode' => {
+ label => 'Tool change G-code',
+ tooltip => 'This custom code is inserted at every extruder change. Note that you can use placeholder variables for all Slic3r settings as well as [previous_extruder] and [next_extruder].',
+ cli => 'toolchange-gcode=s',
+ type => 's',
+ multiline => 1,
+ full_width => 1,
+ height => 50,
+ serialize => sub { join '\n', split /\R+/, $_[0] },
+ deserialize => sub { join "\n", split /\\n/, $_[0] },
+ default => '',
+ },
'post_process' => {
label => 'Post-processing scripts',
tooltip => 'If you want to process the output G-code through custom scripts, just list their absolute paths here. Separate multiple scripts with a semicolon. Scripts will be passed the absolute path to the G-code file as the first argument, and they can access the Slic3r config settings by reading environment variables.',
@@ -925,7 +937,7 @@ sub new_from_cli {
delete $args{$_} for grep !defined $args{$_}, keys %args;
- for (qw(start end layer)) {
+ for (qw(start end layer toolchange)) {
my $opt_key = "${_}_gcode";
if ($args{$opt_key}) {
die "Invalid value for --${_}-gcode: file does not exist\n"
View
@@ -442,6 +442,14 @@ sub set_extruder {
my $gcode = "";
$gcode .= $self->retract(toolchange => 1) if defined $self->extruder;
+ # append custom toolchange G-code
+ if (defined $self->extruder && $Slic3r::Config->toolchange_gcode) {
+ $gcode .= sprintf "%s\n", $Slic3r::Config->replace_options($Slic3r::Config->toolchange_gcode, {
+ previous_extruder => $self->extruder->id,
+ next_extruder => $extruder->id,
+ });
+ }
+
# set the new extruder
$self->extruder($extruder);
$gcode .= sprintf "T%d%s\n", $extruder->id, ($Slic3r::Config->gcode_comments ? ' ; change extruder' : '');
View
@@ -656,6 +656,11 @@ sub build {
no_labels => 1,
options => [qw(layer_gcode)],
},
+ {
+ title => 'Tool change G-code',
+ no_labels => 1,
+ options => [qw(toolchange_gcode)],
+ },
]);
$self->{extruder_pages} = [];
View
@@ -224,6 +224,7 @@ sub usage {
the default commands (turn off temperature [M104 S0],
home X axis [G28 X], disable motors [M84]).
--layer-gcode Load layer-change G-code from the supplied file (default: nothing).
+ --toolchange-gcode Load tool-change G-code from the supplied file (default: nothing).
--extra-perimeters Add more perimeters when needed (default: yes)
--randomize-start Randomize starting point across layers (default: yes)
--only-retract-when-crossing-perimeters

0 comments on commit e59ed7e

Please sign in to comment.