Options on command line now override config. Also, "feed rate" was renamed to "speed" everywhere. #77
This commit is contained in:
parent
2a02d26ca5
commit
e99c9f9e5f
@ -106,11 +106,11 @@ The author is Alessandro Ranellucci (me).
|
||||
--temperature Extrusion temperature, set 0 to disable (default: 200)
|
||||
|
||||
Speed options:
|
||||
--print-feed-rate Speed of print moves in mm/sec (default: 60)
|
||||
--travel-feed-rate Speed of non-print moves in mm/sec (default: 130)
|
||||
--perimeter-feed-rate
|
||||
Speed of print moves for perimeters in mm/sec (default: 60)
|
||||
--bridge-feed-rate Speed of bridge print moves in mm/sec (default: 60)
|
||||
--travel-speed Speed of non-print moves in mm/sec (default: 130)
|
||||
--perimeter-speed Speed of print moves for perimeters in mm/sec (default: 30)
|
||||
--infill-speed Speed of print moves in mm/sec (default: 60)
|
||||
--solid-infill-speed Speed of print moves for solid surfaces in mm/sec (default: 60)
|
||||
--bridge-speed Speed of bridge print moves in mm/sec (default: 60)
|
||||
--bottom-layer-speed-ratio
|
||||
Factor to increase/decrease speeds on bottom
|
||||
layer by (default: 0.3)
|
||||
|
@ -48,11 +48,11 @@ our $extrusion_multiplier = 1;
|
||||
our $temperature = 200;
|
||||
|
||||
# speed options
|
||||
our $travel_feed_rate = 130; # mm/sec
|
||||
our $perimeter_feed_rate = 30; # mm/sec
|
||||
our $infill_feed_rate = 60; # mm/sec
|
||||
our $solid_infill_feed_rate = 60; # mm/sec
|
||||
our $bridge_feed_rate = 60; # mm/sec
|
||||
our $travel_speed = 130; # mm/sec
|
||||
our $perimeter_speed = 30; # mm/sec
|
||||
our $infill_speed = 60; # mm/sec
|
||||
our $solid_infill_speed = 60; # mm/sec
|
||||
our $bridge_speed = 60; # mm/sec
|
||||
our $bottom_layer_speed_ratio = 0.3;
|
||||
|
||||
# accuracy options
|
||||
|
@ -10,119 +10,158 @@ our $Options = {
|
||||
# printer options
|
||||
'nozzle_diameter' => {
|
||||
label => 'Nozzle diameter',
|
||||
cli => 'nozzle-diameter=f',
|
||||
type => 'f',
|
||||
},
|
||||
'print_center' => {
|
||||
label => 'Print center',
|
||||
cli => 'print-center=s',
|
||||
type => 'point',
|
||||
serialize => sub { join ',', @{$_[0]} },
|
||||
deserialize => sub { [ split /,/, $_[0] ] },
|
||||
},
|
||||
'use_relative_e_distances' => {
|
||||
label => 'Use relative E distances',
|
||||
cli => 'use-relative-e-distances',
|
||||
type => 'bool',
|
||||
},
|
||||
'no_extrusion' => {
|
||||
label => 'No extrusion',
|
||||
cli => 'no-extrusion',
|
||||
type => 'bool',
|
||||
},
|
||||
'z_offset' => {
|
||||
label => 'Z offset',
|
||||
cli => 'z-offset=f',
|
||||
type => 'f',
|
||||
},
|
||||
'gcode_arcs' => {
|
||||
label => 'Use native GCODE arcs',
|
||||
cli => 'gcode-arcs',
|
||||
type => 'bool',
|
||||
},
|
||||
'g0' => {
|
||||
label => 'Use g0 for travel moves',
|
||||
cli => 'g0',
|
||||
type => 'bool',
|
||||
},
|
||||
|
||||
# filament options
|
||||
'filament_diameter' => {
|
||||
label => 'Diameter (mm)',
|
||||
cli => 'filament-diameter=f',
|
||||
type => 'f',
|
||||
},
|
||||
'extrusion_multiplier' => {
|
||||
label => 'Extrusion multiplier',
|
||||
cli => 'extrusion-multiplier=f',
|
||||
type => 'f',
|
||||
aliases => [qw(filament_packing_density)],
|
||||
},
|
||||
'temperature' => {
|
||||
label => 'Temperature (°C)',
|
||||
cli => 'temperature=i',
|
||||
type => 'i',
|
||||
},
|
||||
|
||||
# speed options
|
||||
'travel_feed_rate' => {
|
||||
'travel_speed' => {
|
||||
label => 'Travel (mm/s)',
|
||||
cli => 'travel-speed=i',
|
||||
type => 'f',
|
||||
aliases => [qw(travel_feed_rate)],
|
||||
},
|
||||
'perimeter_feed_rate' => {
|
||||
'perimeter_speed' => {
|
||||
label => 'Perimeters (mm/s)',
|
||||
cli => 'perimeter-speed=i',
|
||||
type => 'f',
|
||||
aliases => [qw(perimeter_feed_rate)],
|
||||
},
|
||||
'infill_feed_rate' => {
|
||||
'infill_speed' => {
|
||||
label => 'Infill (mm/s)',
|
||||
cli => 'infill-speed=i',
|
||||
type => 'f',
|
||||
aliases => [qw(print_feed_rate)],
|
||||
aliases => [qw(print_feed_rate infill_feed_rate)],
|
||||
},
|
||||
'solid_infill_feed_rate' => {
|
||||
'solid_infill_speed' => {
|
||||
label => 'Solid infill (mm/s)',
|
||||
cli => 'solid-infill-speed=i',
|
||||
type => 'f',
|
||||
aliases => [qw(solid_infill_feed_rate)],
|
||||
},
|
||||
'bridge_feed_rate' => {
|
||||
'bridge_speed' => {
|
||||
label => 'Bridges (mm/s)',
|
||||
cli => 'bridge-speed=i',
|
||||
type => 'f',
|
||||
aliases => [qw(bridge_feed_rate)],
|
||||
},
|
||||
'bottom_layer_speed_ratio' => {
|
||||
label => 'Bottom layer speed ratio',
|
||||
cli => 'bottom-layer-speed-ratio=f',
|
||||
type => 'f',
|
||||
},
|
||||
|
||||
# accuracy options
|
||||
'layer_height' => {
|
||||
label => 'Layer height (mm)',
|
||||
cli => 'layer-height=f',
|
||||
type => 'f',
|
||||
},
|
||||
'extrusion_width_ratio' => {
|
||||
label => 'Extrusion width (ratio over layer height; leave zero to calculate automatically)',
|
||||
cli => 'extrusion-width-ratio=f',
|
||||
type => 'f',
|
||||
},
|
||||
'first_layer_height_ratio' => {
|
||||
label => 'First layer height ratio',
|
||||
cli => 'first-layer-height-ratio=f',
|
||||
type => 'f',
|
||||
},
|
||||
'infill_every_layers' => {
|
||||
label => 'Infill every N layers',
|
||||
cli => 'infill-every-layers=i',
|
||||
type => 'i',
|
||||
},
|
||||
|
||||
# print options
|
||||
'perimeters' => {
|
||||
label => 'Perimeters',
|
||||
cli => 'perimeters=i',
|
||||
type => 'i',
|
||||
aliases => [qw(perimeter_offsets)],
|
||||
},
|
||||
'solid_layers' => {
|
||||
label => 'Solid layers',
|
||||
cli => 'solid-layers=i',
|
||||
type => 'i',
|
||||
},
|
||||
'fill_pattern' => {
|
||||
label => 'Fill pattern',
|
||||
cli => 'fill-pattern=s',
|
||||
type => 'select',
|
||||
values => [qw(rectilinear line concentric hilbertcurve archimedeanchords octagramspiral)],
|
||||
labels => [qw(rectilinear line concentric), 'hilbertcurve (slow)', 'archimedeanchords (slow)', 'octagramspiral (slow)'],
|
||||
},
|
||||
'solid_fill_pattern' => {
|
||||
label => 'Solid fill pattern',
|
||||
cli => 'solid-fill-pattern=s',
|
||||
type => 'select',
|
||||
values => [qw(rectilinear concentric hilbertcurve archimedeanchords octagramspiral)],
|
||||
labels => [qw(rectilinear concentric), 'hilbertcurve (slow)', 'archimedeanchords (slow)', 'octagramspiral (slow)'],
|
||||
},
|
||||
'fill_density' => {
|
||||
label => 'Fill density',
|
||||
cli => 'fill-density=f',
|
||||
type => 'f',
|
||||
},
|
||||
'fill_angle' => {
|
||||
label => 'Fill angle (°)',
|
||||
cli => 'fill-angle=i',
|
||||
type => 'i',
|
||||
},
|
||||
'start_gcode' => {
|
||||
label => 'Start GCODE',
|
||||
cli => 'start-gcode=s',
|
||||
type => 's',
|
||||
multiline => 1,
|
||||
width => 350,
|
||||
@ -132,6 +171,7 @@ our $Options = {
|
||||
},
|
||||
'end_gcode' => {
|
||||
label => 'End GCODE',
|
||||
cli => 'end-gcode=s',
|
||||
type => 's',
|
||||
multiline => 1,
|
||||
width => 350,
|
||||
@ -143,60 +183,73 @@ our $Options = {
|
||||
# retraction options
|
||||
'retract_length' => {
|
||||
label => 'Length (mm)',
|
||||
cli => 'retract-length=f',
|
||||
type => 'f',
|
||||
},
|
||||
'retract_speed' => {
|
||||
label => 'Speed (mm/s)',
|
||||
cli => 'retract-speed=i',
|
||||
type => 'i',
|
||||
},
|
||||
'retract_restart_extra' => {
|
||||
label => 'Extra length on restart (mm)',
|
||||
cli => 'retract-restart-extra=f',
|
||||
type => 'f',
|
||||
},
|
||||
'retract_before_travel' => {
|
||||
label => 'Minimum travel after retraction (mm)',
|
||||
cli => 'retract-before-travel=f',
|
||||
type => 'f',
|
||||
},
|
||||
'retract_lift' => {
|
||||
label => 'Lift Z (mm)',
|
||||
cli => 'retract-lift=f',
|
||||
type => 'f',
|
||||
},
|
||||
|
||||
# skirt options
|
||||
'skirts' => {
|
||||
label => 'Loops',
|
||||
cli => 'skirts=i',
|
||||
type => 'i',
|
||||
},
|
||||
'skirt_distance' => {
|
||||
label => 'Distance from object (mm)',
|
||||
cli => 'skirt-distance=i',
|
||||
type => 'i',
|
||||
},
|
||||
'skirt_height' => {
|
||||
label => 'Skirt height (layers)',
|
||||
cli => 'skirt-height=i',
|
||||
type => 'i',
|
||||
},
|
||||
|
||||
# transform options
|
||||
'scale' => {
|
||||
label => 'Scale',
|
||||
cli => 'scale=f',
|
||||
type => 'f',
|
||||
},
|
||||
'rotate' => {
|
||||
label => 'Rotate (°)',
|
||||
cli => 'rotate=i',
|
||||
type => 'i',
|
||||
},
|
||||
'duplicate_x' => {
|
||||
label => 'Copies along X',
|
||||
cli => 'duplicate-x=i',
|
||||
type => 'i',
|
||||
aliases => [qw(multiply_x)],
|
||||
},
|
||||
'duplicate_y' => {
|
||||
label => 'Copies along Y',
|
||||
cli => 'duplicate-y=i',
|
||||
type => 'i',
|
||||
aliases => [qw(multiply_y)],
|
||||
},
|
||||
'duplicate_distance' => {
|
||||
label => 'Distance between copies',
|
||||
cli => 'duplicate-distance=i',
|
||||
type => 'i',
|
||||
aliases => [qw(multiply_distance)],
|
||||
},
|
||||
@ -260,7 +313,7 @@ sub validate_cli {
|
||||
die "Invalid value for --${_}-gcode: file does not exist"
|
||||
if !-e $opt->{$_."_gcode"};
|
||||
open my $fh, "<", $opt->{$_."_gcode"};
|
||||
set($_."_gcode", do { local $/; <$fh> });
|
||||
$opt->{$_."_gcode"} = do { local $/; <$fh> };
|
||||
close $fh;
|
||||
}
|
||||
}
|
||||
@ -361,8 +414,8 @@ sub validate {
|
||||
if $Slic3r::skirt_height < 1;
|
||||
|
||||
# legacy with existing config files
|
||||
$Slic3r::bridge_feed_rate ||= $Slic3r::infill_feed_rate;
|
||||
$Slic3r::solid_infill_feed_rate ||= $Slic3r::infill_feed_rate;
|
||||
$Slic3r::bridge_speed ||= $Slic3r::infill_speed;
|
||||
$Slic3r::solid_infill_speed ||= $Slic3r::infill_speed;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -16,25 +16,25 @@ has 'last_f' => (is => 'rw', default => sub {0});
|
||||
has 'dec' => (is => 'ro', default => sub { 3 } );
|
||||
|
||||
# calculate speeds
|
||||
has 'travel_feed_rate' => (
|
||||
has 'travel_speed' => (
|
||||
is => 'ro',
|
||||
default => sub { $Slic3r::travel_feed_rate * 60 }, # mm/min
|
||||
default => sub { $Slic3r::travel_speed * 60 }, # mm/min
|
||||
);
|
||||
has 'perimeter_feed_rate' => (
|
||||
has 'perimeter_speed' => (
|
||||
is => 'ro',
|
||||
default => sub { $Slic3r::perimeter_feed_rate * 60 }, # mm/min
|
||||
default => sub { $Slic3r::perimeter_speed * 60 }, # mm/min
|
||||
);
|
||||
has 'infill_feed_rate' => (
|
||||
has 'infill_speed' => (
|
||||
is => 'ro',
|
||||
default => sub { $Slic3r::infill_feed_rate * 60 }, # mm/min
|
||||
default => sub { $Slic3r::infill_speed * 60 }, # mm/min
|
||||
);
|
||||
has 'solid_infill_feed_rate' => (
|
||||
has 'solid_infill_speed' => (
|
||||
is => 'ro',
|
||||
default => sub { $Slic3r::solid_infill_feed_rate * 60 }, # mm/min
|
||||
default => sub { $Slic3r::solid_infill_speed * 60 }, # mm/min
|
||||
);
|
||||
has 'bridge_feed_rate' => (
|
||||
has 'bridge_speed' => (
|
||||
is => 'ro',
|
||||
default => sub { $Slic3r::bridge_feed_rate * 60 }, # mm/min
|
||||
default => sub { $Slic3r::bridge_speed * 60 }, # mm/min
|
||||
);
|
||||
has 'retract_speed' => (
|
||||
is => 'ro',
|
||||
@ -122,10 +122,10 @@ sub extrude {
|
||||
|
||||
# extrude arc or line
|
||||
$self->print_feed_rate(
|
||||
$path->role =~ /^(perimeter|skirt)$/o ? $self->perimeter_feed_rate
|
||||
: $path->role eq 'fill' ? $self->infill_feed_rate
|
||||
: $path->role eq 'solid-fill' ? $self->solid_infill_feed_rate
|
||||
: $path->role eq 'bridge' ? $self->bridge_feed_rate
|
||||
$path->role =~ /^(perimeter|skirt)$/o ? $self->perimeter_speed
|
||||
: $path->role eq 'fill' ? $self->infill_speed
|
||||
: $path->role eq 'solid-fill' ? $self->solid_infill_speed
|
||||
: $path->role eq 'bridge' ? $self->bridge_speed
|
||||
: die "Unknown role: " . $path->role
|
||||
);
|
||||
if ($path->isa('Slic3r::ExtrusionPath::Arc')) {
|
||||
@ -268,7 +268,7 @@ sub _Gx {
|
||||
: 1;
|
||||
|
||||
# determine speed
|
||||
my $speed = ($e ? $self->print_feed_rate : $self->travel_feed_rate) * $speed_multiplier;
|
||||
my $speed = ($e ? $self->print_feed_rate : $self->travel_speed) * $speed_multiplier;
|
||||
|
||||
# output speed if it's different from last one used
|
||||
# (goal: reduce gcode size)
|
||||
|
@ -25,11 +25,11 @@ sub new {
|
||||
},
|
||||
print_speed => {
|
||||
title => 'Print speed',
|
||||
options => [qw(perimeter_feed_rate infill_feed_rate solid_infill_feed_rate bridge_feed_rate)],
|
||||
options => [qw(perimeter_speed infill_speed solid_infill_speed bridge_speed)],
|
||||
},
|
||||
speed => {
|
||||
title => 'Other speed settings',
|
||||
options => [qw(travel_feed_rate bottom_layer_speed_ratio)],
|
||||
options => [qw(travel_speed bottom_layer_speed_ratio)],
|
||||
},
|
||||
accuracy => {
|
||||
title => 'Accuracy',
|
||||
|
91
slic3r.pl
91
slic3r.pl
@ -11,10 +11,12 @@ BEGIN {
|
||||
use Getopt::Long;
|
||||
use Slic3r;
|
||||
use XXX;
|
||||
|
||||
$|++;
|
||||
our %opt;
|
||||
GetOptions(
|
||||
|
||||
my %opt = ();
|
||||
my %cli_options = ();
|
||||
{
|
||||
my %options = (
|
||||
'help' => sub { usage() },
|
||||
|
||||
'debug' => \$Slic3r::debug,
|
||||
@ -23,64 +25,15 @@ GetOptions(
|
||||
|
||||
'save=s' => \$opt{save},
|
||||
'load=s' => \$opt{load},
|
||||
);
|
||||
foreach my $opt_key (keys %$Slic3r::Config::Options) {
|
||||
my $opt = $Slic3r::Config::Options->{$opt_key};
|
||||
$options{ $opt->{cli} } = \$cli_options{$opt_key}
|
||||
if $opt->{cli};
|
||||
}
|
||||
|
||||
# printer options
|
||||
'nozzle-diameter=f' => \$Slic3r::nozzle_diameter,
|
||||
'print-center=s' => \$Slic3r::print_center,
|
||||
'use-relative-e-distances' => \$Slic3r::use_relative_e_distances,
|
||||
'no-extrusion' => \$Slic3r::no_extrusion,
|
||||
'z-offset=f' => \$Slic3r::z_offset,
|
||||
'gcode-arcs' => \$Slic3r::gcode_arcs,
|
||||
'g0' => \$Slic3r::g0,
|
||||
|
||||
# filament options
|
||||
'filament-diameter=f' => \$Slic3r::filament_diameter,
|
||||
'extrusion-multiplier=f' => \$Slic3r::extrusion_multiplier,
|
||||
'temperature=i' => \$Slic3r::temperature,
|
||||
|
||||
# speed options
|
||||
'travel-feed-rate=i' => \$Slic3r::travel_feed_rate,
|
||||
'perimeter-feed-rate=i' => \$Slic3r::perimeter_feed_rate,
|
||||
'infill-feed-rate=i' => \$Slic3r::infill_feed_rate,
|
||||
'solid-infill-feed-rate=i' => \$Slic3r::solid_infill_feed_rate,
|
||||
'bridge-feed-rate=i' => \$Slic3r::bridge_feed_rate,
|
||||
'bottom-layer-speed-ratio=f' => \$Slic3r::bottom_layer_speed_ratio,
|
||||
|
||||
# accuracy options
|
||||
'layer-height=f' => \$Slic3r::layer_height,
|
||||
'extrusion-width-ratio=f' => \$Slic3r::extrusion_width_ratio,
|
||||
'first-layer-height-ratio=f' => \$Slic3r::first_layer_height_ratio,
|
||||
'infill-every-layers=i' => \$Slic3r::infill_every_layers,
|
||||
|
||||
# print options
|
||||
'perimeters=i' => \$Slic3r::perimeters,
|
||||
'solid-layers=i' => \$Slic3r::solid_layers,
|
||||
'fill-pattern=s' => \$Slic3r::fill_pattern,
|
||||
'solid-fill-pattern=s' => \$Slic3r::solid_fill_pattern,
|
||||
'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,
|
||||
'retract-speed=i' => \$Slic3r::retract_speed,
|
||||
'retract-restart-extra=f' => \$Slic3r::retract_restart_extra,
|
||||
'retract-before-travel=f' => \$Slic3r::retract_before_travel,
|
||||
'retract-lift=f' => \$Slic3r::retract_lift,
|
||||
|
||||
# skirt options
|
||||
'skirts=i' => \$Slic3r::skirts,
|
||||
'skirt-distance=i' => \$Slic3r::skirt_distance,
|
||||
'skirt-height=i' => \$Slic3r::skirt_height,
|
||||
|
||||
# transform options
|
||||
'scale=f' => \$Slic3r::scale,
|
||||
'rotate=i' => \$Slic3r::rotate,
|
||||
'duplicate-x=i' => \$Slic3r::duplicate_x,
|
||||
'duplicate-y=i' => \$Slic3r::duplicate_y,
|
||||
'duplicate-distance=i' => \$Slic3r::duplicate_distance,
|
||||
) or usage(1);
|
||||
GetOptions(%options) or usage(1);
|
||||
}
|
||||
|
||||
# load configuration
|
||||
if ($opt{load}) {
|
||||
@ -89,7 +42,11 @@ if ($opt{load}) {
|
||||
}
|
||||
|
||||
# validate command line options
|
||||
Slic3r::Config->validate_cli(\%opt);
|
||||
Slic3r::Config->validate_cli(\%cli_options);
|
||||
|
||||
# apply command line options
|
||||
Slic3r::Config->set($_ => $cli_options{$_})
|
||||
for grep defined $cli_options{$_}, keys %cli_options;
|
||||
|
||||
# validate configuration
|
||||
Slic3r::Config->validate;
|
||||
@ -155,13 +112,11 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
|
||||
--temperature Extrusion temperature, set 0 to disable (default: $Slic3r::temperature)
|
||||
|
||||
Speed options:
|
||||
--travel-feed-rate Speed of non-print moves in mm/sec (default: $Slic3r::travel_feed_rate)
|
||||
--perimeter-feed-rate
|
||||
Speed of print moves for perimeters in mm/sec (default: $Slic3r::perimeter_feed_rate)
|
||||
--infill-feed-rate Speed of print moves in mm/sec (default: $Slic3r::infill_feed_rate)
|
||||
--solid-infill-feed-rate
|
||||
Speed of print moves for solid surfaces in mm/sec (default: $Slic3r::solid_infill_feed_rate)
|
||||
--bridge-feed-rate Speed of bridge print moves in mm/sec (default: $Slic3r::bridge_feed_rate)
|
||||
--travel-speed Speed of non-print moves in mm/sec (default: $Slic3r::travel_speed)
|
||||
--perimeter-speed Speed of print moves for perimeters in mm/sec (default: $Slic3r::perimeter_speed)
|
||||
--infill-speed Speed of print moves in mm/sec (default: $Slic3r::infill_speed)
|
||||
--solid-infill-speed Speed of print moves for solid surfaces in mm/sec (default: $Slic3r::solid_infill_speed)
|
||||
--bridge-speed Speed of bridge print moves in mm/sec (default: $Slic3r::bridge_speed)
|
||||
--bottom-layer-speed-ratio
|
||||
Factor to increase/decrease speeds on bottom
|
||||
layer by (default: $Slic3r::bottom_layer_speed_ratio)
|
||||
|
Loading…
Reference in New Issue
Block a user