Torch height control during rapids

Hey Les, I’m pretty sure this is going to be another “not possible” question (I seem to be pretty good at those lately), but my goal is to only output a torch height off M code in the output if the next rapid distance is greater than some predetermined value. When we cut a lot of holes in sheets with the laser, it causes a lot of unnecessary movement and slowdowns. Problem is, at the time of OnPenUp(), I don’t know how to get the distance of the next rapid. endX and endY have not been updated at this point yet, so they are still the same as currentX and currentY. Is there anywhere to get the distance of the coming rapid from?

This is the code I currently have and found out the endX/Y are not updated:

if (highSpeed == 1) then
	post.NonModalNumber("End X = ", endX * scale, "0.000#") --for debugging purposes
	post.NonModalNumber("End Y = ", endY * scale, "0.000#") --for debugging purposes
	post.NonModalNumber("Current X = ", currentX * scale, "0.000#") --for debugging purposes
	post.NonModalNumber("Current Y = ", currentY * scale, "0.000#") --for debugging purposes
	if ((math.sqrt((endX - currentX)^2+(endY - currentY)^2)) * scale > heightOffTol) then
		post.Text ("M199\n")
	end
else
	post.Text ("M199\n")
end

highSpeed is a boolean flag and heightOffTol is a decimal, both are custom post variables in the popup dialog.

You would probably have to do the check in the OnRapid sub and output the M code before the rapid move.

You would probably have to do the check in the OnRapid sub and output the M code before the rapid move.

I swear sometimes I should just dye my hair blonde. It didn’t even remotely cross my mind to move that to the OnRapid function. Works like a champ, thanks!!

:laughing: