Update how machine instances are translated to stacks

Lots of things have changed in how this works. Sadly, I can't translate things like the material, from PLA to ultimaker2_plus_0.4mm_pla. Not without implementing the entire container registry in the plug-in anyway.

Contributes to issue CURA-844.
This commit is contained in:
Ghostkeeper 2016-07-01 15:07:20 +02:00
parent d1188899a7
commit 2de811accf

View file

@ -62,22 +62,26 @@ class MachineInstance:
config.add_section("general") config.add_section("general")
config.set("general", "name", self._name) config.set("general", "name", self._name)
config.set("general", "id", self._name)
config.set("general", "type", self._type_name) config.set("general", "type", self._type_name)
config.set("general", "version", "2") # Hard-code version 2, since if this number changes the programmer MUST change this entire function. config.set("general", "version", "2") # Hard-code version 2, since if this number changes the programmer MUST change this entire function.
if self._variant_name:
config.set("general", "variant", self._variant_name) containers = []
if self._key: containers.append(self._name + "_current_settings")
config.set("general", "key", self._key) containers.append("empty") #The dependencies of the active profile, material and variant changed, so there is no 1:1 relation possible here.
if self._active_profile_name: containers.append("empty")
config.set("general", "active_profile", self._active_profile_name) containers.append("empty")
if self._active_material_name: containers.append(self._type_name)
config.set("general", "material", self._active_material_name) config.set("general", "containers", ",".join(containers))
config.add_section("metadata")
config.set("metadata", "type", "machine")
import VersionUpgrade21to22 # Import here to prevent circular dependencies. import VersionUpgrade21to22 # Import here to prevent circular dependencies.
VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettings(self._machine_setting_overrides) VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettings(self._machine_setting_overrides)
config.add_section("machine_settings") config.add_section("values")
for key, value in self._machine_setting_overrides.items(): for key, value in self._machine_setting_overrides.items():
config.set("machine_settings", key, str(value)) config.set("values", key, str(value))
output = io.StringIO() output = io.StringIO()
config.write(output) config.write(output)