I noticed in the .scpost in OnPenDown() that the pierce delay has been commented out, so effectively zero seconds. Thus if you change the Leadin Type to Ramp (in the Tool def) doesn’t that give you the pierce outcome that you want ? If so, then you can either adjust plungeRate to suit the ramp-down time you want.
Or consider using this OnPenDown() function substitute in your .scpost to calculate a Ramp down feedrate based on pierceDelay value.
function OnPenDown()
post.ModalText (" o<touchoff> call")
post.Eol()
post.ModalText (" G00")
post.ModalNumber (" Z", pierceHeight * scale, "0.0000")
post.Text ("\n M03 M07\n")
if pierceDelay > 0 then
if leadinType ~= 0 then --assume this is a Ramp style leadin
local rampDistance = math.abs(pierceHeight - cutHeight) * 1.414 -- 45deg ramp angle
local rampSpeed = rampDistance / pierceDelay * 60 --speed in units/minute
post.ModalNumber(" F", rampSpeed * scale, FRformat) --post Ramp speed to match pierceDelay
post.Text(" (overriding plungeRate of:")
-- now ModalNumber() here will nullify posting the same value in OnMove() or OnArc() later
post.ModalNumber(" F", plungeRate * scale, FRformat)
post.Text(" )\n")
else
post.NonModalNumber(" G04 P", pierceDelay, "0.##")
post.Eol()
end
end
end
FRformat = "0.##"
corrected: ModalNumber()…
Also, ModalNumber() function is handy so that the same exact text (including format of number) is not posted twice on consecutive calls. So I use it in this case to post the real plungeRate as a comment after overriding it with the calculated plungeRate (rampSpeed). In order for this to work as planned, the ModalNumber(" F", … ) stmts in OnMove() and OnArc() must be exactly the same formatting text, so change those stmts to use global var FRformat (feedrate format) so they are sure to match. Notice OnMove() and OnArc() had been using differing " F" word formatting.