From 4d3fc1d1c6b5b59cb241ce4d19133fe681f074ef Mon Sep 17 00:00:00 2001 From: shinmai <332256+shinmai@users.noreply.github.com> Date: Thu, 27 Jan 2022 16:21:21 +0200 Subject: [PATCH] experimental NONMESH z-hop fix setting added a setting that if enabled will attempt to remove X and Y components from NONMESH z-hop moves to avoid a slow travel move across the bed for details see https://github.com/Ultimaker/CuraEngine/issues/1369#issue-752831893 and https://github.com/paukstelis/Octoprint-Cancelobject/issues/62 --- MarlinCancelObject.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/MarlinCancelObject.py b/MarlinCancelObject.py index c13897c..426842f 100644 --- a/MarlinCancelObject.py +++ b/MarlinCancelObject.py @@ -16,10 +16,19 @@ def getSettingDataString(self): "key": "MarlinCancelObject", "metadata": {}, "version": 2, - "settings": {} + "settings": { + "nzf": + { + "label": "Experimental z-hop fix", + "description": "Attempt to remove X & Y components from Z-hop travel moves at the start of NONMESH segments to avoid slow movements across the bed after cancelled objects. Experimental, (p)review G-code before printing.", + "type": "bool", + "default_value": false + } + } }""" def execute(self, data): + nonmesh_zhop_fix = self.getSettingValueByKey("nzf") meshes=[] # array to hold meshnames for indexing for index, layer in enumerate(data): @@ -33,6 +42,18 @@ def execute(self, data): elif(meshname != "NONMESH"): meshes.append(meshname) idx=meshes.index(meshname) + else: + if(nonmesh_zhop_fix): + ol = lines[lindex+1] + nl = ol + if(ol[:2] == "G0" and " Z" in ol): + np=[] + for part in ol.split(" "): + if(part[0] == "X" or part[0] == "Y"): + continue + np.append(part) + nl=" ".join(np) + lines[lindex+1]=nl + " ;Attempted Z-hop fix" gcode_to_add = "\nM486 S%d ;Marlin Cancel Object support" % idx lines[lindex] = line + gcode_to_add data[index] = "\n".join(lines)