From 09dc2099569b65a82774a503b072ca812956acb1 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 3 Sep 2019 16:27:37 +0200 Subject: [PATCH 1/2] Fix regex in FlavorParser --- plugins/GCodeReader/FlavorParser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/GCodeReader/FlavorParser.py b/plugins/GCodeReader/FlavorParser.py index 5a57618983..ec0f5d3ea3 100644 --- a/plugins/GCodeReader/FlavorParser.py +++ b/plugins/GCodeReader/FlavorParser.py @@ -68,7 +68,7 @@ class FlavorParser: if n < 0: return None n += len(code) - pattern = re.compile("[;\s]") + pattern = re.compile("[;\\s]") match = pattern.search(line, n) m = match.start() if match is not None else -1 try: From 05247961459191ed28655a457e0e11f57f97733d Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 3 Sep 2019 20:01:10 +0200 Subject: [PATCH 2/2] Do not trigger slicing if there's no slicable object CURA-6604 --- plugins/CuraEngineBackend/CuraEngineBackend.py | 13 +++++++++++++ plugins/GCodeReader/FlavorParser.py | 5 ----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 994966f9b7..ddf7864bb3 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -543,6 +543,15 @@ class CuraEngineBackend(QObject, Backend): if error.getErrorCode() == Arcus.ErrorCode.BindFailedError and self._start_slice_job is not None: self._start_slice_job.setIsCancelled(False) + # Check if there's any slicable object in the scene. + def hasSlicableObject(self) -> bool: + has_slicable = False + for node in DepthFirstIterator(self._scene.getRoot()): + if node.callDecoration("isSliceable"): + has_slicable = True + break + return has_slicable + ## Remove old layer data (if any) def _clearLayerData(self, build_plate_numbers: Set = None) -> None: # Clear out any old gcode @@ -561,6 +570,10 @@ class CuraEngineBackend(QObject, Backend): ## Convenient function: mark everything to slice, emit state and clear layer data def needsSlicing(self) -> None: + # CURA-6604: If there's no slicable object, do not (try to) trigger slice, which will clear all the current + # gcode. This can break Gcode file loading if it tries to remove it afterwards. + if not self.hasSlicableObject(): + return self.determineAutoSlicing() self.stopSlicing() self.markSliceAll() diff --git a/plugins/GCodeReader/FlavorParser.py b/plugins/GCodeReader/FlavorParser.py index ec0f5d3ea3..89812e7202 100644 --- a/plugins/GCodeReader/FlavorParser.py +++ b/plugins/GCodeReader/FlavorParser.py @@ -476,11 +476,6 @@ class FlavorParser: machine_depth = global_stack.getProperty("machine_depth", "value") scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2)) - # Make sure that all seen extruders (if exist in the currently active machine) are enabled. - for extruder_nr in self._extruders_seen: - if str(extruder_nr) in global_stack.extruders: - CuraApplication.getInstance().getMachineManager().setExtruderEnabled(extruder_nr, True) - Logger.log("d", "GCode loading finished") if CuraApplication.getInstance().getPreferences().getValue("gcodereader/show_caution"):