diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 5d47126cf..aa445f527 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -644,7 +644,9 @@ static std::vector 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); } }