New --start-gcode and --end-gcode options. #12

degen-loop-screen
Alessandro Ranellucci 2011-10-14 16:24:55 +02:00
parent f7335b6d1e
commit 2d784fac9b
5 changed files with 63 additions and 12 deletions

View File

@ -46,12 +46,12 @@ Slic3r current features are:
* center print around bed center point;
* multiple solid layers near horizontal external surfaces;
* ability to scale, rotate and multiply input object;
* customizable initial and final GCODE (using command line only);
* use different speed for bottom layer and perimeters.
Roadmap includes the following goals:
* output some statistics;
* allow the user to customize initial and final GCODE commands;
* support material for internal perimeters;
* cool;
* other fill patterns.
@ -83,10 +83,9 @@ The author is Alessandro Ranellucci (me).
--save <file> Save configuration to the specified file
--load <file> Load configuration from the specified file
-o, --output File to output gcode to (default: <inputfile>.gcode)
Printer options:
--nozzle-diameter Diameter of nozzle in mm (default: 0.55)
--nozzle-diameter Diameter of nozzle in mm (default: 0.5)
--print-center Coordinates of the point to center the print around
(default: 100,100)
--use-relative-e-distances
@ -98,7 +97,7 @@ The author is Alessandro Ranellucci (me).
--filament-diameter Diameter of your raw filament (default: 3)
--filament-packing-density
Ratio of the extruded volume over volume pushed
into the extruder (default: 0.85)
into the extruder (default: 1)
--temperature Extrusion temperature (default: 200)
Speed options:
@ -112,6 +111,9 @@ The author is Alessandro Ranellucci (me).
Accuracy options:
--layer-height Layer height in mm (default: 0.4)
--high-res-perimeters
Print perimeters at half layer height to get surface accuracy
(default: disabled)
Print options:
--perimeters Number of perimeters/horizontal skins (range: 1+,
@ -120,6 +122,11 @@ The author is Alessandro Ranellucci (me).
(range: 1+, default: 3)
--fill-density Infill density (range: 0-1, default: 0.4)
--fill-angle Infill angle in degrees (range: 0-90, default: 0)
--start-gcode Load initial gcode from the supplied file. This will overwrite
the default command (home all axes [G28]).
--end-gcode Load final gcode from the supplied file. This will overwrite
the default commands (turn off temperature [M104 S0],
home X axis [G28 X], disable motors [M84]).
Retraction options:
--retract-length Length of retraction in mm when pausing extrusion
@ -129,7 +136,7 @@ The author is Alessandro Ranellucci (me).
Additional amount of filament in mm to push after
compensating retraction (default: 0)
--retract-before-travel
Only retract before travel moves of this length (default: 1)
Only retract before travel moves of this length (default: 2)
Skirt options:
--skirts Number of skirts to draw (default: 1)
@ -143,3 +150,4 @@ The author is Alessandro Ranellucci (me).
--multiply-y Number of items along Y axis (1+, default: 1)
--multiply-distance Distance in mm between copies (default: 6)

View File

@ -38,6 +38,7 @@ our $z_offset = 0;
# filament options
our $filament_diameter = 3; # mm
our $filament_packing_density = 1;
our $temperature = 200;
# speed options
our $print_feed_rate = 60; # mm/sec
@ -59,7 +60,12 @@ our $bridge_overlap = 3; # mm
our $fill_type = 'rectilinear';
our $fill_density = 0.4; # 1 = 100%
our $fill_angle = 0;
our $temperature = 200;
our $start_gcode = "G28 ; home all axes";
our $end_gcode = <<"END";
M104 S0 ; turn off temperature
G28 X0 ; home X axis
M84 ; disable motors
END
# retraction options
our $retract_length = 1; # mm

View File

@ -86,6 +86,18 @@ our $Options = {
label => 'Fill angle (°)',
type => 'i',
},
'start_gcode' => {
label => 'Start GCODE',
type => 's',
serialize => sub { join '\n', split /\R+/, $_[0] },
deserialize => sub { join "\n", split /\\n/, $_[0] },
},
'end_gcode' => {
label => 'End GCODE',
type => 's',
serialize => sub { join '\n', split /\R+/, $_[0] },
deserialize => sub { join "\n", split /\\n/, $_[0] },
},
# retraction options
'retract_length' => {
@ -179,6 +191,25 @@ sub load {
close $fh;
}
sub validate_cli {
my $class = shift;
my ($opt) = @_;
for (qw(start end)) {
if (defined $opt->{$_."_gcode"}) {
if ($opt->{$_."_gcode"} eq "") {
set($_."_gcode", "");
} else {
die "Invalid value for --${_}-gcode: file does not exist"
if !-e $opt->{$_."_gcode"};
open my $fh, "<", $opt->{$_."_gcode"};
set($_."_gcode", do { local $/; <$fh> });
close $fh;
}
}
}
}
sub validate {
my $class = shift;

View File

@ -325,9 +325,8 @@ sub export_gcode {
or die "Failed to open $file for writing\n";
# write start commands to file
# TODO: this must be customizable by user
print $fh "G28 ; home all axes\n";
printf $fh "M104 S%d ; wait for temperature to be reached\n", $Slic3r::temperature;
print $fh "$Slic3r::start_gcode\n";
print $fh "G90 ; use absolute coordinates\n";
print $fh "G21 ; set units to millimeters\n";
if ($Slic3r::use_relative_e_distances) {
@ -375,10 +374,7 @@ sub export_gcode {
}
# write end commands to file
# TODO: this must be customizable by user
print $fh "M104 S0 ; turn off temperature\n";
print $fh "G28 X0 ; home X axis\n";
print $fh "M84 ; disable motors\n";
print $fh "$Slic3r::end_gcode\n";
# close our gcode file
close $fh;

View File

@ -49,6 +49,8 @@ GetOptions(
'fill-type=s' => \$Slic3r::fill_type,
'fill-density=f' => \$Slic3r::fill_density,
'fill-angle=i' => \$Slic3r::fill_angle,
'start-gcode=s' => \$opt{start_gcode},
'end-gcode=s' => \$opt{end_gcode},
# retraction options
'retract-length=f' => \$Slic3r::retract_length,
@ -74,6 +76,9 @@ if ($opt{load}) {
Slic3r::Config->load($opt{load});
}
# validate command line options
Slic3r::Config->validate_cli(\%opt);
# validate configuration
Slic3r::Config->validate;
@ -153,6 +158,11 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
(range: 1+, default: $Slic3r::solid_layers)
--fill-density Infill density (range: 0-1, default: $Slic3r::fill_density)
--fill-angle Infill angle in degrees (range: 0-90, default: $Slic3r::fill_angle)
--start-gcode Load initial gcode from the supplied file. This will overwrite
the default command (home all axes [G28]).
--end-gcode Load final gcode from the supplied file. This will overwrite
the default commands (turn off temperature [M104 S0],
home X axis [G28 X], disable motors [M84]).
Retraction options:
--retract-length Length of retraction in mm when pausing extrusion