1) Storing the physical_printer_settings_id into the 3MF, AMF, GCode.

2) Activating the physical_printer_settings_id when loading from 3MF, AMF, GCode.
   The physical printer is only activated if it references the printer_settings_id
   loaded from the same file.
3) When loading the presets from 3MF, AMF, GCode, the "external" profiles
   are no more created for profiles which differ from the local profiles
   the loaded profiles reference. Instead, the referenced profile is activated
   and modified with the loaded preset. If the referenced profile does not
   exist, but the profile refers to a system profile with the "inherits"
   fileds, the system profile is loaded and modified instead.
   This works for all profiles with the exception of multi-extruder
   printer with multiple filament profiles modified. In that case
   the first modified filament profile will be loaded as modified,
   while the other modified profiles will be loaded as "external".

This should fix
Physical printer + 3mf file, wrong preset used to generate gcode #5178
and possibly
https://github.com/prusa3d/PrusaSlicer/issues/5272
This commit is contained in:
Vojtech Bubnik 2020-12-04 10:48:44 +01:00
parent 15b56c9950
commit e42e25c933
8 changed files with 118 additions and 57 deletions

View file

@ -596,9 +596,10 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
#endif /* _DEBUG */
// Normalize the config.
new_full_config.option("print_settings_id", true);
new_full_config.option("filament_settings_id", true);
new_full_config.option("printer_settings_id", true);
new_full_config.option("print_settings_id", true);
new_full_config.option("filament_settings_id", true);
new_full_config.option("printer_settings_id", true);
new_full_config.option("physical_printer_settings_id", true);
new_full_config.normalize_fdm();
// Find modified keys of the various configs. Resolve overrides extruder retract values by filament profiles.
@ -627,9 +628,10 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
if (! full_config_diff.empty()) {
update_apply_status(this->invalidate_step(psGCodeExport));
// Set the profile aliases for the PrintBase::output_filename()
m_placeholder_parser.set("print_preset", new_full_config.option("print_settings_id")->clone());
m_placeholder_parser.set("filament_preset", new_full_config.option("filament_settings_id")->clone());
m_placeholder_parser.set("printer_preset", new_full_config.option("printer_settings_id")->clone());
m_placeholder_parser.set("print_preset", new_full_config.option("print_settings_id")->clone());
m_placeholder_parser.set("filament_preset", new_full_config.option("filament_settings_id")->clone());
m_placeholder_parser.set("printer_preset", new_full_config.option("printer_settings_id")->clone());
m_placeholder_parser.set("physical_printer_preset", new_full_config.option("physical_printer_settings_id")->clone());
// We want the filament overrides to be applied over their respective extruder parameters by the PlaceholderParser.
// see "Placeholders do not respect filament overrides." GH issue #3649
m_placeholder_parser.apply_config(filament_overrides);