New --retract-lift-above and --retract-lift-below options. #763 #3057

This commit is contained in:
Alessandro Ranellucci 2015-12-18 18:36:39 +01:00
parent 562efc1677
commit 8138fbf349
8 changed files with 86 additions and 4 deletions

View File

@ -279,6 +279,8 @@ The author of the Silk icon set is Mark James.
--retract-before-travel
Only retract before travel moves of this length in mm (default: 2)
--retract-lift Lift Z by the given distance in mm when retracting (default: 0)
--retract-lift-above Only lift Z when above the specified height (default: 0)
--retract-lift-below Only lift Z when below the specified height (default: 0)
--retract-layer-change
Enforce a retraction before each Z move (default: no)
--wipe Wipe the nozzle while doing a retraction (default: no)

View File

@ -1257,7 +1257,7 @@ sub _extruders_count_changed {
$self->_update;
}
sub _extruder_options { qw(nozzle_diameter extruder_offset retract_length retract_lift retract_speed retract_restart_extra retract_before_travel wipe
sub _extruder_options { qw(nozzle_diameter extruder_offset retract_length retract_lift retract_lift_above retract_lift_below retract_speed retract_restart_extra retract_before_travel wipe
retract_layer_change retract_length_toolchange retract_restart_extra_toolchange) }
sub _build_extruder_pages {
@ -1293,7 +1293,19 @@ sub _build_extruder_pages {
{
my $optgroup = $page->new_optgroup('Retraction');
$optgroup->append_single_option_line($_, $extruder_idx)
for qw(retract_length retract_lift retract_speed retract_restart_extra retract_before_travel retract_layer_change wipe);
for qw(retract_length retract_lift);
{
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Only lift Z',
);
$line->append_option($optgroup->get_option('retract_lift_above', $extruder_idx));
$line->append_option($optgroup->get_option('retract_lift_below', $extruder_idx));
$optgroup->append_line($line);
}
$optgroup->append_single_option_line($_, $extruder_idx)
for qw(retract_speed retract_restart_extra retract_before_travel retract_layer_change wipe);
}
{
my $optgroup = $page->new_optgroup('Retraction when tool is disabled (advanced settings for multi-extruder setups)');
@ -1360,6 +1372,10 @@ sub _update {
$self->get_field($_, $i)->toggle($retraction)
for qw(retract_lift retract_layer_change);
# retract lift above/below only applies if using retract lift
$self->get_field($_, $i)->toggle($retraction && $config->get_at('retract_lift', $i) > 0)
for qw(retract_lift_above retract_lift_below);
# some options only apply when not using firmware retraction
$self->get_field($_, $i)->toggle($retraction && !$config->use_firmware_retraction)
for qw(retract_speed retract_restart_extra wipe);

View File

@ -439,6 +439,8 @@ $j
--retract-before-travel
Only retract before travel moves of this length in mm (default: $config->{retract_before_travel}[0])
--retract-lift Lift Z by the given distance in mm when retracting (default: $config->{retract_lift}[0])
--retract-lift-above Only lift Z when above the specified height (default: $config->{retract_lift_above}[0])
--retract-lift-below Only lift Z when below the specified height (default: $config->{retract_lift_below}[0])
--retract-layer-change
Enforce a retraction before each Z move (default: no)
--wipe Wipe the nozzle while doing a retraction (default: no)

View File

@ -1,4 +1,4 @@
use Test::More tests => 18;
use Test::More tests => 21;
use strict;
use warnings;
@ -7,6 +7,7 @@ BEGIN {
use lib "$FindBin::Bin/../lib";
}
use List::Util qw(any);
use Slic3r;
use Slic3r::Test qw(_eq);
@ -200,4 +201,28 @@ use Slic3r::Test qw(_eq);
ok $retracted, 'retracting also when --retract-length is 0 but --use-firmware-retraction is enabled';
}
{
my $config = Slic3r::Config->new_from_defaults;
$config->set('start_gcode', '');
$config->set('retract_lift', [3]);
$config->set('retract_lift_above', [5]);
$config->set('retract_lift_below', [15]);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
my @lifted_at = ();
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
my ($self, $cmd, $args, $info) = @_;
if ($cmd eq 'G1' && $info->{dist_Z} < 0) {
push @lifted_at, $info->{new_Z};
}
});
ok !!@lifted_at, 'lift takes place';
ok !(any { $_ < $config->get_at('retract_lift_above', 0) } @lifted_at),
'Z is not lifted below the configured value';
ok !(any { $_ > $config->get_at('retract_lift_below', 0) } @lifted_at),
'Z is not lifted above the configured value';
}
__END__

View File

@ -495,7 +495,14 @@ GCodeWriter::unretract()
std::string
GCodeWriter::lift()
{
double target_lift = this->config.retract_lift.get_at(0);
// check whether the above/below conditions are met
double target_lift = 0;
{
double above = this->config.retract_lift_above.get_at(0);
double below = this->config.retract_lift_below.get_at(0);
if (this->_pos.z >= above && this->_pos.z <= below && below > 0)
target_lift = this->config.retract_lift.get_at(0);
}
if (this->_lifted == 0 && target_lift > 0) {
this->_lifted = target_lift;
return this->_travel_to_z(this->_pos.z + target_lift, "lift Z");

View File

@ -218,6 +218,8 @@ Print::invalidate_state_by_config_options(const std::vector<t_config_option_key>
|| *opt_key == "retract_length"
|| *opt_key == "retract_length_toolchange"
|| *opt_key == "retract_lift"
|| *opt_key == "retract_lift_above"
|| *opt_key == "retract_lift_below"
|| *opt_key == "retract_restart_extra"
|| *opt_key == "retract_restart_extra_toolchange"
|| *opt_key == "retract_speed"

View File

@ -818,6 +818,30 @@ PrintConfigDef::PrintConfigDef()
def->default_value = opt;
}
def = this->add("retract_lift_above", coFloats);
def->label = "Above Z";
def->full_label = "Only lift Z above";
def->tooltip = "If you set this to a positive value, Z lift will only take place above the specified absolute Z. You can tune this setting for skipping lift on the first layers.";
def->sidetext = "mm";
def->cli = "retract-lift-above=f@";
{
ConfigOptionFloats* opt = new ConfigOptionFloats();
opt->values.push_back(0);
def->default_value = opt;
}
def = this->add("retract_lift_below", coFloats);
def->label = "Below Z";
def->full_label = "Only lift Z below";
def->tooltip = "If you set this to a positive value, Z lift will only take place below the specified absolute Z. You can tune this setting for limiting lift to the first layers.";
def->sidetext = "mm";
def->cli = "retract-lift-below=f@";
{
ConfigOptionFloats* opt = new ConfigOptionFloats();
opt->values.push_back(0);
def->default_value = opt;
}
def = this->add("retract_restart_extra", coFloats);
def->label = "Extra length on restart";
def->tooltip = "When the retraction is compensated after the travel move, the extruder will push this additional amount of filament. This setting is rarely needed.";

View File

@ -254,6 +254,8 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOptionFloats retract_length;
ConfigOptionFloats retract_length_toolchange;
ConfigOptionFloats retract_lift;
ConfigOptionFloats retract_lift_above;
ConfigOptionFloats retract_lift_below;
ConfigOptionFloats retract_restart_extra;
ConfigOptionFloats retract_restart_extra_toolchange;
ConfigOptionFloats retract_speed;
@ -283,6 +285,8 @@ class GCodeConfig : public virtual StaticPrintConfig
OPT_PTR(retract_length);
OPT_PTR(retract_length_toolchange);
OPT_PTR(retract_lift);
OPT_PTR(retract_lift_above);
OPT_PTR(retract_lift_below);
OPT_PTR(retract_restart_extra);
OPT_PTR(retract_restart_extra_toolchange);
OPT_PTR(retract_speed);