mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 16:49:03 +08:00
Change retract_restart_extra_toolchange behavior to trigger at each first tool unretraction (but the very first)
supermerill/SuperSlicer#1052
This commit is contained in:
parent
666851acd5
commit
54ad2a8611
@ -36,7 +36,7 @@ group:Retraction wipe
|
|||||||
setting:idx:wipe_extra_perimeter
|
setting:idx:wipe_extra_perimeter
|
||||||
setting:idx:seam_gap
|
setting:idx:seam_gap
|
||||||
group:Retraction when tool is disabled (advanced settings for multi-extruder setups)
|
group:Retraction when tool is disabled (advanced settings for multi-extruder setups)
|
||||||
setting:idx:retract_length_toolchange
|
setting:label$Minimum retraction:idx:retract_length_toolchange
|
||||||
setting:idx:retract_restart_extra_toolchange
|
setting:label$Extra unretraction:idx:retract_restart_extra_toolchange
|
||||||
group:Preview
|
group:Preview
|
||||||
reset_to_filament_color
|
reset_to_filament_color
|
||||||
|
@ -13,6 +13,8 @@ Tool::Tool(uint16_t id, GCodeConfig* config) :
|
|||||||
Extruder::Extruder(uint16_t id, GCodeConfig* config) :
|
Extruder::Extruder(uint16_t id, GCodeConfig* config) :
|
||||||
Tool(id, config)
|
Tool(id, config)
|
||||||
{
|
{
|
||||||
|
// set extra_toolchange to be init for when it will be new current extruder
|
||||||
|
m_restart_extra_toolchange = retract_restart_extra_toolchange();
|
||||||
|
|
||||||
// cache values that are going to be called often
|
// cache values that are going to be called often
|
||||||
m_e_per_mm3 = this->extrusion_multiplier();
|
m_e_per_mm3 = this->extrusion_multiplier();
|
||||||
@ -46,7 +48,7 @@ double Tool::extrude(double dE)
|
|||||||
The restart_extra argument sets the extra length to be used for
|
The restart_extra argument sets the extra length to be used for
|
||||||
unretraction. If we're actually performing a retraction, any restart_extra
|
unretraction. If we're actually performing a retraction, any restart_extra
|
||||||
value supplied will overwrite the previous one if any. */
|
value supplied will overwrite the previous one if any. */
|
||||||
double Tool::retract(double length, double restart_extra)
|
double Tool::retract(double length, double restart_extra, double restart_extra_toolchange)
|
||||||
{
|
{
|
||||||
// in case of relative E distances we always reset to 0 before any output
|
// in case of relative E distances we always reset to 0 before any output
|
||||||
if (m_config->use_relative_e_distances)
|
if (m_config->use_relative_e_distances)
|
||||||
@ -56,17 +58,22 @@ double Tool::retract(double length, double restart_extra)
|
|||||||
m_E -= to_retract;
|
m_E -= to_retract;
|
||||||
m_absolute_E -= to_retract;
|
m_absolute_E -= to_retract;
|
||||||
m_retracted += to_retract;
|
m_retracted += to_retract;
|
||||||
m_restart_extra = restart_extra;
|
if(!std::isnan(restart_extra))
|
||||||
|
m_restart_extra = restart_extra;
|
||||||
}
|
}
|
||||||
|
if (!std::isnan(restart_extra_toolchange))
|
||||||
|
m_restart_extra_toolchange = restart_extra_toolchange;
|
||||||
return to_retract;
|
return to_retract;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Tool::unretract()
|
double Tool::unretract()
|
||||||
{
|
{
|
||||||
double dE = m_retracted + m_restart_extra;
|
double dE = m_retracted + m_restart_extra + m_restart_extra_toolchange;
|
||||||
this->extrude(dE);
|
this->extrude(dE);
|
||||||
m_retracted = 0.;
|
m_retracted = 0.;
|
||||||
m_restart_extra = 0.;
|
m_restart_extra = 0.;
|
||||||
|
if(m_restart_extra_toolchange != 0)
|
||||||
|
m_restart_extra_toolchange = 0.;
|
||||||
return dE;
|
return dE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,13 @@ public:
|
|||||||
m_absolute_E = 0;
|
m_absolute_E = 0;
|
||||||
m_retracted = 0;
|
m_retracted = 0;
|
||||||
m_restart_extra = 0;
|
m_restart_extra = 0;
|
||||||
|
m_restart_extra_toolchange = 0; // note: can't call retract_restart_extra_toolchange(); because virtual inheritance doesn't work when only the tool is build (constructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t id() const { return m_id; }
|
uint16_t id() const { return m_id; }
|
||||||
|
|
||||||
virtual double extrude(double dE);
|
virtual double extrude(double dE);
|
||||||
virtual double retract(double length, double restart_extra);
|
virtual double retract(double length, double restart_extra, double restart_extra_from_toolchange);
|
||||||
virtual double unretract();
|
virtual double unretract();
|
||||||
double E() const { return m_E; }
|
double E() const { return m_E; }
|
||||||
void reset_E() { m_E = 0.; }
|
void reset_E() { m_E = 0.; }
|
||||||
@ -67,6 +68,7 @@ protected:
|
|||||||
double m_retracted;
|
double m_retracted;
|
||||||
// When retracted, this value stores the extra amount of priming on deretraction.
|
// When retracted, this value stores the extra amount of priming on deretraction.
|
||||||
double m_restart_extra;
|
double m_restart_extra;
|
||||||
|
double m_restart_extra_toolchange;
|
||||||
double m_e_per_mm3;
|
double m_e_per_mm3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1469,6 +1469,9 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||||||
m_writer.toolchange(initial_extruder_id);
|
m_writer.toolchange(initial_extruder_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure the first tool doesn't "extra_retract"
|
||||||
|
m_writer.unretract();
|
||||||
|
|
||||||
//write temps after custom gcodes to ensure the temperature are good. (after tool selection)
|
//write temps after custom gcodes to ensure the temperature are good. (after tool selection)
|
||||||
if ((initial_extruder_id != (uint16_t)-1) && !this->config().start_gcode_manual && print.config().first_layer_temperature.get_at(initial_extruder_id) != 0)
|
if ((initial_extruder_id != (uint16_t)-1) && !this->config().start_gcode_manual && print.config().first_layer_temperature.get_at(initial_extruder_id) != 0)
|
||||||
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, true);
|
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, true);
|
||||||
|
@ -601,12 +601,14 @@ std::string GCodeWriter::retract(bool before_wipe)
|
|||||||
return this->_retract(
|
return this->_retract(
|
||||||
factor * config_region->print_retract_length,
|
factor * config_region->print_retract_length,
|
||||||
factor * m_tool->retract_restart_extra(),
|
factor * m_tool->retract_restart_extra(),
|
||||||
|
NAN,
|
||||||
"retract"
|
"retract"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return this->_retract(
|
return this->_retract(
|
||||||
factor * m_tool->retract_length(),
|
factor * m_tool->retract_length(),
|
||||||
factor * m_tool->retract_restart_extra(),
|
factor * m_tool->retract_restart_extra(),
|
||||||
|
NAN,
|
||||||
"retract"
|
"retract"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -617,12 +619,13 @@ std::string GCodeWriter::retract_for_toolchange(bool before_wipe)
|
|||||||
assert(factor >= 0. && factor <= 1. + EPSILON);
|
assert(factor >= 0. && factor <= 1. + EPSILON);
|
||||||
return this->_retract(
|
return this->_retract(
|
||||||
factor * m_tool->retract_length_toolchange(),
|
factor * m_tool->retract_length_toolchange(),
|
||||||
|
NAN,
|
||||||
factor * m_tool->retract_restart_extra_toolchange(),
|
factor * m_tool->retract_restart_extra_toolchange(),
|
||||||
"retract for toolchange"
|
"retract for toolchange"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCodeWriter::_retract(double length, double restart_extra, const std::string &comment)
|
std::string GCodeWriter::_retract(double length, double restart_extra, double restart_extra_toolchange, const std::string &comment)
|
||||||
{
|
{
|
||||||
std::ostringstream gcode;
|
std::ostringstream gcode;
|
||||||
|
|
||||||
@ -637,9 +640,10 @@ std::string GCodeWriter::_retract(double length, double restart_extra, const std
|
|||||||
double area = d * d * PI/4;
|
double area = d * d * PI/4;
|
||||||
length = length * area;
|
length = length * area;
|
||||||
restart_extra = restart_extra * area;
|
restart_extra = restart_extra * area;
|
||||||
|
restart_extra_toolchange = restart_extra_toolchange * area;
|
||||||
}
|
}
|
||||||
|
|
||||||
double dE = m_tool->retract(length, restart_extra);
|
double dE = m_tool->retract(length, restart_extra, restart_extra_toolchange);
|
||||||
assert(dE >= 0);
|
assert(dE >= 0);
|
||||||
assert(dE < 10000000);
|
assert(dE < 10000000);
|
||||||
if (dE != 0) {
|
if (dE != 0) {
|
||||||
|
@ -100,7 +100,7 @@ private:
|
|||||||
Vec3d m_pos = Vec3d::Zero();
|
Vec3d m_pos = Vec3d::Zero();
|
||||||
|
|
||||||
std::string _travel_to_z(double z, const std::string &comment);
|
std::string _travel_to_z(double z, const std::string &comment);
|
||||||
std::string _retract(double length, double restart_extra, const std::string &comment);
|
std::string _retract(double length, double restart_extra, double restart_extra_toolchange, const std::string &comment);
|
||||||
|
|
||||||
// if positive, it's set, and the next lift wil have this extra lift
|
// if positive, it's set, and the next lift wil have this extra lift
|
||||||
double extra_lift = 0;
|
double extra_lift = 0;
|
||||||
|
@ -3281,7 +3281,8 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->full_label = L("Retraction Length (Toolchange)");
|
def->full_label = L("Retraction Length (Toolchange)");
|
||||||
def->tooltip = L("When retraction is triggered before changing tool, filament is pulled back "
|
def->tooltip = L("When retraction is triggered before changing tool, filament is pulled back "
|
||||||
"by the specified amount (the length is measured on raw filament, before it enters "
|
"by the specified amount (the length is measured on raw filament, before it enters "
|
||||||
"the extruder).");
|
"the extruder)."
|
||||||
|
"\nNote: This value will be unretracted when this extruder will load the next time.");
|
||||||
def->sidetext = L("mm (zero to disable)");
|
def->sidetext = L("mm (zero to disable)");
|
||||||
def->mode = comExpert;
|
def->mode = comExpert;
|
||||||
def->min = 0;
|
def->min = 0;
|
||||||
@ -3361,7 +3362,8 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->label = L("Extra length on restart");
|
def->label = L("Extra length on restart");
|
||||||
def->full_label = L("Extrat length on toolchange restart");
|
def->full_label = L("Extrat length on toolchange restart");
|
||||||
def->tooltip = L("When the retraction is compensated after changing tool, the extruder will push "
|
def->tooltip = L("When the retraction is compensated after changing tool, the extruder will push "
|
||||||
"this additional amount of filament.");
|
"this additional amount of filament"
|
||||||
|
" (but not on the first extruder after start, as it should already be loaded).");
|
||||||
def->sidetext = L("mm");
|
def->sidetext = L("mm");
|
||||||
def->mode = comExpert;
|
def->mode = comExpert;
|
||||||
def->is_vector_extruder = true;
|
def->is_vector_extruder = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user