ENH: add layer num in filament end GCode

jira: NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I6f81b86a7b7391048d70f2c4839733a69015e53b
This commit is contained in:
xun.zhang 2025-03-20 16:09:43 +08:00 committed by lane.wei
parent 01be3a51e6
commit aafcfd72f4
1 changed files with 6 additions and 2 deletions

View File

@ -644,7 +644,9 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
unsigned int old_filament_id = gcodegen.writer().filament()->id();
const std::string& filament_end_gcode = gcodegen.config().filament_end_gcode.get_at(old_filament_id);
if (gcodegen.writer().filament() != nullptr && !filament_end_gcode.empty()) {
end_filament_gcode_str = gcodegen.placeholder_parser_process("filament_end_gcode", filament_end_gcode, old_filament_id);
DynamicConfig config;
config.set_key_value("layer_num", new ConfigOptionInt(gcodegen.m_layer_index));
end_filament_gcode_str = gcodegen.placeholder_parser_process("filament_end_gcode", filament_end_gcode, old_filament_id, &config);
check_add_eol(end_filament_gcode_str);
}
}
@ -6029,7 +6031,9 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
unsigned int old_filament_id = m_writer.filament()->id();
const std::string &filament_end_gcode = m_config.filament_end_gcode.get_at(old_filament_id);
if (! filament_end_gcode.empty()) {
gcode += placeholder_parser_process("filament_end_gcode", filament_end_gcode, old_filament_id);
DynamicConfig config;
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
gcode += placeholder_parser_process("filament_end_gcode", filament_end_gcode, old_filament_id, &config);
check_add_eol(gcode);
}
}