mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-13 10:51:12 +00:00
Read the initial filament start G-code through get_at() (#16080)
A filament_start_gcode list shorter than the filament count made the Bambu start-of-export path throw std::out_of_range. Use get_at() like the other filament_start_gcode reads, and add a regression test.
This commit is contained in:
@@ -4262,7 +4262,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
config.set_key_value("nozzle_diameter_at_nozzle_id", new ConfigOptionFloats(get_nozzle_diameters_by_nozzle_id(group_result.get())));
|
||||
config.set_key_value("nozzle_volume_types", new ConfigOptionStrings(get_nozzle_volume_types_by_nozzle_id(group_result.get())));
|
||||
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
||||
std::string filament_start_gcode = this->placeholder_parser_process("filament_start_gcode", print.config().filament_start_gcode.values.at(initial_non_support_extruder_id), initial_non_support_extruder_id,&config);
|
||||
std::string filament_start_gcode = this->placeholder_parser_process("filament_start_gcode", print.config().filament_start_gcode.get_at(initial_non_support_extruder_id), initial_non_support_extruder_id,&config);
|
||||
file.writeln(filament_start_gcode);
|
||||
// Mark the first filament used in print. Multi-nozzle printers (H2C) get ";VT%d H%d" where
|
||||
// H = dynamic ? nozzle_id : -1; existing single-nozzle printers keep the bare ";VT%d" so their
|
||||
|
||||
@@ -1748,3 +1748,29 @@ TEST_CASE("Percent accelerations resolve against the option they are a percentag
|
||||
REQUIRE(accelerations_by_role[role_name] == std::set<int>{ value });
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Initial filament start G-code tolerates a list shorter than the filament count", "[GCodeWriter]")
|
||||
{
|
||||
// Two filaments but only one filament_start_gcode entry, and the only object prints on
|
||||
// filament 2, so the BBL export starts on a filament past the end of the list.
|
||||
DynamicPrintConfig config = multifilament_config(2);
|
||||
config.set_key_value("filament_start_gcode", new ConfigOptionStrings({"; filament start"}));
|
||||
|
||||
Model model;
|
||||
auto *obj = model.add_object();
|
||||
obj->add_volume(cube(20));
|
||||
obj->add_instance();
|
||||
obj->config.set_key_value("extruder", new ConfigOptionInt(2));
|
||||
|
||||
Print print;
|
||||
print.is_BBL_printer() = true;
|
||||
arrange_objects_on_test_bed(model, config);
|
||||
for (auto *mo : model.objects) {
|
||||
mo->ensure_on_bed();
|
||||
print.auto_assign_extruders(mo);
|
||||
}
|
||||
print.apply(model, config);
|
||||
print.validate();
|
||||
|
||||
REQUIRE_NOTHROW(Slic3r::Test::gcode(print));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user