Stacks are now loaded from workspace file

CURA-1263
This commit is contained in:
Jaime van Kessel 2016-11-10 15:42:20 +01:00
parent 611572c324
commit b92ca508bb

View file

@ -2,6 +2,9 @@ from UM.Workspace.WorkspaceReader import WorkspaceReader
from UM.Application import Application from UM.Application import Application
from UM.Logger import Logger from UM.Logger import Logger
from UM.Settings.ContainerStack import ContainerStack
import zipfile
## Base implementation for reading 3MF workspace files. ## Base implementation for reading 3MF workspace files.
class ThreeMFWorkspaceReader(WorkspaceReader): class ThreeMFWorkspaceReader(WorkspaceReader):
@ -22,4 +25,35 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
return WorkspaceReader.PreReadResult.accepted return WorkspaceReader.PreReadResult.accepted
def read(self, file_name): def read(self, file_name):
pass # Load all the nodes / meshdata of the workspace
nodes = self._3mf_mesh_reader.read(file_name)
if nodes is None:
nodes = []
archive = zipfile.ZipFile(file_name, "r")
cura_file_names = [name for name in archive.namelist() if name.startswith("Cura/")]
# Get the stack(s) saved in the workspace.
container_stack_files = [name for name in cura_file_names if name.endswith(".stack.cfg")]
global_stack = None
extruder_stacks = []
for container_stack_file in container_stack_files:
container_id = container_stack_file.replace("Cura/", "")
container_id = container_id.replace(".stack.cfg", "")
stack = ContainerStack(container_id)
# Serialize stack by converting read data from bytes to string
stack.deserialize(archive.open(container_stack_file).read().decode("utf-8"))
if stack.getMetaDataEntry("type") == "extruder_train":
extruder_stacks.append(stack)
else:
global_stack = stack
# Check if the right machine type is active now
#Application.getInstance().getGlobalContainerStack().getBottom().getId() ==
return nodes