New --gcode-flavor option. extrusion_axis, use_relative_e_distances options hidden and implied. #158

This commit is contained in:
Alessandro Ranellucci 2012-02-20 11:44:30 +01:00
parent 23156f0abe
commit 615bcb27dd
6 changed files with 28 additions and 17 deletions

View File

@ -97,12 +97,10 @@ The author is Alessandro Ranellucci (me).
--nozzle-diameter Diameter of nozzle in mm (default: 0.5)
--print-center Coordinates in mm of the point to center the print around
(default: 100,100)
--use-relative-e-distances
Use relative distances for extrusion in GCODE output
--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-flavor The type of G-code to generate (reprap/teacup/makerbot/mach3/no-extrusion,
default: reprap)
--gcode-arcs Use G2/G3 commands for native arcs (experimental, not supported
by all firmwares)
--g0 Use G0 commands for retraction (experimental, not supported by all

View File

@ -48,9 +48,10 @@ our $output_filename_format = '[input_filename_base].gcode';
# printer options
our $nozzle_diameter = 0.5;
our $print_center = [100,100]; # object will be centered around this point
our $z_offset = 0;
our $gcode_flavor = 'reprap';
our $use_relative_e_distances = 0;
our $extrusion_axis = 'E';
our $z_offset = 0;
our $gcode_arcs = 0;
our $g0 = 0;
our $gcode_comments = 0;

View File

@ -40,6 +40,13 @@ our $Options = {
serialize => sub { join ',', @{$_[0]} },
deserialize => sub { [ split /,/, $_[0] ] },
},
'gcode_flavor' => {
label => 'G-code flavor',
cli => 'gcode-flavor=s',
type => 'select',
values => [qw(reprap teacup makerbot mach3 no-extrusion)],
labels => ['RepRap (Marlin/Sprinter)', 'Teacup', 'MakerBot', 'Mach3/EMC', 'No extrusion'],
},
'use_relative_e_distances' => {
label => 'Use relative E distances',
cli => 'use-relative-e-distances',
@ -520,6 +527,9 @@ sub validate {
die "Invalid value for --bridge-flow-ratio\n"
if $Slic3r::bridge_flow_ratio <= 0;
# G-code flavors
$Slic3r::extrusion_axis = 'A' if $Slic3r::gcode_flavor eq 'mach3';
# legacy with existing config files
$Slic3r::small_perimeter_speed ||= $Slic3r::perimeter_speed;
$Slic3r::bridge_speed ||= $Slic3r::infill_speed;

View File

@ -21,7 +21,7 @@ sub new {
my %panels = (
printer => {
title => 'Printer',
options => [qw(nozzle_diameter print_center z_offset use_relative_e_distances extrusion_axis g0)],
options => [qw(nozzle_diameter print_center z_offset gcode_flavor g0)],
},
filament => {
title => 'Filament',

View File

@ -546,17 +546,21 @@ sub export_gcode {
print $fh "\n";
# write start commands to file
printf $fh "M104 S%d ; set temperature\n", $Slic3r::temperature if $Slic3r::temperature;
printf $fh "M104 %s%d ; set temperature\n",
($Slic3r::gcode_flavor eq 'mach3' ? 'P' : 'S'), $Slic3r::temperature
if $Slic3r::temperature;
print $fh "$Slic3r::start_gcode\n";
printf $fh "M109 S%d ; wait for temperature to be reached\n", $Slic3r::temperature if $Slic3r::temperature;
printf $fh "M109 %s%d ; wait for temperature to be reached\n",
($Slic3r::gcode_flavor eq 'mach3' ? 'P' : 'S'), $Slic3r::temperature
if $Slic3r::temperature && $Slic3r::gcode_flavor ne 'makerbot';
print $fh "G90 ; use absolute coordinates\n";
print $fh "G21 ; set units to millimeters\n";
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 {
if ($Slic3r::gcode_flavor =~ /^(?:reprap|teacup|makerbot)$/) {
printf $fh "G92 %s0 ; reset extrusion distance\n", $Slic3r::extrusion_axis;
if (!$Slic3r::use_relative_e_distances && $Slic3r::gcode_flavor =~ /^(?:reprap|makerbot)$/) {
print $fh "M82 ; use absolute distances for extrusion\n";
}
}
# calculate X,Y shift to center print around specified origin
my @shift = (

View File

@ -113,12 +113,10 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
--nozzle-diameter Diameter of nozzle in mm (default: $Slic3r::nozzle_diameter)
--print-center Coordinates in mm of the point to center the print around
(default: $Slic3r::print_center->[0],$Slic3r::print_center->[1])
--use-relative-e-distances
Use relative distances for extrusion in GCODE output
--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-flavor The type of G-code to generate (reprap/teacup/makerbot/mach3/no-extrusion,
default: $Slic3r::gcode_flavor)
--gcode-arcs Use G2/G3 commands for native arcs (experimental, not supported
by all firmwares)
--g0 Use G0 commands for retraction (experimental, not supported by all