From 8a65e29d2336e8a389482070eba2a0b423a4fdbf Mon Sep 17 00:00:00 2001 From: J-Dunn Date: Mon, 4 Aug 2025 17:57:03 +0200 Subject: [PATCH] CAM: revert grbl_post regression (#22569) * CAM: revert grbl_post regression I recently noticed a bug in grbl_proc post processor where it was not correctly setting OLD_Z if current machine_z is below G81 retract plane in R parmeter. On digging into my original commit is looks like the two lines which did this have been commented out. I can never find the Blame feature when I need so if someone else can find the culprit feel free. https://github.com/FreeCAD/FreeCAD/pull/9153/commits/2bd617a2b35540a6d41cb5519328fa1280116153 This PR simply reinstates the missing lines and adds a snippet of NIST as a comment block to prevent any over-zealous editing in the future. This regression means that drilling cycles start with z=clearance height instead of z=safe height leading to much costly air cutting. This similarly messes up the the retract plane for G98 leading to excessive machine time wasting and incorrect application of G98 returns. Indeed this regression was noticed because some were claiming the Safe height was redundant in drilling ops since it was never used. There is much discussion about all this at the moment which is being disrupted by people assuming the current broken paths are what FreeCAD is intended to do. Let's fix this ASAP, so we can stop this confusion and get discussions back to reality. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/CAM/Path/Post/scripts/grbl_post.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Mod/CAM/Path/Post/scripts/grbl_post.py b/src/Mod/CAM/Path/Post/scripts/grbl_post.py index 497da87a57..435e4482e5 100644 --- a/src/Mod/CAM/Path/Post/scripts/grbl_post.py +++ b/src/Mod/CAM/Path/Post/scripts/grbl_post.py @@ -597,8 +597,19 @@ 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 + # + # 3.5.20 Set Canned Cycle Return Level — G98 and G99 + # When the spindle retracts during canned cycles, there is a choice of how far it retracts: (1) retract + # perpendicular to the selected plane to the position indicated by the R word, or (2) retract + # perpendicular to the selected plane to the position that axis was in just before the canned cycle + # started (unless that position is lower than the position indicated by the R word, in which case use + # the R word position). + # To use option (1), program G99. To use option (2), program G98. Remember that the R word has + # different meanings in absolute distance mode and incremental distance mode. + # """ + + 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)