From 4024391e754cf0e6808f7a41be668744c310bb42 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 12 Jun 2018 10:54:53 +0200 Subject: [PATCH 1/4] Fix quality profile update CURA-5453 ))Should take into account that the custom profile being updated may not have a quality_changes container for each stack, and Cura should create one if this is the case, so the user changes results can be stored. --- cura/Settings/ContainerManager.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index 0dc26207df..0f49791153 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -43,6 +43,7 @@ class ContainerManager(QObject): self._container_registry = ContainerRegistry.getInstance() self._machine_manager = self._application.getMachineManager() self._material_manager = self._application.getMaterialManager() + self._quality_manager = self._application.getQualityManager() self._container_name_filters = {} @pyqtSlot(str, str, result=str) @@ -307,15 +308,24 @@ class ContainerManager(QObject): # \return \type{bool} True if successful, False if not. @pyqtSlot(result = bool) def updateQualityChanges(self): - global_stack = Application.getInstance().getGlobalContainerStack() + global_stack = self._machine_manager.activeMachine if not global_stack: return False self._machine_manager.blurSettings.emit() - for stack in ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks(): + current_quality_changes_name = global_stack.qualityChanges.getName() + current_quality_type = global_stack.quality.getMetaDataEntry("quality_type") + extruder_stacks = list(global_stack.extruders.values()) + for stack in [global_stack] + extruder_stacks: # Find the quality_changes container for this stack and merge the contents of the top container into it. quality_changes = stack.qualityChanges + + if quality_changes.getId() == "empty_quality_changes": + quality_changes = self._quality_manager._createQualityChanges(current_quality_type, current_quality_changes_name, + global_stack, stack) + stack.qualityChanges = quality_changes + if not quality_changes or self._container_registry.isReadOnly(quality_changes.getId()): Logger.log("e", "Could not update quality of a nonexistant or read only quality profile in stack %s", stack.getId()) continue From 0c3528a613901bdf7043f89f5367c9153cc0c96d Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 13 Jun 2018 08:59:13 +0200 Subject: [PATCH 2/4] Fix missing new quality_changes CURA-5471 Otherwise they don't get saved... --- cura/Settings/ContainerManager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index 0f49791153..41c0235e25 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -324,6 +324,7 @@ class ContainerManager(QObject): if quality_changes.getId() == "empty_quality_changes": quality_changes = self._quality_manager._createQualityChanges(current_quality_type, current_quality_changes_name, global_stack, stack) + self._container_registry.addContainer(quality_changes) stack.qualityChanges = quality_changes if not quality_changes or self._container_registry.isReadOnly(quality_changes.getId()): From dfd20e1362a5fdf9ca72e4added8a228e0f5a483 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 13 Jun 2018 20:41:56 +0200 Subject: [PATCH 3/4] CURA-5335 Looking for the actual line number in the gcode when using the filament change script. --- .../scripts/FilamentChange.py | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/FilamentChange.py b/plugins/PostProcessingPlugin/scripts/FilamentChange.py index 07e887b082..1246bc8b43 100644 --- a/plugins/PostProcessingPlugin/scripts/FilamentChange.py +++ b/plugins/PostProcessingPlugin/scripts/FilamentChange.py @@ -1,9 +1,14 @@ # This PostProcessing Plugin script is released # under the terms of the AGPLv3 or higher +from typing import Optional, Tuple +from UM.Logger import Logger from ..Script import Script class FilamentChange(Script): + + _layer_keyword = ";LAYER:" + def __init__(self): super().__init__() @@ -64,11 +69,26 @@ class FilamentChange(Script): if len(layer_targets) > 0: for layer_num in layer_targets: layer_num = int(layer_num.strip()) - if layer_num < len(data): - layer = data[layer_num - 1] - lines = layer.split("\n") + if layer_num <= len(data): + index, layer_data = self._searchLayerData(data, layer_num - 1) + if layer_data is None: + Logger.log("e", "Could not found the layer") + continue + lines = layer_data.split("\n") lines.insert(2, color_change) final_line = "\n".join(lines) - data[layer_num - 1] = final_line + data[index] = final_line return data + + ## This method returns the data corresponding with the indicated layer number, looking in the gcode for + # the occurrence of this layer number. + def _searchLayerData(self, data: list, layer_num: int) -> Tuple[int, Optional[str]]: + for index, layer_data in enumerate(data): + first_line = layer_data.split("\n")[0] + # The first line should contain the layer number at the beginning. + if first_line[:len(self._layer_keyword)] == self._layer_keyword: + # If found the layer that we are looking for, then return the data + if first_line[len(self._layer_keyword):] == str(layer_num): + return index, layer_data + return 0, None \ No newline at end of file From 7b8242175100d042000030638b7f3226783c195c Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 14 Jun 2018 14:57:03 +0200 Subject: [PATCH 4/4] Don't disable E steppers when pausing There is no such command to disable only the E stepper drivers. This command M84 gets interpreted as disabling ALL stepper drivers, which on some printers would cause the print bed to fall down. --- plugins/PostProcessingPlugin/scripts/PauseAtHeight.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py index cb31514e9d..60babbae40 100644 --- a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py +++ b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py @@ -262,9 +262,6 @@ class PauseAtHeight(Script): if current_z < 15: prepend_gcode += self.putValue(G=1, Z=15, F=300) + "\n" - # Disable the E steppers - prepend_gcode += self.putValue(M=84, E=0) + "\n" - # Set extruder standby temperature prepend_gcode += self.putValue(M=104, S=standby_temperature) + "; standby temperature\n"