Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostas Karmas <konskarm@gmail.com>2020-08-03 15:34:45 +0300
committerKostas Karmas <konskarm@gmail.com>2020-08-03 17:20:29 +0300
commita6d779e72284b4279d9956610eead861de5a80a2 (patch)
tree6618bb2b1a0b475bed5e3813a5c2d11d16049c0f /plugins/3MFReader
parent17b6dd46b03906730a571fbacad66e28cd8513e5 (diff)
Sort materials based on extruder position in the open project dialog
From eCCB
Diffstat (limited to 'plugins/3MFReader')
-rwxr-xr-xplugins/3MFReader/ThreeMFWorkspaceReader.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py
index 664b14afa1..ec457e0a4b 100755
--- a/plugins/3MFReader/ThreeMFWorkspaceReader.py
+++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py
@@ -260,7 +260,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
if machine_definition_container_count != 1:
return WorkspaceReader.PreReadResult.failed # Not a workspace file but ordinary 3MF.
- material_labels = []
+ material_ids_to_names_map = {}
material_conflict = False
xml_material_profile = self._getXmlProfileClass()
reverse_material_id_dict = {}
@@ -276,7 +276,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
reverse_map = {metadata["id"]: container_id for metadata in metadata_list}
reverse_material_id_dict.update(reverse_map)
- material_labels.append(self._getMaterialLabelFromSerialized(serialized))
+ material_ids_to_names_map[container_id] = self._getMaterialLabelFromSerialized(serialized)
if self._container_registry.findContainersMetadata(id = container_id): #This material already exists.
containers_found_dict["material"] = True
if not self._container_registry.isReadOnly(container_id): # Only non readonly materials can be in conflict
@@ -443,6 +443,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
QCoreApplication.processEvents() # Ensure that the GUI does not freeze.
Job.yieldThread()
+ materials_in_extruders_dict = {} # Which material is in which extruder
+
# if the global stack is found, we check if there are conflicts in the extruder stacks
for extruder_stack_file in extruder_stack_files:
serialized = archive.open(extruder_stack_file).read().decode("utf-8")
@@ -456,6 +458,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
position = parser["metadata"]["position"]
variant_id = parser["containers"][str(_ContainerIndexes.Variant)]
material_id = parser["containers"][str(_ContainerIndexes.Material)]
+ materials_in_extruders_dict[position] = material_ids_to_names_map[reverse_material_id_dict[material_id]]
extruder_info = ExtruderInfo()
extruder_info.position = position
@@ -496,6 +499,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
machine_conflict = True
break
+ # Now we know which material is in which extruder. Let's use that to sort the material_labels according to
+ # their extruder position
+ material_labels = [material_name for pos, material_name in sorted(materials_in_extruders_dict.items())]
+
num_visible_settings = 0
try:
temp_preferences = Preferences()