Skip to content

Commit

Permalink
experimental NONMESH z-hop fix setting
Browse files Browse the repository at this point in the history
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 Ultimaker/CuraEngine#1369 (comment) and paukstelis/Octoprint-Cancelobject#62
  • Loading branch information
shinmai committed Jan 27, 2022
1 parent e7e88c4 commit 4d3fc1d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion MarlinCancelObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit 4d3fc1d

Please sign in to comment.