From 91ffb7442991cdee9cf28c9108c517a1f8122dcf Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 6 Jun 2012 15:43:54 +0200 Subject: [PATCH] Accept either absolute or relative values for --bottom-layer-speed. #151 --- README.markdown | 5 ++--- lib/Slic3r.pm | 2 +- lib/Slic3r/Config.pm | 6 +++--- lib/Slic3r/Extruder.pm | 21 ++++++++++++++------- lib/Slic3r/GUI/SkeinPanel.pm | 2 +- slic3r.pl | 5 ++--- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/README.markdown b/README.markdown index 5385e1122..3662860a2 100644 --- a/README.markdown +++ b/README.markdown @@ -131,9 +131,8 @@ The author is Alessandro Ranellucci. --infill-speed Speed of print moves in mm/s (default: 60) --solid-infill-speed Speed of print moves for solid surfaces in mm/s (default: 60) --bridge-speed Speed of bridge print moves in mm/s (default: 60) - --bottom-layer-speed-ratio - Factor to increase/decrease speeds on bottom - layer by (default: 0.3) + --bottom-layer-speed Speed of print moves for bottom layer, expressed either as an absolute + value or as a percentage over normal speeds (default: 30%) Accuracy options: --layer-height Layer height in mm (default: 0.4) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 8839fb280..d5b32dc60 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -83,7 +83,7 @@ our $small_perimeter_speed = 30; # mm/s our $infill_speed = 60; # mm/s our $solid_infill_speed = 60; # mm/s our $bridge_speed = 60; # mm/s -our $bottom_layer_speed_ratio = 0.3; +our $bottom_layer_speed = '30%'; # mm/s or % # acceleration options our $acceleration = 0; diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 25aa3b8f3..fbc3aa222 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -157,9 +157,9 @@ our $Options = { type => 'f', aliases => [qw(bridge_feed_rate)], }, - 'bottom_layer_speed_ratio' => { - label => 'Bottom layer speed ratio', - cli => 'bottom-layer-speed-ratio=f', + 'bottom_layer_speed' => { + label => 'Bottom layer speed (mm/s or %)', + cli => 'bottom-layer-speed=f', type => 'f', }, diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index d120a7401..78acd29ff 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -182,7 +182,11 @@ sub extrude_path { if ($Slic3r::cooling) { my $path_time = unscale($path_length) / $self->speeds->{$self->last_speed} * 60; - $path_time /= $Slic3r::bottom_layer_speed_ratio if $self->layer->id == 0; + if ($self->layer->id == 0) { + $path_time = $Slic3r::bottom_layer_speed =~ /^(\d+(?:\.\d+)?)%$/ + ? $path_time / ($1/100) + : unscale($path_length) / $Slic3r::bottom_layer_speed * 60; + } $self->elapsed_time($self->elapsed_time + $path_time); } @@ -318,11 +322,6 @@ sub _Gx { my ($gcode, $e, $comment) = @_; my $dec = $self->dec; - # apply the speed reduction for print moves on bottom layer - my $speed_multiplier = $e && $self->layer->id == 0 && $comment !~ /retract/ - ? $Slic3r::bottom_layer_speed_ratio - : 1; - # determine speed my $speed = ($e ? $self->speed : 'travel'); @@ -335,7 +334,15 @@ sub _Gx { } elsif ($self->last_speed eq 'bridge') { $append_bridge_off = 1; } - $gcode .= sprintf " F%.${dec}f", $self->speeds->{$speed} * $speed_multiplier; + + # apply the speed reduction for print moves on bottom layer + my $speed_f = $self->speeds->{$speed}; + if ($e && $self->layer->id == 0 && $comment !~ /retract/) { + $speed_f = $Slic3r::bottom_layer_speed =~ /^(\d+(?:\.\d+)?)%$/ + ? ($speed_f * $1/100) + : $Slic3r::bottom_layer_speed; + } + $gcode .= sprintf " F%.${dec}f", $speed_f; $self->last_speed($speed); } diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 8e0c9887a..65c52732f 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -36,7 +36,7 @@ sub new { }, speed => { title => 'Other speed settings', - options => [qw(travel_speed bottom_layer_speed_ratio)], + options => [qw(travel_speed bottom_layer_speed)], }, accuracy => { title => 'Accuracy', diff --git a/slic3r.pl b/slic3r.pl index ce45e66c3..a1540ff82 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -175,9 +175,8 @@ $j --infill-speed Speed of print moves in mm/s (default: $Slic3r::infill_speed) --solid-infill-speed Speed of print moves for solid surfaces in mm/s (default: $Slic3r::solid_infill_speed) --bridge-speed Speed of bridge print moves in mm/s (default: $Slic3r::bridge_speed) - --bottom-layer-speed-ratio - Factor to increase/decrease speeds on bottom - layer by (default: $Slic3r::bottom_layer_speed_ratio) + --bottom-layer-speed Speed of print moves for bottom layer, expressed either as an absolute + value or as a percentage over normal speeds (default: $Slic3r::bottom_layer_speed) Accuracy options: --layer-height Layer height in mm (default: $Slic3r::layer_height)