diff --git a/src/Mod/Path/App/PathSegmentWalker.cpp b/src/Mod/Path/App/PathSegmentWalker.cpp
index bbb171419b..b87aa34bbd 100644
--- a/src/Mod/Path/App/PathSegmentWalker.cpp
+++ b/src/Mod/Path/App/PathSegmentWalker.cpp
@@ -327,7 +327,12 @@ void PathSegmentWalker::walk(PathSegmentVisitor &cb, const Base::Vector3d &start
}
Base::Vector3d p3(next);
- p3.*pz = last.*pz;
+ if (retract_mode == 99) // G81,G83 need to account for G99 and retract to R only
+ p3.*pz = p2.*pz;
+ else
+ p3.*pz = last.*pz;
+
+
Base::Vector3d p3r = compensateRotation(p3, nrot, rotCenter);
plist.push_back(p1r);
@@ -353,6 +358,10 @@ void PathSegmentWalker::walk(PathSegmentVisitor &cb, const Base::Vector3d &start
pz = &Base::Vector3d::y;
} else if(name=="G19") {
pz = &Base::Vector3d::x;
+ } else if(name=="G98") {
+ retract_mode = 98;
+ } else if(name=="G99") {
+ retract_mode = 99;
}
}
}
diff --git a/src/Mod/Path/App/PathSegmentWalker.h b/src/Mod/Path/App/PathSegmentWalker.h
index 987969a22c..4da7668319 100644
--- a/src/Mod/Path/App/PathSegmentWalker.h
+++ b/src/Mod/Path/App/PathSegmentWalker.h
@@ -52,7 +52,7 @@ class PathExport PathSegmentVisitor
};
/**
- * PathSegmentWalker processes a path a splits all movement commands into straight segments and calls the
+ * PathSegmentWalker processes a path and splits all movement commands into straight segments and calls the
* appropriate member of the provided PathSegmentVisitor.
* All non-movement commands are processed accordingly if they affect the movement commands.
*/
@@ -66,6 +66,7 @@ public:
private:
const Toolpath &tp;
+ int retract_mode;
};
diff --git a/src/Mod/Path/Gui/Resources/panels/PageOpDrillingEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageOpDrillingEdit.ui
index 9011c261ee..945865971f 100644
--- a/src/Mod/Path/Gui/Resources/panels/PageOpDrillingEdit.ui
+++ b/src/Mod/Path/Gui/Resources/panels/PageOpDrillingEdit.ui
@@ -56,6 +56,16 @@
<html><head/><body><p>The tool and its settings to be used for this operation.</p></body></html>
+
+ -
+
+
+ <html><head/><body><p>Don't retract after every hole</p></body></html>
+
+
+ Keep Tool Down
+
+
diff --git a/src/Mod/Path/Path/Op/Drilling.py b/src/Mod/Path/Path/Op/Drilling.py
index 9cf906c583..3c89690ba7 100644
--- a/src/Mod/Path/Path/Op/Drilling.py
+++ b/src/Mod/Path/Path/Op/Drilling.py
@@ -65,7 +65,7 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
# Enumeration lists for App::PropertyEnumeration properties
enums = {
- "ReturnLevel": [
+ "RetractMode": [
(translate("Path_Drilling", "G98"), "G98"),
(translate("Path_Drilling", "G99"), "G99"),
], # How high to retract after a drilling move
@@ -151,10 +151,10 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
)
obj.addProperty(
"App::PropertyEnumeration",
- "ReturnLevel",
+ "RetractMode",
"Drill",
QT_TRANSLATE_NOOP(
- "App::Property", "Controls how tool retracts Default=G98"
+ "App::Property", "Controls tool retract height between holes in same op, Default=G98: safety height"
),
)
obj.addProperty(
@@ -163,15 +163,17 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
"Drill",
QT_TRANSLATE_NOOP(
"App::Property",
- "The height where feed starts and height during retract tool when path is finished while in a peck operation",
+ "The height where cutting feed rate starts and retract height for peck operation",
),
)
obj.addProperty(
"App::PropertyEnumeration",
"ExtraOffset",
"Drill",
- QT_TRANSLATE_NOOP("App::Property", "How far the drill depth is extended"),
+ QT_TRANSLATE_NOOP("App::Property", "How far the drilling depth is extended"),
)
+ obj.addProperty("App::PropertyBool", "KeepToolDown", "Drill",
+ QT_TRANSLATE_NOOP("App::Property", "Apply G99 retraction: only retract to RetractHeight between holes in this operation"))
for n in self.propertyEnumerations():
setattr(obj, n[0], n[1])
@@ -197,8 +199,29 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
elif obj.ExtraOffset == "2x Drill Tip":
endoffset = PathUtils.drillTipLength(self.tool) * 2
+ if not hasattr(obj,"KeepToolDown"):
+ obj.addProperty("App::PropertyBool", "KeepToolDown", "Drill",
+ QT_TRANSLATE_NOOP("App::Property", "Apply G99 retraction: only retract to RetractHeight between holes in this operation"))
+
+ if not hasattr(obj,"RetractMode"):
+ obj.addProperty(
+ "App::PropertyEnumeration",
+ "RetractMode",
+ "Drill",
+ QT_TRANSLATE_NOOP(
+ "App::Property",
+ "Controls tool retract height between holes in same op, Default=G98: safety height"
+ ),
+ )
+ # ensure new enums exist in old class
+ for n in self.propertyEnumerations():
+ setattr(obj, n[0], n[1])
+
+
# http://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g98-g99
- self.commandlist.append(Path.Command(obj.ReturnLevel))
+ if obj.KeepToolDown : obj.RetractMode = "G99"
+ else : obj.RetractMode = "G98"
+ self.commandlist.append(Path.Command(obj.RetractMode))
holes = PathUtils.sort_locations(holes, ["x", "y"])
@@ -224,13 +247,13 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
startPoint = edge.Vertexes[0].Point
- command = Path.Command("G0", {"X": startPoint.x, "Y": startPoint.y})
- self.commandlist.append(command)
- machine.addCommand(command)
+# command = Path.Command("G0", {"X": startPoint.x, "Y": startPoint.y})
+# self.commandlist.append(command)
+# machine.addCommand(command)
- command = Path.Command("G0", {"Z": startHeight})
- self.commandlist.append(command)
- machine.addCommand(command)
+# command = Path.Command("G0", {"Z": startHeight})
+# self.commandlist.append(command)
+# machine.addCommand(command)
# command = Path.Command("G1", {"Z": obj.StartDepth.Value})
# self.commandlist.append(command)
@@ -276,7 +299,8 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
def opSetDefaultValues(self, obj, job):
"""opSetDefaultValues(obj, job) ... set default value for RetractHeight"""
obj.ExtraOffset = "None"
-
+ obj.KeepToolDown = False # default to safest option: G98
+
if hasattr(job.SetupSheet, "RetractHeight"):
obj.RetractHeight = job.SetupSheet.RetractHeight
elif self.applyExpression(
@@ -305,9 +329,10 @@ def SetupProperties():
setup.append("DwellTime")
setup.append("DwellEnabled")
setup.append("AddTipLength")
- setup.append("ReturnLevel")
+ setup.append("RetractMode")
setup.append("ExtraOffset")
setup.append("RetractHeight")
+ setup.append("KeepToolDown")
return setup
diff --git a/src/Mod/Path/Path/Op/Gui/Drilling.py b/src/Mod/Path/Path/Op/Gui/Drilling.py
index 67b7a3b0d8..5502c17159 100644
--- a/src/Mod/Path/Path/Op/Gui/Drilling.py
+++ b/src/Mod/Path/Path/Op/Gui/Drilling.py
@@ -110,6 +110,8 @@ class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage):
self.peckRetractSpinBox.updateProperty()
self.dwellTimeSpinBox.updateProperty()
+ if obj.KeepToolDown != self.form.KeepToolDownEnabled.isChecked():
+ obj.KeepToolDown = self.form.KeepToolDownEnabled.isChecked()
if obj.DwellEnabled != self.form.dwellEnabled.isChecked():
obj.DwellEnabled = self.form.dwellEnabled.isChecked()
if obj.PeckEnabled != self.form.peckEnabled.isChecked():
@@ -127,6 +129,15 @@ class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage):
Path.Log.track()
self.updateQuantitySpinBoxes()
+ if not hasattr(obj,"KeepToolDown"):
+ obj.addProperty("App::PropertyBool", "KeepToolDown", "Drill",
+ QtCore.QT_TRANSLATE_NOOP("App::Property", "Apply G99 retraction: only retract to RetractHeight between holes in this operation"))
+
+ if obj.KeepToolDown:
+ self.form.KeepToolDownEnabled.setCheckState(QtCore.Qt.Checked)
+ else:
+ self.form.KeepToolDownEnabled.setCheckState(QtCore.Qt.Unchecked)
+
if obj.DwellEnabled:
self.form.dwellEnabled.setCheckState(QtCore.Qt.Checked)
else:
@@ -161,7 +172,8 @@ class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage):
signals.append(self.form.toolController.currentIndexChanged)
signals.append(self.form.coolantController.currentIndexChanged)
signals.append(self.form.ExtraOffset.currentIndexChanged)
-
+ signals.append(self.form.KeepToolDownEnabled.stateChanged)
+
return signals
def updateData(self, obj, prop):
diff --git a/src/Mod/Path/Path/Post/scripts/grbl_post.py b/src/Mod/Path/Path/Post/scripts/grbl_post.py
index 5c27cd5fcf..5e1f8a656f 100755
--- a/src/Mod/Path/Path/Post/scripts/grbl_post.py
+++ b/src/Mod/Path/Path/Post/scripts/grbl_post.py
@@ -602,8 +602,10 @@ def drill_translate(outstring, cmd, params):
global UNITS
global UNIT_FORMAT
global UNIT_SPEED_FORMAT
+
strFormat = "." + str(PRECISION) + "f"
+ strG0_Initial_Z=("G0 Z" + format(float(CURRENT_Z.getValueAs(UNIT_FORMAT)), strFormat) + "\n")
trBuff = ""
@@ -630,8 +632,8 @@ def drill_translate(outstring, cmd, params):
drill_Z += CURRENT_Z
RETRACT_Z += CURRENT_Z
- if DRILL_RETRACT_MODE == "G98" and CURRENT_Z >= RETRACT_Z:
- RETRACT_Z = CURRENT_Z
+# if DRILL_RETRACT_MODE == "G98" and CURRENT_Z >= RETRACT_Z:
+# RETRACT_Z = CURRENT_Z
# get the other parameters
drill_feedrate = Units.Quantity(params["F"], FreeCAD.Units.Velocity)
@@ -670,10 +672,10 @@ def drill_translate(outstring, cmd, params):
+ "\n"
)
if CURRENT_Z > RETRACT_Z:
- # NIST GCODE 3.5.16.1 Preliminary and In-Between Motion says G0 to RETRACT_Z. Here use G1 since retract height may be below surface !
+ # NIST GCODE 3.5.16.1 Preliminary and In-Between Motion says G0 to RETRACT_Z.
trBuff += (
linenumber()
- + "G1 Z"
+ + "G0 Z"
+ format(float(RETRACT_Z.getValueAs(UNIT_FORMAT)), strFormat)
+ strF_Feedrate
)
@@ -726,7 +728,11 @@ def drill_translate(outstring, cmd, params):
+ format(float(drill_Z.getValueAs(UNIT_FORMAT)), strFormat)
+ strF_Feedrate
)
- trBuff += linenumber() + strG0_RETRACT_Z
+
+ if DRILL_RETRACT_MODE == "G98" :
+ trBuff += (linenumber() + strG0_Initial_Z)
+ else:
+ trBuff += (linenumber() + strG0_RETRACT_Z)
break
except Exception as e: