diff options
author | Kostas Karmas <konskarm@gmail.com> | 2020-08-10 15:56:37 +0300 |
---|---|---|
committer | Kostas Karmas <konskarm@gmail.com> | 2020-08-10 15:56:37 +0300 |
commit | b9d5f0dc152cdf2e6548e72c0c4dd46d250b008b (patch) | |
tree | 01c400eb45e8866674f6e68b5eea2121e7b1b5f2 /plugins/3MFReader | |
parent | 2828f45e8993fb1d03ac9350aa8edc2530139b9f (diff) |
Take the machine_extruder_count into consideration when opening project
CURA-7646
Diffstat (limited to 'plugins/3MFReader')
-rwxr-xr-x | plugins/3MFReader/ThreeMFWorkspaceReader.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 9abab88e6a..54a0b17bda 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -663,7 +663,12 @@ class ThreeMFWorkspaceReader(WorkspaceReader): # We need to create a new machine machine_name = self._container_registry.uniqueName(self._machine_info.name) - global_stack = CuraStackBuilder.createMachine(machine_name, self._machine_info.definition_id) + # Printers with modifiable number of extruders (such as CFFF) will specify a machine_extruder_count in their + # quality_changes file. If that's the case, take the extruder count into account when creating the machine + # or else the extruderList will return only the first extruder, leading to missing non-global settings in + # the other extruders. See CURA-7646 + machine_extruder_count = self._getMachineExtruderCount() # type: Optional[int] + global_stack = CuraStackBuilder.createMachine(machine_name, self._machine_info.definition_id, machine_extruder_count) if global_stack: # Only switch if creating the machine was successful. extruder_stack_dict = {str(position): extruder for position, extruder in enumerate(global_stack.extruderList)} @@ -918,6 +923,24 @@ class ThreeMFWorkspaceReader(WorkspaceReader): self._machine_info.quality_changes_info.name = quality_changes_name + def _getMachineExtruderCount(self) -> Optional[int]: + """ + Extracts the machine extruder count from the definition_changes file of the printer. If it is not specified in + the file, None is returned instead. + + :return: The count of the machine's extruders + """ + machine_extruder_count = None + if self._machine_info.definition_changes_info \ + and "values" in self._machine_info.definition_changes_info.parser \ + and "machine_extruder_count" in self._machine_info.definition_changes_info.parser["values"]: + try: + machine_extruder_count = int(self._machine_info.definition_changes_info.parser["values"]["machine_extruder_count"]) + except ValueError: + Logger.log("w", "'machine_extruder_count' in file '{file_name}' is not a number." + .format(file_name = self._machine_info.definition_changes_info.file_name)) + return machine_extruder_count + def _createNewQualityChanges(self, quality_type: str, intent_category: Optional[str], name: str, global_stack: GlobalStack, extruder_stack: Optional[ExtruderStack]) -> InstanceContainer: """Helper class to create a new quality changes profile. |