FIX: get wrong value in retract params
1.Should get value by filament id instead of extruder id 2.Fix many other issues caused by incorrect usage jira:NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I3278d7de0f8976a97c9e5ccef80bba4a58553f5a (cherry picked from commit 30c51dd1171fc16ba778308745fab2eb246aedd0)
This commit is contained in:
parent
cfa669c2cb
commit
e9027478f8
|
@ -148,43 +148,43 @@ 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(extruder_id()) * 0.01));
|
||||
return std::min(1., std::max(0., m_config->retract_before_wipe.get_at(m_id) * 0.01));
|
||||
}
|
||||
|
||||
double Extruder::retraction_length() const
|
||||
{
|
||||
return m_config->retraction_length.get_at(extruder_id());
|
||||
return m_config->retraction_length.get_at(m_id);
|
||||
}
|
||||
|
||||
double Extruder::retract_lift() const
|
||||
{
|
||||
return m_config->z_hop.get_at(extruder_id());
|
||||
return m_config->z_hop.get_at(m_id);
|
||||
}
|
||||
|
||||
int Extruder::retract_speed() const
|
||||
{
|
||||
return int(floor(m_config->retraction_speed.get_at(extruder_id())+0.5));
|
||||
return int(floor(m_config->retraction_speed.get_at(m_id)+0.5));
|
||||
}
|
||||
|
||||
int Extruder::deretract_speed() const
|
||||
{
|
||||
int speed = int(floor(m_config->deretraction_speed.get_at(extruder_id())+0.5));
|
||||
int speed = int(floor(m_config->deretraction_speed.get_at(m_id)+0.5));
|
||||
return (speed > 0) ? speed : this->retract_speed();
|
||||
}
|
||||
|
||||
double Extruder::retract_restart_extra() const
|
||||
{
|
||||
return m_config->retract_restart_extra.get_at(extruder_id());
|
||||
return m_config->retract_restart_extra.get_at(m_id);
|
||||
}
|
||||
|
||||
double Extruder::retract_length_toolchange() const
|
||||
{
|
||||
return m_config->retract_length_toolchange.get_at(extruder_id());
|
||||
return m_config->retract_length_toolchange.get_at(m_id);
|
||||
}
|
||||
|
||||
double Extruder::retract_restart_extra_toolchange() const
|
||||
{
|
||||
return m_config->retract_restart_extra_toolchange.get_at(extruder_id());
|
||||
return m_config->retract_restart_extra_toolchange.get_at(m_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||
amount of retraction. In other words, how far do we move in XY at wipe_speed
|
||||
for the time needed to consume retraction_length at retraction_speed? */
|
||||
// BBS
|
||||
double wipe_dist = scale_(gcodegen.config().wipe_distance.get_at(gcodegen.writer().filament() ->extruder_id()));
|
||||
double wipe_dist = scale_(gcodegen.config().wipe_distance.get_at(gcodegen.writer().filament()->id()));
|
||||
|
||||
/* Take the stored wipe path and replace first point with the current actual position
|
||||
(they might be different, for example, in case of loop clipping). */
|
||||
|
@ -1322,10 +1322,10 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
|||
m_processor.result().support_traditional_timelapse = m_support_traditional_timelapse;
|
||||
|
||||
bool activate_long_retraction_when_cut = false;
|
||||
for (const auto& extruder : m_writer.extruders())
|
||||
for (const auto& filament : m_writer.extruders())
|
||||
activate_long_retraction_when_cut |= (
|
||||
m_config.long_retractions_when_cut.get_at(extruder.extruder_id())
|
||||
&& m_config.retraction_distances_when_cut.get_at(extruder.extruder_id()) > 0
|
||||
m_config.long_retractions_when_cut.get_at(filament.id())
|
||||
&& m_config.retraction_distances_when_cut.get_at(filament.id()) > 0
|
||||
);
|
||||
|
||||
m_processor.result().long_retraction_when_cut = activate_long_retraction_when_cut;
|
||||
|
@ -2005,8 +2005,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
m_placeholder_parser.set("initial_no_support_extruder", initial_non_support_extruder_id);
|
||||
m_placeholder_parser.set("current_extruder", initial_extruder_id);
|
||||
//set the key for compatibilty
|
||||
m_placeholder_parser.set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(extruder_id));
|
||||
m_placeholder_parser.set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(extruder_id));
|
||||
m_placeholder_parser.set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(initial_extruder_id));
|
||||
m_placeholder_parser.set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(initial_extruder_id));
|
||||
|
||||
m_placeholder_parser.set("retraction_distances_when_cut", new ConfigOptionFloatsNullable(m_config.retraction_distances_when_cut));
|
||||
m_placeholder_parser.set("long_retractions_when_cut",new ConfigOptionBoolsNullable(m_config.long_retractions_when_cut));
|
||||
|
@ -4219,10 +4219,10 @@ std::string GCode::change_layer(coordf_t print_z)
|
|||
//BBS
|
||||
//coordf_t z = print_z + m_config.z_offset.value; // in unscaled coordinates
|
||||
coordf_t z = print_z; // in unscaled coordinates
|
||||
if (EXTRUDER_CONFIG(retract_when_changing_layer) && m_writer.will_move_z(z)) {
|
||||
LiftType lift_type = this->to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types)));
|
||||
if (FILAMENT_CONFIG(retract_when_changing_layer) && m_writer.will_move_z(z)) {
|
||||
LiftType lift_type = this->to_lift_type(ZHopType(FILAMENT_CONFIG(z_hop_types)));
|
||||
//BBS: force to use SpiralLift when change layer if lift type is auto
|
||||
gcode += this->retract(false, false, ZHopType(EXTRUDER_CONFIG(z_hop_types)) == ZHopType::zhtAuto ? LiftType::SpiralLift : lift_type);
|
||||
gcode += this->retract(false, false, ZHopType(FILAMENT_CONFIG(z_hop_types)) == ZHopType::zhtAuto ? LiftType::SpiralLift : lift_type);
|
||||
}
|
||||
|
||||
m_writer.add_object_change_labels(gcode);
|
||||
|
@ -4489,7 +4489,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
|
|||
|
||||
|
||||
// BBS
|
||||
if (m_wipe.enable && EXTRUDER_CONFIG(wipe)) {
|
||||
if (m_wipe.enable && FILAMENT_CONFIG(wipe)) {
|
||||
m_wipe.path = Polyline();
|
||||
for (ExtrusionPath &path : paths) {
|
||||
//BBS: Don't need to save duplicated point into wipe path
|
||||
|
@ -4552,7 +4552,7 @@ std::string GCode::extrude_multi_path(ExtrusionMultiPath multipath, std::string
|
|||
gcode += this->_extrude(path, description, speed);
|
||||
|
||||
// BBS
|
||||
if (m_wipe.enable && EXTRUDER_CONFIG(wipe)) {
|
||||
if (m_wipe.enable && FILAMENT_CONFIG(wipe)) {
|
||||
m_wipe.path = Polyline();
|
||||
for (ExtrusionPath &path : multipath.paths) {
|
||||
//BBS: Don't need to save duplicated point into wipe path
|
||||
|
@ -4591,7 +4591,7 @@ std::string GCode::extrude_path(ExtrusionPath path, std::string description, dou
|
|||
{
|
||||
// description += ExtrusionEntity::role_to_string(path.role());
|
||||
std::string gcode = this->_extrude(path, description, speed);
|
||||
if (m_wipe.enable && EXTRUDER_CONFIG(wipe)) {
|
||||
if (m_wipe.enable && FILAMENT_CONFIG(wipe)) {
|
||||
m_wipe.path = std::move(path.polyline);
|
||||
m_wipe.path.reverse();
|
||||
}
|
||||
|
@ -5507,7 +5507,7 @@ LiftType GCode::to_lift_type(ZHopType z_hop_types) {
|
|||
|
||||
bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftType& lift_type)
|
||||
{
|
||||
if (travel.length() < scale_(EXTRUDER_CONFIG(retraction_minimum_travel))) {
|
||||
if (travel.length() < scale_(FILAMENT_CONFIG(retraction_minimum_travel))) {
|
||||
// skip retraction if the move is shorter than the configured threshold
|
||||
return false;
|
||||
}
|
||||
|
@ -5586,11 +5586,11 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp
|
|||
//BBS: force to retract when leave from external perimeter for a long travel
|
||||
//Better way is judging whether the travel move direction is same with last extrusion move.
|
||||
if (is_perimeter(m_last_processor_extrusion_role) && m_last_processor_extrusion_role != erPerimeter) {
|
||||
if (ZHopType(EXTRUDER_CONFIG(z_hop_types)) == ZHopType::zhtAuto) {
|
||||
if (ZHopType(FILAMENT_CONFIG(z_hop_types)) == ZHopType::zhtAuto) {
|
||||
lift_type = is_through_overhang(clipped_travel) ? LiftType::SpiralLift : LiftType::LazyLift;
|
||||
}
|
||||
else {
|
||||
lift_type = to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types)));
|
||||
lift_type = to_lift_type(ZHopType(FILAMENT_CONFIG(z_hop_types)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -5615,11 +5615,11 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp
|
|||
return false;
|
||||
|
||||
// retract if reduce_infill_retraction is disabled or doesn't apply when role is perimeter
|
||||
if (ZHopType(EXTRUDER_CONFIG(z_hop_types)) == ZHopType::zhtAuto) {
|
||||
if (ZHopType(FILAMENT_CONFIG(z_hop_types)) == ZHopType::zhtAuto) {
|
||||
lift_type = is_through_overhang(clipped_travel) ? LiftType::SpiralLift : LiftType::LazyLift;
|
||||
}
|
||||
else {
|
||||
lift_type = to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types)));
|
||||
lift_type = to_lift_type(ZHopType(FILAMENT_CONFIG(z_hop_types)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -5632,7 +5632,7 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li
|
|||
return gcode;
|
||||
|
||||
// wipe (if it's enabled for this extruder and we have a stored wipe path and no-zero wipe distance)
|
||||
if (EXTRUDER_CONFIG(wipe) && m_wipe.has_path() && scale_(EXTRUDER_CONFIG(wipe_distance)) > SCALED_EPSILON) {
|
||||
if (FILAMENT_CONFIG(wipe) && m_wipe.has_path() && scale_(FILAMENT_CONFIG(wipe_distance)) > SCALED_EPSILON) {
|
||||
gcode += toolchange ? m_writer.retract_for_toolchange(true) : m_writer.retract(true);
|
||||
gcode += m_wipe.wipe(*this, toolchange, is_last_retraction);
|
||||
}
|
||||
|
|
|
@ -692,10 +692,11 @@ std::string GCodeWriter::lift(LiftType lift_type, bool spiral_vase)
|
|||
{
|
||||
//BBS
|
||||
int extruder_id = filament()->extruder_id();
|
||||
int filament_id = filament()->id();
|
||||
double above = this->config.retract_lift_above.get_at(extruder_id);
|
||||
double below = this->config.retract_lift_below.get_at(extruder_id);
|
||||
if (m_pos.z() >= above && m_pos.z() <= below)
|
||||
target_lift = this->config.z_hop.get_at(extruder_id);
|
||||
target_lift = this->config.z_hop.get_at(filament_id);
|
||||
}
|
||||
// BBS
|
||||
if (m_lifted == 0 && m_to_lift == 0 && target_lift > 0) {
|
||||
|
|
Loading…
Reference in New Issue