From 3395e194161c5034a0b7fe7a6e4b23c187ffefaf Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 24 Feb 2022 06:31:08 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Support=20two-digit=20flavors=20for?= =?UTF-8?q?=20G00=20G01=20G02=20G03=20(#4437)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support two-digit flavors for G00 G01 G02 G03 Many CAM processors generate two-digit movement commands. These are legal movement commands but the viewer is currently blind to them. (Evidently slicers never generate these, or this would have already been an issue.) This does not fully solve rendering of non-extruding toolpaths, but it enables a workaround in combination with M101 added to the preamble. * 🥅 Support G00, G01, G02, G03 in backend as well Co-authored-by: Gina Häußge --- src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js | 2 +- src/octoprint/util/gcodeInterpreter.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js b/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js index b75b7f15e..9660fb0ea 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js @@ -380,7 +380,7 @@ var doParse = function () { var log = false; - if (/^(?:G0|G1|G2|G3)(\.\d+)?\s/i.test(line)) { + if (/^(?:G0|G1|G2|G3|G00|G01|G02|G03)(\.\d+)?\s/i.test(line)) { args = line.split(/\s/); for (j = 0; j < args.length; j++) { diff --git a/src/octoprint/util/gcodeInterpreter.py b/src/octoprint/util/gcodeInterpreter.py index af30cb260..e573a5c0a 100644 --- a/src/octoprint/util/gcodeInterpreter.py +++ b/src/octoprint/util/gcodeInterpreter.py @@ -422,7 +422,7 @@ class gcode: tool = int(values["tool"]) # G codes - if gcode in ("G0", "G1"): # Move + if gcode in ("G0", "G1", "G00", "G01"): # Move x = getCodeFloat(line, "X") y = getCodeFloat(line, "Y") z = getCodeFloat(line, "Z") @@ -497,7 +497,7 @@ class gcode: if e: self._track_layer(pos) - if gcode in ("G2", "G3"): # Arc Move + if gcode in ("G2", "G3", "G02", "G03"): # Arc Move x = getCodeFloat(line, "X") y = getCodeFloat(line, "Y") z = getCodeFloat(line, "Z")