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. 

2bd617a2b3

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>
This commit is contained in:
J-Dunn
2025-08-04 17:57:03 +02:00
committed by GitHub
parent 39c902c616
commit 966cb36e9e

View File

@@ -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)