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:
authorJaime van Kessel <nallath@gmail.com>2020-08-12 14:42:14 +0300
committerJaime van Kessel <nallath@gmail.com>2020-08-12 14:42:14 +0300
commitdd42c87da762d2030ee2220bc6f0a3e44cf85c28 (patch)
tree09eafb0115e49a5d2a08c1591e8cfc8dbdefc023 /plugins
parent67ef6405240a8ef6b4abde24eb85e281b0dbb98a (diff)
parent01d5e846aa62c12a709f91d66df54f029f4bf323 (diff)
Merge branch 'CURA-7646_Settings_not_applied_when_creating_new_CFFF_from_project_file' of github.com:Ultimaker/Cura into 4.7
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/3MFReader/ThreeMFWorkspaceReader.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py
index 9abab88e6a..6ed35fe72c 100755
--- a/plugins/3MFReader/ThreeMFWorkspaceReader.py
+++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py
@@ -502,6 +502,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# 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())]
+ machine_extruder_count = self._getMachineExtruderCount()
+ if machine_extruder_count:
+ material_labels = material_labels[:machine_extruder_count]
num_visible_settings = 0
try:
@@ -663,7 +666,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.
+ 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 +926,29 @@ 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 \
+ and 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:
+ # Theoretically, if the machine_extruder_count is a setting formula (e.g. "=3"), this will produce a
+ # value error and the project file loading will load the settings in the first extruder only.
+ # This is not expected to happen though, since all machine definitions define the machine_extruder_count
+ # as an integer.
+ 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.