Accept both relative and absolute extrusion width values. #151

degen-loop-screen
Alessandro Ranellucci 2012-06-06 15:23:34 +02:00
parent 2e3c8241e4
commit aedb6cc35f
6 changed files with 24 additions and 17 deletions

View File

@ -211,9 +211,8 @@ The author is Alessandro Ranellucci.
--notes Notes to be added as comments to the output file
Flow options (advanced):
--extrusion-width-ratio
Calculate the extrusion width as the layer height multiplied by
this value (> 0, default: calculated automatically)
--extrusion-width Set extrusion width manually; it accepts either an absolute value in mm
(like 0.65) or a percentage over layer height (like 200%)
--bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: 1)

View File

@ -99,7 +99,7 @@ our $first_layer_height_ratio = 1;
our $infill_every_layers = 1;
# flow options
our $extrusion_width_ratio = 0;
our $extrusion_width = 0;
our $bridge_flow_ratio = 1;
our $overlap_factor = 0.5;
our $flow_width;

View File

@ -198,9 +198,9 @@ our $Options = {
},
# flow options
'extrusion_width_ratio' => {
label => 'Extrusion width (ratio over layer height; leave zero to calculate automatically)',
cli => 'extrusion-width-ratio=f',
'extrusion_width' => {
label => 'Extrusion width (mm or %; leave zero to calculate automatically)',
cli => 'extrusion-width=f',
type => 'f',
},
'bridge_flow_ratio' => {
@ -516,15 +516,22 @@ sub load {
next if /^$/;
next if /^\s*#/;
/^(\w+) = (.*)/ or die "Unreadable configuration file (invalid data at line $.)\n";
my $key = $1;
my ($key, $val) = ($1, $2);
# handle legacy options
next if $ignore{$key};
if ($key eq 'extrusion_width_ratio') {
$key = 'extrusion_width';
$val = $val =~ /^\d+(\.\d+)?$/ ? ($val*100) . "%" : 0;
}
if (!exists $Options->{$key}) {
$key = +(grep { $Options->{$_}{aliases} && grep $_ eq $key, @{$Options->{$_}{aliases}} }
keys %$Options)[0] or warn "Unknown option $1 at line $.\n";
keys %$Options)[0] or warn "Unknown option $key at line $.\n";
}
next unless $key;
my $opt = $Options->{$key};
set($key, $opt->{deserialize} ? $opt->{deserialize}->($2) : $2);
set($key, $opt->{deserialize} ? $opt->{deserialize}->($val) : $val);
}
close $fh;
}
@ -581,8 +588,10 @@ sub validate {
die "First layer height can't be zero or negative\n"
if ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) <= 0;
if ($Slic3r::extrusion_width_ratio) {
$Slic3r::flow_width = $Slic3r::layer_height * $Slic3r::extrusion_width_ratio;
if ($Slic3r::extrusion_width) {
$Slic3r::flow_width = $Slic3r::extrusion_width =~ /^(\d+(?:\.\d+)?)%$/
? ($Slic3r::layer_height * $1 / 100)
: $Slic3r::extrusion_width;
} else {
# here we calculate a sane default by matching the flow speed (at the nozzle)
# and the feed rate

View File

@ -70,7 +70,7 @@ sub new {
},
extrusion => {
title => 'Extrusion',
options => [qw(extrusion_width_ratio bridge_flow_ratio)],
options => [qw(extrusion_width bridge_flow_ratio)],
},
output => {
title => 'Output',

View File

@ -437,7 +437,7 @@ sub write_gcode {
print $fh "\n" if $Slic3r::notes;
for (qw(layer_height perimeters solid_layers fill_density nozzle_diameter filament_diameter
extrusion_multiplier perimeter_speed infill_speed travel_speed extrusion_width_ratio scale)) {
extrusion_multiplier perimeter_speed infill_speed travel_speed scale)) {
printf $fh "; %s = %s\n", $_, Slic3r::Config->get($_);
}
printf $fh "; single wall width = %.2fmm\n", $Slic3r::flow_width;

View File

@ -255,9 +255,8 @@ $j
--notes Notes to be added as comments to the output file
Flow options (advanced):
--extrusion-width-ratio
Calculate the extrusion width as the layer height multiplied by
this value (> 0, default: calculated automatically)
--extrusion-width Set extrusion width manually; it accepts either an absolute value in mm
(like 0.65) or a percentage over layer height (like 200%)
--bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: $Slic3r::bridge_flow_ratio)
EOF