From 874f4cdd1573974ca554e6673f99f9b98a32e040 Mon Sep 17 00:00:00 2001 From: J-Dunn Date: Thu, 6 Apr 2023 12:00:22 +0200 Subject: [PATCH 1/5] Path: G99 aware, ui checkbox --- .../Path/Gui/Resources/panels/PageOpDrillingEdit.ui | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 + + From 2960e0e9342030fde1b1a1cf4876267ea73ddeff Mon Sep 17 00:00:00 2001 From: J-Dunn Date: Thu, 6 Apr 2023 12:02:48 +0200 Subject: [PATCH 2/5] Path: make 3Dview G99 aware --- src/Mod/Path/App/PathSegmentWalker.cpp | 11 ++++++++++- src/Mod/Path/App/PathSegmentWalker.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) 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; }; From 98928f7c23a5a66d5765598f7fc4fd895b79245e Mon Sep 17 00:00:00 2001 From: J-Dunn Date: Thu, 6 Apr 2023 12:05:27 +0200 Subject: [PATCH 3/5] Path: G99 aware via keeptooldown --- src/Mod/Path/Path/Op/Gui/Drilling.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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): From 0dcc5b881653bcc81bbe0f3457b561401f752d96 Mon Sep 17 00:00:00 2001 From: J-Dunn Date: Thu, 6 Apr 2023 12:06:14 +0200 Subject: [PATCH 4/5] Path: G99 aware via keeptooldown --- src/Mod/Path/Path/Op/Drilling.py | 53 +++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 14 deletions(-) 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 From 7984dd6ab7992c22273a02f473cbe3f6c24fb8c9 Mon Sep 17 00:00:00 2001 From: J-Dunn Date: Thu, 6 Apr 2023 12:08:32 +0200 Subject: [PATCH 5/5] Path: make grbl_post NIST compliant on G98/G99 --- src/Mod/Path/Path/Post/scripts/grbl_post.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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: