mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
CURA-4400 Fixed project loading
"enabled" metadata is now read from saved projects (.3mf)
This commit is contained in:
parent
19792fc1a6
commit
d7b0f11ddf
2 changed files with 14 additions and 0 deletions
|
@ -136,6 +136,8 @@ class ExtruderStack(CuraContainerStack):
|
||||||
@override(CuraContainerStack)
|
@override(CuraContainerStack)
|
||||||
def deserialize(self, contents: str, file_name: Optional[str] = None) -> None:
|
def deserialize(self, contents: str, file_name: Optional[str] = None) -> None:
|
||||||
super().deserialize(contents, file_name)
|
super().deserialize(contents, file_name)
|
||||||
|
if "enabled" not in self.getMetaData():
|
||||||
|
self.addMetaDataEntry("enabled", "True")
|
||||||
stacks = ContainerRegistry.getInstance().findContainerStacks(id=self.getMetaDataEntry("machine", ""))
|
stacks = ContainerRegistry.getInstance().findContainerStacks(id=self.getMetaDataEntry("machine", ""))
|
||||||
if stacks:
|
if stacks:
|
||||||
self.setNextStack(stacks[0])
|
self.setNextStack(stacks[0])
|
||||||
|
|
|
@ -99,6 +99,7 @@ class MachineInfo:
|
||||||
class ExtruderInfo:
|
class ExtruderInfo:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.position = None
|
self.position = None
|
||||||
|
self.enabled = True
|
||||||
self.variant_info = None
|
self.variant_info = None
|
||||||
self.root_material_id = None
|
self.root_material_id = None
|
||||||
|
|
||||||
|
@ -425,6 +426,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
|
|
||||||
extruder_info = ExtruderInfo()
|
extruder_info = ExtruderInfo()
|
||||||
extruder_info.position = position
|
extruder_info.position = position
|
||||||
|
if parser.has_option("metadata", "enabled"):
|
||||||
|
extruder_info.enabled = parser["metadata"]["enabled"]
|
||||||
if variant_id not in ("empty", "empty_variant"):
|
if variant_id not in ("empty", "empty_variant"):
|
||||||
extruder_info.variant_info = instance_container_info_dict[variant_id]
|
extruder_info.variant_info = instance_container_info_dict[variant_id]
|
||||||
if material_id not in ("empty", "empty_material"):
|
if material_id not in ("empty", "empty_material"):
|
||||||
|
@ -946,6 +949,15 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
else:
|
else:
|
||||||
self._quality_type_to_apply = self._machine_info.quality_type
|
self._quality_type_to_apply = self._machine_info.quality_type
|
||||||
|
|
||||||
|
# Set enabled/disabled for extruders
|
||||||
|
for position, extruder_stack in extruder_stack_dict.items():
|
||||||
|
extruder_info = self._machine_info.extruder_info_dict.get(position)
|
||||||
|
if not extruder_info:
|
||||||
|
continue
|
||||||
|
if "enabled" not in extruder_stack.getMetaData():
|
||||||
|
extruder_stack.addMetaDataEntry("enabled", "True")
|
||||||
|
extruder_stack.setMetaDataEntry("enabled", str(extruder_info.enabled))
|
||||||
|
|
||||||
def _updateActiveMachine(self, global_stack):
|
def _updateActiveMachine(self, global_stack):
|
||||||
# Actually change the active machine.
|
# Actually change the active machine.
|
||||||
machine_manager = Application.getInstance().getMachineManager()
|
machine_manager = Application.getInstance().getMachineManager()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue