diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 12e8ea2590..a5390a96a9 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -927,6 +927,8 @@ class MachineManager(QObject): ExtruderManager.getInstance().extrudersChanged.emit(self._global_container_stack.getId()) # Make sure the front end reflects changes self.forceUpdateAllSettings() + # Also trigger the build plate compatibility to update + self.activeMaterialChanged.emit() def _onMachineNameChanged(self): self.globalContainerChanged.emit() @@ -1024,17 +1026,25 @@ class MachineManager(QObject): self.activeQualityGroupChanged.emit() self.activeQualityChangesGroupChanged.emit() + def _fixQualityChangesGroupToNotSupported(self, quality_changes_group): + nodes = [quality_changes_group.node_for_global] + list(quality_changes_group.nodes_for_extruders.values()) + containers = [n.getContainer() for n in nodes if n is not None] + for container in containers: + container.setMetaDataEntry("quality_type", "not_supported") + quality_changes_group.quality_type = "not_supported" + def _setQualityChangesGroup(self, quality_changes_group): if self._global_container_stack is None: return #Can't change that. quality_type = quality_changes_group.quality_type # A custom quality can be created based on "not supported". # In that case, do not set quality containers to empty. - if quality_type == "not_supported": - quality_group = None - else: + quality_group = None + if quality_type != "not_supported": quality_group_dict = self._quality_manager.getQualityGroups(self._global_container_stack) - quality_group = quality_group_dict[quality_type] + quality_group = quality_group_dict.get(quality_type) + if quality_group is None: + self._fixQualityChangesGroupToNotSupported(quality_changes_group) quality_changes_container = self._empty_quality_changes_container quality_container = self._empty_quality_container diff --git a/plugins/GCodeWriter/GCodeWriter.py b/plugins/GCodeWriter/GCodeWriter.py index ccd881afdc..f25e249db1 100644 --- a/plugins/GCodeWriter/GCodeWriter.py +++ b/plugins/GCodeWriter/GCodeWriter.py @@ -42,6 +42,8 @@ class GCodeWriter(MeshWriter): re.escape("\r"): "\\r" # Carriage return. Windows users may need this for visualisation in their editors. } + _setting_keyword = ";SETTING_" + def __init__(self): super().__init__() @@ -69,11 +71,15 @@ class GCodeWriter(MeshWriter): return False gcode_list = gcode_dict.get(active_build_plate, None) if gcode_list is not None: + has_settings = False for gcode in gcode_list: + if gcode[:len(self._setting_keyword)] == self._setting_keyword: + has_settings = True stream.write(gcode) # Serialise the current container stack and put it at the end of the file. - settings = self._serialiseSettings(Application.getInstance().getGlobalContainerStack()) - stream.write(settings) + if not has_settings: + settings = self._serialiseSettings(Application.getInstance().getGlobalContainerStack()) + stream.write(settings) return True return False @@ -108,7 +114,7 @@ class GCodeWriter(MeshWriter): container_registry = self._application.getContainerRegistry() quality_manager = self._application.getQualityManager() - prefix = ";SETTING_" + str(GCodeWriter.version) + " " # The prefix to put before each line. + prefix = self._setting_keyword + str(GCodeWriter.version) + " " # The prefix to put before each line. prefix_length = len(prefix) quality_type = stack.quality.getMetaDataEntry("quality_type") diff --git a/resources/qml/Menus/ProfileMenu.qml b/resources/qml/Menus/ProfileMenu.qml index 5b9a5a3b73..ffd3c556b6 100644 --- a/resources/qml/Menus/ProfileMenu.qml +++ b/resources/qml/Menus/ProfileMenu.qml @@ -51,8 +51,7 @@ Menu MenuItem { text: model.name - checkable: model.available - enabled: model.available + checkable: true checked: Cura.MachineManager.activeQualityOrQualityChangesName == model.name exclusiveGroup: group onTriggered: Cura.MachineManager.setQualityChangesGroup(model.quality_changes_group)