diff --git a/README.markdown b/README.markdown index ca0d9a6f..46269718 100644 --- a/README.markdown +++ b/README.markdown @@ -249,6 +249,8 @@ The author of the Silk icon set is Mark James. --bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: 1) Multiple extruder options: + --extruder-offset Offset of each extruder, if firmware doesn't handle the displacement + (can be specified multiple times, default: 0x0) --perimeters-extruder Extruder to use for perimeters (1+, default: 1) --infill-extruder Extruder to use for infill (1+, default: 1) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index b44a111c..e545bb62 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -110,6 +110,16 @@ our $Options = { }, # extruders options + 'extruder_offset' => { + label => 'Extruder offset', + tooltip => 'If your firmware doesn\'t handle the extruder displacement you need the G-code to take it into account. This option lets you specify the displacement of each extruder with respect to the first one. It expects positive coordinates (they will be subtracted from the XY coordinate).', + sidetext => 'mm', + cli => 'extruder-offset=s@', + type => 'point', + serialize => sub { join ',', map { join 'x', @$_ } @{$_[0]} }, + deserialize => sub { [ map [ split /x/, $_ ], (ref $_[0] eq 'ARRAY') ? @{$_[0]} : (split /,/, $_[0]) ] }, + default => [[0,0]], + }, 'nozzle_diameter' => { label => 'Nozzle diameter', tooltip => 'This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)', @@ -818,7 +828,7 @@ sub new_from_cli { } $args{$_} = $Options->{$_}{deserialize}->($args{$_}) - for grep exists $args{$_}, qw(print_center bed_size duplicate_grid); + for grep exists $args{$_}, qw(print_center bed_size duplicate_grid extruder_offset); return $class->new(%args); } diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index 20d10d0d..25ddc0fd 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -4,6 +4,7 @@ use Moo; use Slic3r::Geometry qw(PI); use constant OPTIONS => [qw( + extruder_offset nozzle_diameter filament_diameter extrusion_multiplier temperature first_layer_temperature )]; has $_ => (is => 'ro', required => 1) for @{&OPTIONS}; diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index f42f005d..54ccdef8 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -295,8 +295,8 @@ sub _G0_G1 { if ($point) { $gcode .= sprintf " X%.${dec}f Y%.${dec}f", - ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x, - ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y; #** + ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $self->extruder->extruder_offset->[X], + ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $self->extruder->extruder_offset->[Y]; #** $self->last_pos($point); } if (defined $z && $z != $self->z) { @@ -315,8 +315,8 @@ sub G2_G3 { my $gcode = $orientation eq 'cw' ? "G2" : "G3"; $gcode .= sprintf " X%.${dec}f Y%.${dec}f", - ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x, - ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y; #** + ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $self->extruder->extruder_offset->[X], + ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $self->extruder->extruder_offset->[Y]; #** # XY distance of the center from the start position $gcode .= sprintf " I%.${dec}f J%.${dec}f", diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 881025ca..240963cd 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -611,6 +611,10 @@ sub _build_extruder_pages { title => 'Size', options => ['nozzle_diameter#' . $extruder_idx], }, + { + title => 'Position (for multi-extruder printers)', + options => ['extruder_offset#' . $extruder_idx], + }, ]); $self->{extruder_pages}[$extruder_idx]{disabled} = 0; } diff --git a/slic3r.pl b/slic3r.pl index 90da6aac..b317799b 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -291,6 +291,8 @@ $j --bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: $config->{bridge_flow_ratio}) Multiple extruder options: + --extruder-offset Offset of each extruder, if firmware doesn't handle the displacement + (can be specified multiple times, default: 0x0) --perimeters-extruder Extruder to use for perimeters (1+, default: 1) --infill-extruder Extruder to use for infill (1+, default: 1)