From 910fd5c713bea921b1c08f6448ef5f547392e450 Mon Sep 17 00:00:00 2001 From: Brad Kartchner Date: Mon, 31 Oct 2022 21:56:24 -0600 Subject: [PATCH] Fix for issue #26 This fixes an error reported when saving a project with an AutoTower --- AutoTowersGenerator.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/AutoTowersGenerator.py b/AutoTowersGenerator.py index 001fea0..d247bde 100644 --- a/AutoTowersGenerator.py +++ b/AutoTowersGenerator.py @@ -549,15 +549,21 @@ def _postProcess(self, output_device)->None: # Retrieve the g-code for the current build plate active_build_plate_id = CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate gcode = gcode_dict[active_build_plate_id] - except TypeError: + except (TypeError, KeyError): # If there is no g-code for the current build plate, there's nothing more to do return - # Proceed if the g-code has not already been post-processed - if self._gcodeProcessedMarker not in gcode[0]: + try: + # Proceed if the g-code has not already been post-processed + if self._gcodeProcessedMarker not in gcode[0]: + + # Mark the g-code as having been post-processed + gcode[0] = gcode[0] + self._gcodeProcessedMarker + '\n' - # Mark the g-code as having been post-processed - gcode[0] = gcode[0] + self._gcodeProcessedMarker + '\n' + # Call the tower controller post-processing callback to modify the g-code + gcode = self._towerControllerPostProcessingCallback(gcode, self.displayOnLcdSetting) + except IndexError: + return - # Call the tower controller post-processing callback to modify the g-code - gcode = self._towerControllerPostProcessingCallback(gcode, self.displayOnLcdSetting) + Message('AutoTowersGenerator post-processing completed', title=self._pluginName).show() + \ No newline at end of file