From eb690a459f311779161c471f52877c6b07e16a4a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 6 May 2019 11:40:47 +0200 Subject: [PATCH 1/2] Fix boundingbox calculation of grouped groups Previously this would cause a crash because the bounding box of the outermost group would not take the bounding boxes of it's children's children into acocunt. CURA-6501 --- cura/Scene/CuraSceneNode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/Scene/CuraSceneNode.py b/cura/Scene/CuraSceneNode.py index 4fd8f2b983..1983bc6008 100644 --- a/cura/Scene/CuraSceneNode.py +++ b/cura/Scene/CuraSceneNode.py @@ -116,11 +116,11 @@ class CuraSceneNode(SceneNode): if self._mesh_data: self._aabb = self._mesh_data.getExtents(self.getWorldTransformation()) - for child in self._children: + for child in self.getAllChildren(): if child.callDecoration("isNonPrintingMesh"): # Non-printing-meshes inside a group should not affect push apart or drop to build plate continue - if not child._mesh_data: + if not child.getMeshData(): # Nodes without mesh data should not affect bounding boxes of their parents. continue if self._aabb is None: From c9e7f3a245898ce25f46f8ff5c5839b1c9d12d9b Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 6 May 2019 11:46:54 +0200 Subject: [PATCH 2/2] Fix finding layer numbers That seems to have been unreliable. Luckily the original g-code is already broken up in layers, so searching it is completely unnecessary. Hopefully resolves issue #5630. --- .../scripts/FilamentChange.py | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/FilamentChange.py b/plugins/PostProcessingPlugin/scripts/FilamentChange.py index 2acb01d5cc..7bece3d7e0 100644 --- a/plugins/PostProcessingPlugin/scripts/FilamentChange.py +++ b/plugins/PostProcessingPlugin/scripts/FilamentChange.py @@ -1,9 +1,7 @@ # Copyright (c) 2019 Ultimaker B.V. # The PostProcessingPlugin is released under the terms of the AGPLv3 or higher. -from typing import Optional, Tuple - -from UM.Logger import Logger +from typing import List from ..Script import Script class FilamentChange(Script): @@ -65,9 +63,10 @@ class FilamentChange(Script): } }""" - def execute(self, data: list): - - """data is a list. Each index contains a layer""" + ## Inserts the filament change g-code at specific layer numbers. + # \param data A list of layers of g-code. + # \return A similar list, with filament change commands inserted. + def execute(self, data: List[str]): layer_nums = self.getSettingValueByKey("layer_number") initial_retract = self.getSettingValueByKey("initial_retract") later_retract = self.getSettingValueByKey("later_retract") @@ -88,32 +87,13 @@ class FilamentChange(Script): if y_pos is not None: color_change = color_change + (" Y%.2f" % y_pos) - color_change = color_change + " ; Generated by FilamentChange plugin" + color_change = color_change + " ; Generated by FilamentChange plugin\n" layer_targets = layer_nums.split(",") if len(layer_targets) > 0: for layer_num in layer_targets: - layer_num = int(layer_num.strip()) + layer_num = int(layer_num.strip()) + 1 if layer_num <= len(data): - index, layer_data = self._searchLayerData(data, layer_num - 1) - if layer_data is None: - Logger.log("e", "Could not find the layer {layer_num}".format(layer_num = layer_num)) - continue - lines = layer_data.split("\n") - lines.insert(2, color_change) - final_line = "\n".join(lines) - data[index] = final_line + data[layer_num] = color_change + data[layer_num] - 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 + return data \ No newline at end of file