ENH: fix the floating layer issue

Fix for floating layer under multi-color
printing while z_hop is zero.

Signed-off-by: salt.wei <salt.wei@bambulab.com>
Change-Id: I8cc96bd18020cac8424fe4c3e62fb87da118b826
This commit is contained in:
salt.wei 2023-03-16 18:13:12 +08:00 committed by Lane.Wei
parent 679ccb658b
commit 0b126dbed6
5 changed files with 108 additions and 17 deletions

View file

@ -520,9 +520,20 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
// retract before toolchange
toolchange_gcode_str = toolchange_retract_str + toolchange_gcode_str;
//BBS: current position and fan_speed is unclear after interting change_filament_gcode
toolchange_gcode_str += ";_FORCE_RESUME_FAN_SPEED\n";
gcodegen.writer().set_current_position_clear(false);
//BBS
{
//BBS: current position and fan_speed is unclear after interting change_filament_gcode
check_add_eol(toolchange_gcode_str);
toolchange_gcode_str += ";_FORCE_RESUME_FAN_SPEED\n";
gcodegen.writer().set_current_position_clear(false);
//BBS: check whether custom gcode changes the z position. Update if changed
double temp_z_after_tool_change;
if (GCodeProcessor::get_last_z_from_gcode(toolchange_gcode_str, temp_z_after_tool_change)) {
Vec3d pos = gcodegen.writer().get_position();
pos(2) = temp_z_after_tool_change;
gcodegen.writer().set_position(pos);
}
}
// move to start_pos for wiping after toolchange
std::string start_pos_str;
@ -4239,12 +4250,23 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z)
std::string toolchange_gcode_parsed;
if (!change_filament_gcode.empty()) {
toolchange_gcode_parsed = placeholder_parser_process("change_filament_gcode", change_filament_gcode, extruder_id, &dyn_config);
check_add_eol(toolchange_gcode_parsed);
gcode += toolchange_gcode_parsed;
check_add_eol(gcode);
//BBS: gcode writer doesn't know where the extruder is and whether fan speed is changed after inserting tool change gcode
//Set this flag so that normal lift will be used the first time after tool change.
gcode += ";_FORCE_RESUME_FAN_SPEED\n";
m_writer.set_current_position_clear(false);
//BBS
{
//BBS: gcode writer doesn't know where the extruder is and whether fan speed is changed after inserting tool change gcode
//Set this flag so that normal lift will be used the first time after tool change.
gcode += ";_FORCE_RESUME_FAN_SPEED\n";
m_writer.set_current_position_clear(false);
//BBS: check whether custom gcode changes the z position. Update if changed
double temp_z_after_tool_change;
if (GCodeProcessor::get_last_z_from_gcode(toolchange_gcode_parsed, temp_z_after_tool_change)) {
Vec3d pos = m_writer.get_position();
pos(2) = temp_z_after_tool_change;
m_writer.set_position(pos);
}
}
}
// BBS. Reset old extruder E-value.