mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 10:51:22 +00:00
Feature: Retract amount after wipe (#11015)
Co-authored-by: Ian Bassi <ian.bassi@outlook.com>
This commit is contained in:
co-authored by
Ian Bassi
parent
3c0338f462
commit
50768e0716
@@ -177,7 +177,14 @@ double Extruder::filament_flow_ratio() const
|
||||
// Return a "retract_before_wipe" percentage as a factor clamped to <0, 1>
|
||||
double Extruder::retract_before_wipe() const
|
||||
{
|
||||
return std::min(1., std::max(0., m_config->retract_before_wipe.get_at(m_config_index) * 0.01));
|
||||
return std::clamp(m_config->retract_before_wipe.get_at(m_config_index) * 0.01, 0., 1.);
|
||||
}
|
||||
|
||||
// Orca:
|
||||
// Return a "retract_after_wipe" percentage as a factor clamped to <0, 1>
|
||||
double Extruder::retract_after_wipe() const
|
||||
{
|
||||
return std::min(std::clamp(m_config->retract_after_wipe.get_at(m_config_index) * 0.01, 0., 1.), 1. - retract_before_wipe());
|
||||
}
|
||||
|
||||
double Extruder::retraction_length() const
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
double filament_cost() const;
|
||||
double filament_flow_ratio() const;
|
||||
double retract_before_wipe() const;
|
||||
// Orca:
|
||||
double retract_after_wipe() const;
|
||||
double retraction_length() const;
|
||||
double retract_lift() const;
|
||||
int retract_speed() const;
|
||||
|
||||
+40
-21
@@ -441,22 +441,30 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
|
||||
// Declare & initialize retraction lengths
|
||||
double retraction_length_remaining = 0,
|
||||
retractionBeforeWipe = 0,
|
||||
retractionDuringWipe = 0;
|
||||
retraction_length_before_wipe = 0,
|
||||
retraction_length_during_wipe = 0,
|
||||
retraction_length_after_wipe = 0;
|
||||
|
||||
// initialise the remaining retraction amount with the full retraction amount.
|
||||
retraction_length_remaining = toolchange ? extruder->retract_length_toolchange() : extruder->retraction_length();
|
||||
// Initialise the remaining retraction amount with the full retraction amount.
|
||||
retraction_length_remaining = toolchange ?
|
||||
extruder->retract_length_toolchange() : extruder->retraction_length();
|
||||
|
||||
// nothing to retract - return early
|
||||
if(retraction_length_remaining <=EPSILON) return {0.f,0.f};
|
||||
// Nothing to retract - return early
|
||||
if (retraction_length_remaining <= EPSILON)
|
||||
return { 0.f, 0.f, 0.f };
|
||||
|
||||
// calculate retraction before wipe distance from the user setting. Keep adding to this variable any excess retraction needed
|
||||
// to be performed before the wipe.
|
||||
retractionBeforeWipe = retraction_length_remaining * extruder->retract_before_wipe();
|
||||
retraction_length_remaining -= retractionBeforeWipe; // subtract it from the remaining retraction length
|
||||
|
||||
// all of the retraction is to be done before the wipe
|
||||
if(retraction_length_remaining <=EPSILON) return {retractionBeforeWipe,0.f};
|
||||
// Calculate retraction before and after wipe distances from the user setting.
|
||||
// Keep adding to the for retraction before wipe variable any excess retraction
|
||||
// needed to be performed before the wipe.
|
||||
retraction_length_before_wipe = retraction_length_remaining * extruder->retract_before_wipe();
|
||||
retraction_length_after_wipe = retraction_length_remaining * extruder->retract_after_wipe();
|
||||
|
||||
// Subtract it from the remaining retraction length
|
||||
retraction_length_remaining -= retraction_length_before_wipe + retraction_length_after_wipe;
|
||||
|
||||
// All of the retraction is to be done before the wipe
|
||||
if (retraction_length_remaining <= EPSILON)
|
||||
return { retraction_length_before_wipe, 0., retraction_length_after_wipe };
|
||||
|
||||
// Calculate wipe speed
|
||||
// Orca: resolve the travel_speed slot via the Print-side per-layer resolver; the writer's
|
||||
@@ -471,18 +479,25 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
double wipe_path_length = std::min(wipe_path.length(), wipe_dist);
|
||||
|
||||
// Calculate the maximum retraction amount during wipe
|
||||
retractionDuringWipe = config.retraction_speed.get_at(extruder_id) * unscale_(wipe_path_length) / wipe_speed;
|
||||
// If the maximum retraction amount during wipe is too small, return 0 and retract everything prior to the wipe.
|
||||
if(retractionDuringWipe <= EPSILON) return {retractionBeforeWipe,0.f};
|
||||
retraction_length_during_wipe = config.retraction_speed.get_at(extruder_id) *
|
||||
unscale_(wipe_path_length) / wipe_speed;
|
||||
|
||||
// If the maximum retraction amount during wipe is too small,
|
||||
// disable wipe-time retraction and leave any remaining retract amount
|
||||
// to the subsequent standard retract flow.
|
||||
if (retraction_length_during_wipe <= EPSILON)
|
||||
return { retraction_length_before_wipe, 0., retraction_length_after_wipe };
|
||||
|
||||
// If the maximum retraction amount during wipe is greater than any remaining retraction length
|
||||
// return the remaining retraction length to be retracted during the wipe
|
||||
if (retractionDuringWipe - retraction_length_remaining > EPSILON) return {retractionBeforeWipe,retraction_length_remaining};
|
||||
if (retraction_length_during_wipe - retraction_length_remaining > EPSILON)
|
||||
return { retraction_length_before_wipe, retraction_length_remaining, retraction_length_after_wipe };
|
||||
|
||||
// We will always proceed with incrementing the retraction amount before wiping with the difference
|
||||
// and return the maximum allowed wipe amount to be retracted during the wipe move
|
||||
retractionBeforeWipe += retraction_length_remaining - retractionDuringWipe;
|
||||
return {retractionBeforeWipe, retractionDuringWipe};
|
||||
retraction_length_before_wipe += retraction_length_remaining - retraction_length_during_wipe;
|
||||
|
||||
return { retraction_length_before_wipe, retraction_length_during_wipe, retraction_length_after_wipe };
|
||||
}
|
||||
|
||||
std::string transform_gcode(const std::string &gcode, Vec2f pos, const Vec2f &translation, float angle)
|
||||
@@ -8507,8 +8522,12 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li
|
||||
// wipe (if it's enabled for this extruder and we have a stored wipe path and no-zero wipe distance)
|
||||
if (FILAMENT_CONFIG(wipe) && m_wipe.has_path() && scale_(FILAMENT_CONFIG(wipe_distance)) > SCALED_EPSILON) {
|
||||
Wipe::RetractionValues wipeRetractions = m_wipe.calculateWipeRetractionLengths(*this, toolchange);
|
||||
gcode += toolchange ? m_writer.retract_for_toolchange(true,wipeRetractions.retractLengthBeforeWipe) : m_writer.retract(true, wipeRetractions.retractLengthBeforeWipe);
|
||||
gcode += m_wipe.wipe(*this,wipeRetractions.retractLengthDuringWipe, toolchange, is_last_retraction);
|
||||
gcode += toolchange ? m_writer.retract_for_toolchange(true, wipeRetractions.retraction_length_before_wipe) :
|
||||
m_writer.retract(true, wipeRetractions.retraction_length_before_wipe);
|
||||
gcode += m_wipe.wipe(*this, wipeRetractions.retraction_length_during_wipe, toolchange, is_last_retraction);
|
||||
|
||||
// Orca: wipeRetractions.retraction_length_after_wipe is not being used explicitly,
|
||||
// the remaining retraction after wipe is handled by the subsequent m_writer.retract() call
|
||||
}
|
||||
|
||||
/* The parent class will decide whether we need to perform an actual retraction
|
||||
|
||||
@@ -60,15 +60,20 @@ class Wipe {
|
||||
public:
|
||||
bool enable;
|
||||
Polyline path;
|
||||
|
||||
// Orca:
|
||||
struct RetractionValues{
|
||||
double retractLengthBeforeWipe;
|
||||
double retractLengthDuringWipe;
|
||||
double retraction_length_before_wipe = 0.;
|
||||
double retraction_length_during_wipe = 0.;
|
||||
double retraction_length_after_wipe = 0.;
|
||||
};
|
||||
|
||||
Wipe() : enable(false) {}
|
||||
bool has_path() const { return !this->path.points.empty(); }
|
||||
void reset_path() { this->path = Polyline(); }
|
||||
std::string wipe(GCode &gcodegen, double length, bool toolchange = false, bool is_last = false);
|
||||
|
||||
// Orca:
|
||||
RetractionValues calculateWipeRetractionLengths(GCode& gcodegen, bool toolchange);
|
||||
};
|
||||
|
||||
|
||||
@@ -1333,8 +1333,20 @@ static std::vector<std::string> s_Preset_filament_options {/*"filament_colour",
|
||||
//exhaust fan control
|
||||
"activate_air_filtration","activate_air_filtration_during_print","activate_air_filtration_on_completion","during_print_exhaust_fan_speed","complete_print_exhaust_fan_speed",
|
||||
// Retract overrides
|
||||
"filament_retraction_length", "filament_z_hop", "filament_z_hop_types", "filament_retract_lift_above", "filament_retract_lift_below", "filament_retract_lift_enforce", "filament_retraction_speed", "filament_deretraction_speed", "filament_retract_restart_extra", "filament_retraction_minimum_travel",
|
||||
"filament_retract_when_changing_layer", "filament_wipe", "filament_retract_before_wipe",
|
||||
"filament_deretraction_speed",
|
||||
"filament_retract_after_wipe", // Orca
|
||||
"filament_retract_before_wipe",
|
||||
"filament_retract_lift_above",
|
||||
"filament_retract_lift_below",
|
||||
"filament_retract_lift_enforce",
|
||||
"filament_retract_restart_extra",
|
||||
"filament_retract_when_changing_layer",
|
||||
"filament_retraction_length",
|
||||
"filament_retraction_minimum_travel",
|
||||
"filament_retraction_speed",
|
||||
"filament_wipe",
|
||||
"filament_z_hop",
|
||||
"filament_z_hop_types",
|
||||
// Profile compatibility
|
||||
"filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits",
|
||||
//BBS
|
||||
|
||||
@@ -177,6 +177,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
||||
"filename_format",
|
||||
"retraction_minimum_travel",
|
||||
"retract_before_wipe",
|
||||
// Orca:
|
||||
"retract_after_wipe",
|
||||
"retract_when_changing_layer",
|
||||
"retraction_length",
|
||||
"retract_length_toolchange",
|
||||
|
||||
@@ -79,6 +79,9 @@ const std::vector<std::string> filament_extruder_override_keys = {
|
||||
"filament_wipe",
|
||||
// percents
|
||||
"filament_retract_before_wipe",
|
||||
// Orca
|
||||
"filament_retract_after_wipe",
|
||||
// BBS
|
||||
"filament_long_retractions_when_cut",
|
||||
"filament_retraction_distances_when_cut"
|
||||
};
|
||||
@@ -5546,6 +5549,15 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionPercents { 100 });
|
||||
|
||||
// Orca:
|
||||
def = this->add("retract_after_wipe", coPercents);
|
||||
def->label = L("Retract amount after wipe");
|
||||
def->tooltip = L("The length of fast retraction after wipe, relative to retraction length.\n"
|
||||
"The value will be clamped by 100% minus the retract amount before the wipe value.");
|
||||
def->sidetext = "%";
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionPercents { 0 });
|
||||
|
||||
def = this->add("retract_when_changing_layer", coBools);
|
||||
def->label = L("Retract on layer change");
|
||||
def->tooltip = L("This forces a retraction on layer changes.");
|
||||
@@ -7963,17 +7975,44 @@ void PrintConfigDef::init_extruder_option_keys()
|
||||
{
|
||||
// ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings
|
||||
m_extruder_option_keys = {
|
||||
"extruder_type", "nozzle_diameter", "default_nozzle_volume_type", "min_layer_height", "max_layer_height", "extruder_offset",
|
||||
"extruder_printable_height", "nozzle_volume", "nozzle_type", "nozzle_flush_dataset",
|
||||
"retraction_length", "z_hop", "z_hop_types", "travel_slope", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed",
|
||||
"retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance",
|
||||
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour",
|
||||
"default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut"
|
||||
"default_filament_profile",
|
||||
"default_nozzle_volume_type",
|
||||
"deretraction_speed",
|
||||
"extruder_colour",
|
||||
"extruder_offset",
|
||||
"extruder_printable_height",
|
||||
"extruder_type",
|
||||
"long_retractions_when_cut",
|
||||
"max_layer_height",
|
||||
"min_layer_height",
|
||||
"nozzle_diameter",
|
||||
"nozzle_flush_dataset",
|
||||
"nozzle_type",
|
||||
"nozzle_volume",
|
||||
"retract_after_wipe",
|
||||
"retract_before_wipe",
|
||||
"retract_length_toolchange",
|
||||
"retract_lift_above",
|
||||
"retract_lift_below",
|
||||
"retract_lift_enforce",
|
||||
"retract_restart_extra",
|
||||
"retract_restart_extra_toolchange",
|
||||
"retract_when_changing_layer",
|
||||
"retraction_distances_when_cut",
|
||||
"retraction_length",
|
||||
"retraction_minimum_travel",
|
||||
"retraction_speed",
|
||||
"travel_slope",
|
||||
"wipe",
|
||||
"wipe_distance",
|
||||
"z_hop",
|
||||
"z_hop_types"
|
||||
};
|
||||
|
||||
m_extruder_retract_keys = {
|
||||
"deretraction_speed",
|
||||
"long_retractions_when_cut",
|
||||
"retract_after_wipe",
|
||||
"retract_before_wipe",
|
||||
"retract_lift_above",
|
||||
"retract_lift_below",
|
||||
@@ -7996,17 +8035,40 @@ void PrintConfigDef::init_extruder_option_keys()
|
||||
void PrintConfigDef::init_filament_option_keys()
|
||||
{
|
||||
m_filament_option_keys = {
|
||||
"filament_diameter", "min_layer_height", "max_layer_height","volumetric_speed_coefficients",
|
||||
"retraction_length", "z_hop", "z_hop_types", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed",
|
||||
"retract_before_wipe", "filament_retract_length_nc", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance",
|
||||
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour",
|
||||
"default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut"/*,"filament_seam_gap"*/
|
||||
"default_filament_profile",
|
||||
"deretraction_speed",
|
||||
"filament_colour",
|
||||
"filament_diameter",
|
||||
"filament_retract_length_nc",
|
||||
// "filament_seam_gap",
|
||||
"long_retractions_when_cut",
|
||||
"max_layer_height",
|
||||
"min_layer_height",
|
||||
"retract_after_wipe",
|
||||
"retract_before_wipe",
|
||||
"retract_length_toolchange",
|
||||
"retract_lift_above",
|
||||
"retract_lift_below",
|
||||
"retract_lift_enforce",
|
||||
"retract_restart_extra",
|
||||
"retract_restart_extra_toolchange",
|
||||
"retract_when_changing_layer",
|
||||
"retraction_distances_when_cut",
|
||||
"retraction_length",
|
||||
"retraction_minimum_travel",
|
||||
"retraction_speed",
|
||||
"volumetric_speed_coefficients",
|
||||
"wipe",
|
||||
"wipe_distance",
|
||||
"z_hop",
|
||||
"z_hop_types",
|
||||
};
|
||||
|
||||
m_filament_retract_keys = {
|
||||
"deretraction_speed",
|
||||
"filament_retract_length_nc",
|
||||
"long_retractions_when_cut",
|
||||
"retract_after_wipe",
|
||||
"retract_before_wipe",
|
||||
"retract_lift_above",
|
||||
"retract_lift_below",
|
||||
@@ -9050,6 +9112,9 @@ std::set<std::string> filament_options_with_variant = {
|
||||
//BBS
|
||||
"filament_wipe_distance",
|
||||
"filament_retract_before_wipe",
|
||||
// Orca
|
||||
"filament_retract_after_wipe",
|
||||
//BBS
|
||||
"filament_long_retractions_when_cut",
|
||||
"filament_retraction_distances_when_cut",
|
||||
"long_retractions_when_ec",
|
||||
@@ -9100,6 +9165,8 @@ std::set<std::string> printer_options_with_variant_1 = {
|
||||
"wipe",
|
||||
"wipe_distance",
|
||||
"retract_before_wipe",
|
||||
// Orca:
|
||||
"retract_after_wipe",
|
||||
"retract_length_toolchange",
|
||||
"retract_restart_extra",
|
||||
"retract_restart_extra_toolchange",
|
||||
|
||||
@@ -1542,6 +1542,9 @@ PRINT_CONFIG_CLASS_DEFINE(
|
||||
|
||||
|
||||
((ConfigOptionPercents, retract_before_wipe))
|
||||
// Orca
|
||||
((ConfigOptionPercents, retract_after_wipe))
|
||||
|
||||
((ConfigOptionFloats, retraction_length))
|
||||
((ConfigOptionFloats, retract_length_toolchange))
|
||||
((ConfigOptionInt, enable_long_retraction_when_cut))
|
||||
|
||||
Reference in New Issue
Block a user