From 52c9897edacc7600cb11c2f2e6a5f42b14d2849f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 1 Dec 2011 22:34:21 +0100 Subject: [PATCH] New --extrusion-axis option; removed --no-extrusion --- README.markdown | 3 ++- lib/Slic3r.pm | 2 +- lib/Slic3r/Config.pm | 8 ++++---- lib/Slic3r/Extruder.pm | 6 +++--- lib/Slic3r/GUI/SkeinPanel.pm | 2 +- lib/Slic3r/Print.pm | 2 +- slic3r.pl | 3 ++- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.markdown b/README.markdown index fd00d674a..fe0cc8180 100644 --- a/README.markdown +++ b/README.markdown @@ -89,7 +89,8 @@ The author is Alessandro Ranellucci (me). (default: 100,100) --use-relative-e-distances Use relative distances for extrusion in GCODE output - --no-extrusion Do not output any E value in GCODE + --extrusion-axis The axis used for extrusion; leave empty to disable extrusion + (default: E) --z-offset Additional height in mm to add to vertical coordinates (+/-, default: 0) --gcode-arcs Use G2/G3 commands for native arcs (experimental, not supported diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 093cda110..89cc5e3b1 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -37,7 +37,7 @@ use Slic3r::TriangleMesh::IntersectionLine; our $nozzle_diameter = 0.5; our $print_center = [100,100]; # object will be centered around this point our $use_relative_e_distances = 0; -our $no_extrusion = 0; +our $extrusion_axis = 'E'; our $z_offset = 0; our $gcode_arcs = 0; our $g0 = 0; diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 80b144506..e191f4d48 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -25,10 +25,10 @@ our $Options = { cli => 'use-relative-e-distances', type => 'bool', }, - 'no_extrusion' => { - label => 'No extrusion', - cli => 'no-extrusion', - type => 'bool', + 'extrusion_axis' => { + label => 'Extrusion axis', + cli => 'extrusion_axis', + type => 's', }, 'z_offset' => { label => 'Z offset', diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index 3cb24d96d..a550a83b7 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -181,7 +181,7 @@ sub retract { # reset extrusion distance during retracts # this makes sure we leave sufficient precision in the firmware if (!$Slic3r::use_relative_e_distances) { - $gcode .= "G92 E0\n"; + $gcode .= "G92 " . $Slic3r::extrusion_axis . "0\n"; $self->extrusion_distance(0); } @@ -278,10 +278,10 @@ sub _Gx { } # output extrusion distance - if ($e && !$Slic3r::no_extrusion) { + if ($e && $Slic3r::extrusion_axis) { $self->extrusion_distance(0) if $Slic3r::use_relative_e_distances; $self->extrusion_distance($self->extrusion_distance + $e); - $gcode .= sprintf " E%.5f", $self->extrusion_distance; + $gcode .= sprintf " %s%.5f", $Slic3r::extrusion_axis, $self->extrusion_distance; } $gcode .= sprintf " ; %s", $comment if $comment; diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 1edb2af2a..b2d92bdfa 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -17,7 +17,7 @@ sub new { my %panels = ( printer => { title => 'Printer', - options => [qw(nozzle_diameter print_center use_relative_e_distances no_extrusion z_offset)], + options => [qw(nozzle_diameter print_center use_relative_e_distances extrusion_axis z_offset)], }, filament => { title => 'Filament', diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 1545732a0..3cee61b8b 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -472,7 +472,7 @@ sub export_gcode { printf $fh "M109 S%d ; wait for temperature to be reached\n", $Slic3r::temperature if $Slic3r::temperature; print $fh "G90 ; use absolute coordinates\n"; print $fh "G21 ; set units to millimeters\n"; - print $fh "G92 E0 ; reset extrusion distance\n" if !$Slic3r::no_extrusion; + printf $fh "G92 %s0 ; reset extrusion distance\n", $Slic3r::extrusion_axis if $Slic3r::extrusion_axis; if ($Slic3r::use_relative_e_distances) { print $fh "M83 ; use relative distances for extrusion\n"; } else { diff --git a/slic3r.pl b/slic3r.pl index 513daa988..e09c48d9d 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -95,7 +95,8 @@ Usage: slic3r.pl [ OPTIONS ] file.stl (default: $Slic3r::print_center->[0],$Slic3r::print_center->[1]) --use-relative-e-distances Use relative distances for extrusion in GCODE output - --no-extrusion Do not output any E value in GCODE + --extrusion-axis The axis used for extrusion; leave empty to disable extrusion + (default: $Slic3r::extrusion_axis) --z-offset Additional height in mm to add to vertical coordinates (+/-, default: $Slic3r::z_offset) --gcode-arcs Use G2/G3 commands for native arcs (experimental, not supported