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

@ -287,7 +287,18 @@ public:
Preset& load_preset(const std::string &path, const std::string &name, const DynamicPrintConfig &config, bool select = true);
Preset& load_preset(const std::string &path, const std::string &name, DynamicPrintConfig &&config, bool select = true);
Preset& load_external_preset(
// Returns a loaded preset, returns true if an existing preset was selected AND modified from config.
// In that case the successive filament loaded for a multi material printer should not be modified, but
// an external preset should be created instead.
enum class LoadAndSelect {
// Never select
Never,
// Always select
Always,
// Select a profile only if it was modified.
OnlyIfModified,
};
std::pair<Preset*, bool> load_external_preset(
// Path to the profile source file (a G-code, an AMF or 3MF file, a config file)
const std::string &path,
// Name of the profile, derived from the source file name.
@ -297,7 +308,7 @@ public:
// Config to initialize the preset from.
const DynamicPrintConfig &config,
// Select the preset after loading?
bool select = true);
LoadAndSelect select = LoadAndSelect::Always);
// Save the preset under a new name. If the name is different from the old one,
// a new preset is stored into the list of presets.