# How to adjust the torch height after cut

**URL:** <https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099>\
**Category:** Everything Plasma\
**Created:** [May 24, 2023, 8:11pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099 "2023-05-24T20:11:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [May 24, 2023, 8:11pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/1 "2023-05-24T20:11:40Z")

</div>

Question…after I cut something lets say a circle the plasma torch goes way up before another cut and this results into wasted time.

Where can I adjust this?  
see this video at 19:20 [4'x4' Cnc Plasma Table ~ Avid Pro Cnc Plasma Kit - YouTube](https://www.youtube.com/watch?v=me4FibYzfWE)

When the machine was new it behaved like the video.  
Thank you!

---

<div class="post-metadata">

**Author:** ![davidcnc](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidcnc](https://forum.avidcnc.com/u/davidcnc)\
**Post date:** [May 25, 2023, 8:03pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/2 "2023-05-25T20:03:20Z")

</div>

If you can post some sample gcode maybe we can take a look. The machine will only do what it’s told, so the code should reveal the move.

---

<div class="post-metadata">

**Author:** ![da-kengineer-meister](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@da-kengineer-meister](https://forum.avidcnc.com/u/da-kengineer-meister)\
**Post date:** [May 25, 2023, 8:27pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/3 "2023-05-25T20:27:43Z")

</div>

Agreed, David. On the system I run here, that is specified in the G-Code. Many pieces of SW ‘like’ to default it to a ‘safe-high’ to help people possibly breeze over a tip-up without snagging on it. but if cutting big parts that can’t tip-up, or just plowing in a bunch of holes before cutting the part free from the sheet, then a lower retract height is nice. I use different CAD here than most ppl, so I can’t comment to much on this one, but for me, the retract height is specified in the G-Code.

---

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [May 26, 2023, 2:11am UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/4 "2023-05-26T02:11:30Z")

</div>

Thank you for the reply.  
Here is a gcode for cuttign 3 circles.

Thank you!

N0010 (Filename: sq253piece.tap)  
N0020 (Post processor: Avid CNC Mach4.scpost v1.7)  
N0030 (Date: 19/02/2020)  
N0040 G21 (Units: Metric)  
N0050 G53 G90 G91.1 G40  
N0060 G64 (Constant Velocity Mode - normally used with Plasma)  
N0070 (Part: sq253piece)  
N0080 (Operation: Inside Offset, Default, T24: HTP Steel 3mm setting 11 THC100)  
N0090 m2020 (TARGET\_TIP\_VOLTS=100)  
N0100 m2020 (ESS\_DELAY\_AFTER\_ARC\_OKAY=0.2)  
N0110 G4 P0.1  
N0120 G00 X55.7568 Y45.9971  
N0130 G91 Z-0.1000  
N0140 G90  
N0150 (\<\<\<\<\<\<RESTART POINT #1\>\>\>\>\>\>)  
N0160 G31.0 Z-100 F500.0  
N0170 M3003 (Zero Z Axis - Mechanical)  
N0180 M3001 (Clear work shift)  
N0190 m2020 (HC\_WORK\_Z\_ZEROED=1)  
N0200 G4 P0.1  
N0210 G00 Z3.8100  
N0220 G4 P0.002  
N0230 M62P3  
N0240 Z3.8090  
N0250 G01 Z3.0480 F2540.0  
N0260 F2032.0  
N0270 M63P4 (_ **THC Inhibited, AD2** _)  
N0280 G02 X53.3184 Y43.5587 I-2.4384 J0.0000  
N0290 M62P4 (+++THC Allowed, AD2+++)  
N0300 G01 X45.3229  
N0310 M63P4 (_ **THC Inhibited, AD2** _)  
N0320 X38.9729 F1422.4  
N0330 Y49.9087  
N0340 M62P4 (+++THC Allowed, AD2+++)  
N0350 Y65.8997 F2032.0  
N0360 M63P4 (_ **THC Inhibited, AD2** _)  
N0370 Y72.2497 F1422.4  
N0380 X45.3229  
N0390 M62P4 (+++THC Allowed, AD2+++)  
N0400 X61.3139 F2032.0  
N0410 M63P4 (_ **THC Inhibited, AD2** _)  
N0420 X67.6639 F1422.4  
N0430 Y65.8997  
N0440 M62P4 (+++THC Allowed, AD2+++)  
N0450 Y49.9087 F2032.0  
N0460 M63P4 (_ **THC Inhibited, AD2** _)  
N0470 Y43.5587 F1422.4  
N0480 X61.3139  
N0490 M62P4 (+++THC Allowed, AD2+++)  
N0500 X53.3184 F2032.0  
N0510 M63P3  
N0520 G04 P0.2  
N0530 G91 G00 Z0.5000  
N0540 G90  
N0550 M3000 (Set work shift)  
N0560 G00 Z10.0000  
N0570 X81.9086 Y22.9295  
N0580 G91 Z-0.1000  
N0590 G90  
N0600 (\<\<\<\<\<\<RESTART POINT #2\>\>\>\>\>\>)  
N0610 G31.0 Z-100 F500.0  
N0620 M3003 (Zero Z Axis - Mechanical)  
N0630 M3001 (Clear work shift)  
N0640 m2020 (HC\_WORK\_Z\_ZEROED=1)  
N0650 G4 P0.1  
N0660 G00 Z3.8100  
N0670 G4 P0.002  
N0680 M62P3  
N0690 Z3.8090  
N0700 G01 Z3.0480 F2540.0  
N0710 F2032.0  
N0720 M63P4 (_ **THC Inhibited, AD2** _)  
N0730 G02 X79.4702 Y25.3679 I0.0000 J2.4384  
N0740 M62P4 (+++THC Allowed, AD2+++)  
N0750 G01 Y31.9788  
N0760 M63P4 (_ **THC Inhibited, AD2** _)  
N0770 Y38.3288 F1422.4  
N0780 X85.8202  
N0790 M62P4 (+++THC Allowed, AD2+++)  
N0800 X99.0422 F2032.0  
N0810 M63P4 (_ **THC Inhibited, AD2** _)  
N0820 X105.3922 F1422.4  
N0830 Y31.9788  
N0840 M62P4 (+++THC Allowed, AD2+++)  
N0850 Y18.7569 F2032.0  
N0860 M63P4 (_ **THC Inhibited, AD2** _)  
N0870 Y12.4069 F1422.4  
N0880 X99.0422  
N0890 M62P4 (+++THC Allowed, AD2+++)  
N0900 X85.8202 F2032.0  
N0910 M63P4 (_ **THC Inhibited, AD2** _)  
N0920 X79.4702 F1422.4  
N0930 Y18.7569  
N0940 M62P4 (+++THC Allowed, AD2+++)  
N0950 Y25.3679 F2032.0  
N0960 M63P3  
N0970 G04 P0.2  
N0980 G91 G00 Z0.5000  
N0990 G90  
N1000 M3000 (Set work shift)  
N1010 G00 Z10.0000  
N1020 X21.8504 Y14.9384  
N1030 G91 Z-0.1000  
N1040 G90  
N1050 (\<\<\<\<\<\<RESTART POINT #3\>\>\>\>\>\>)  
N1060 G31.0 Z-100 F500.0  
N1070 M3003 (Zero Z Axis - Mechanical)  
N1080 M3001 (Clear work shift)  
N1090 m2020 (HC\_WORK\_Z\_ZEROED=1)  
N1100 G4 P0.1  
N1110 G00 Z3.8100  
N1120 G4 P0.002  
N1130 M62P3  
N1140 Z3.8090  
N1150 G01 Z3.0480 F2540.0  
N1160 F2032.0  
N1170 M63P4 (_ **THC Inhibited, AD2** _)  
N1180 G02 X24.2888 Y12.5000 I-0.0000 J-2.4384  
N1190 M62P4 (+++THC Allowed, AD2+++)  
N1200 G01 Y7.0612  
N1210 M63P4 (_ **THC Inhibited, AD2** _)  
N1220 Y0.7112 F1422.4  
N1230 X17.9388  
N1240 M62P4 (+++THC Allowed, AD2+++)  
N1250 X7.0612 F2032.0  
N1260 M63P4 (_ **THC Inhibited, AD2** _)  
N1270 X0.7112 F1422.4  
N1280 Y7.0612  
N1290 M62P4 (+++THC Allowed, AD2+++)  
N1300 Y17.9388 F2032.0  
N1310 M63P4 (_ **THC Inhibited, AD2** _)  
N1320 Y24.2888 F1422.4  
N1330 X7.0612  
N1340 M62P4 (+++THC Allowed, AD2+++)  
N1350 X17.9388 F2032.0  
N1360 M63P4 (_ **THC Inhibited, AD2** _)  
N1370 X24.2888 F1422.4  
N1380 Y17.9388  
N1390 M62P4 (+++THC Allowed, AD2+++)  
N1400 Y12.5000 F2032.0  
N1410 M63P3  
N1420 G04 P0.2  
N1430 G91 G00 Z0.5000  
N1440 G90  
N1450 M3000 (Set work shift)  
N1460 G00 Z10.0000  
N1470 Z10.1000  
N1480 M30  
%

---

<div class="post-metadata">

**Author:** ![da-kengineer-meister](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@da-kengineer-meister](https://forum.avidcnc.com/u/da-kengineer-meister)\
**Post date:** [May 26, 2023, 9:03am UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/5 "2023-05-26T09:03:08Z")

</div>

> [@ROTM](#):
>
> N0210 G00 Z3.8100  
> …  
> N1110 G00 Z3.8100  
> …  
> etc…

There a a good number of lines like the one above, where ‘Z’ is being retracted almost 3.81inches. Likely the CAD system used to generate the G-Code is putting those in there.

---

<div class="post-metadata">

**Author:** ![davidcnc](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidcnc](https://forum.avidcnc.com/u/davidcnc)\
**Post date:** [May 26, 2023, 2:29pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/6 "2023-05-26T14:29:38Z")

</div>

Hmm well it’s metric so those should only result in, what’s that, about 1/8"? I think I’m interpreting that right. There’s a final retract to Z10 but that’s only roughly 3/8". I don’t see anything like G53 Zxx, G28 or a high Z retract that would be commanding the move.

The way I read it, it should finish, pause 0.2s, rapid up 0.5mm, rapid up to 10mm, then rapid up another 0.1mm to a final 10.1mm above the material surface and rewind.

---

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [May 26, 2023, 5:56pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/7 "2023-05-26T17:56:19Z")

</div>

The new Avid Mach4 version has an option to set the z height.  
and this was the issue [Mach4 Plasma Users Guide - CNC Software (avidcnc.com)](https://www.avidcnc.com/support/instructions/software/plasmaUsersGuide/)

I still have another error but waiting on Avid respone.  
The only next step I can think of is to replace the computer. 😕

---

<div class="post-metadata">

**Author:** ![da-kengineer-meister](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@da-kengineer-meister](https://forum.avidcnc.com/u/da-kengineer-meister)\
**Post date:** [May 26, 2023, 6:53pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/8 "2023-05-26T18:53:20Z")

</div>

Awesome, sounds like the timing on that new version is great! In the system here (CAD+GCode) the tool retracts are hard coded in the G-Code as explicit moves so they are super easy eto spot, not return to plane or any other of the many ways it can be done. Glad there is a quick path back to getting things working for you! 😃

---

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [April 17, 2024, 3:25am UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/9 "2024-04-17T03:25:47Z")

</div>

Good day… still a question on this topic.  
After cutting the z retract all the way up…on the router side it retracts 0.8"  
Where can I set the plasma to do the same?

## Thank you!

Nevermind… found it in sheetcam parking options.

---

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [May 1, 2024, 3:51pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/10 "2024-05-01T15:51:17Z")

</div>

Good day Back at it again.  
The Avid Mach4 button set the z height between cuts…but at the end the z will rise all the way up and it is wasted time.  
It seems the parking settings work for the x and y but the z gets bypassed by the post processor. \>End program Z park

In this youtube video this guy Avid plasma behaves like it should  
[4’x4’ Cnc Plasma Table ~ Avid Pro Cnc Plasma Kit (youtube.com)](https://www.youtube.com/watch?v=me4FibYzfWE&t=1196s)

but mine raise all the way up…almost to the homing z position.

So the question is of the 2 options how would I change this in the postprocessor not to rise all the way up, or let sheetcam decide on the parking position of the z? Thank you!  
I can’t program to save my life but trying here 😕

++++++++++++++++++++++++++++++++++++++++++++++++++++  
– Post processor version  
local postVersion = “1.9.1”  
local minToolsetVersion = “v1.7.3.7”  
local minMach4Version = “2.4.0”

– Custom post option defaults (mm, mm/min)  
local refDistanceDefault = 0  
local refFeedDefault = 500  
local slowProbeDefault = 6.35  
local touchOffTypeDefault = 0  
local endZparkDefault = -12.7

– AntiDive defaults (fallback if not in gcode)  
local targetTipVoltDefault = 115  
local AD1Default = 0.8

–Torch on and off codes. CHANGE THE P# to match your OUTPUT#!!! P3 is for Output#3, P27 is for Output#27, etc…  
torchOnCode = " M62P3"  
torchOffCode = " M63P3"

–Code to use when referencing  
refCode=" G31.0 Z-100"

function OnAbout(event)  
ctrl = event:GetTextCtrl()  
ctrl:AppendText(“TMC3in1 and Ethernet SmoothStepper in Mach4\n”)  
ctrl:AppendText(“\n”)  
ctrl:AppendText(string.format(“Avid CNC post processor version: %s\n”, postVersion))  
ctrl:AppendText(string.format(“Minimum Avid CNC Mach4 profile version: %s\n”, minMach4Version))  
ctrl:AppendText(string.format(“Minimum AvidCNC Toolset version: %s\n”, minToolsetVersion))  
ctrl:AppendText(“\n”)  
ctrl:AppendText(“Post variables:\n”)  
ctrl:AppendText(“refDistance - set the distance between each reference\n”)  
ctrl:AppendText(“refFeed - set the feed rate when referencing\n”)  
ctrl:AppendText(“endZpark - set the machine coordinate end point of a final rapid clearance move\n”)  
ctrl:AppendText(“slowProbe - set the Z height in Work coordinates where the reference feed rate starts\n”)

local window = ctrl:GetParent()  
local btn = wx.wxButton(window, wx.wxID\_ANY, “Set custom post options”)  
btn:Connect(wx.wxID\_ANY, wx.wxEVT\_COMMAND\_BUTTON\_CLICKED, OnButton)  
ctrl:GetContainingSizer():Insert(2, btn, 0, wx.wxALL, 5)  
end

function OnButton(evt)  
post.ShowCustomOptions(“Post settings”)  
end

–These appear in Options-Machine-\>Post processor-\>Set custom post options  
–see the docs for ‘DefineCustomOption’ to see what these values mean.

varDefs={  
–The modes used below are 0, 1, 2 and 3:

– 0 = Appears in ‘Options-Machine-\>Post processor-\>Set custom post options’ and in a ‘Set post processor variable’ operation  
– 1 = Appears in tool definition  
– 2 = Appears in ‘Options-Machine-\>Post processor-\>Set custom post options’ and in a ‘Set post processor variable’ operation  
– 3 = Appears in ‘Options-Machine-\>Post processor-\>Set custom post options’ only

– Description, ,variable name , units ,min ,max ,default ,scale, mode  
{“Target Tip Volts” ,“TARGET\_TIP\_VOLTS” , sc.unit2DECPLACE ,50 ,250 , targetTipVoltDefault ,1 ,1},  
–{“Target Band Volts” ,“TARGET\_BAND\_VOLTS” , sc.unit2DECPLACE ,0 ,20 ,1.5 ,1 ,1},  
–{“Linear Response Band Above Target Volts” ,“LINEAR\_RESPONSE\_BAND\_VOLTS\_ABOVE”, sc.unit2DECPLACE ,0 ,100 ,25.25 ,1 ,1},  
–{“Linear Response Band Below Target Volts” ,“LINEAR\_RESPONSE\_BAND\_VOLTS\_BELOW”, sc.unit2DECPLACE ,0 ,100 ,15.2 ,1 ,1},  
–{“ESS Delay after Arc OK, in Seconds” ,“ESS\_DELAY\_AFTER\_ARC\_OKAY” , sc.unit2DECPLACE ,0 ,10 ,0.005 ,1 ,1},

– Description, , variable name , units ,min ,max ,default ,scale, mode  
{“Distance between references” , “refDistance” , sc.unitLINEAR ,0 ,1e17 , refDistanceDefault ,1 ,2},  
{“Reference feed rate” , “refFeed” , sc.unitFEED ,0 ,1e17 ,refFeedDefault ,1 ,2},  
{“Slow Probe Height” , “slowProbe” , sc.unitLINEAR ,0 ,1e17 , slowProbeDefault ,1 ,2},  
–{“Extra delay for first pierce” , “firstDelay” , sc.unitTIME ,0 ,1e17 ,0 ,1 ,3},  
–{“Mechanical Switch Offset” , “switchoffset” , sc.unitLINEAR ,0 ,1e17 ,2.21 ,1 ,2},  
{"Touchoff, 1 = Mechanical 0 = Ohmic " ,“touchOffType” , sc.unit0DECPLACE ,0 ,1 , touchOffTypeDefault ,1 ,2},  
{“End program Z park (machine coordinates)” ,“endZpark” , sc.unitLINEAR ,-500 ,0 , endZparkDefault ,1 ,2},

– Description, , variable name , units ,min ,max ,default ,scale, mode  
–{“ESS HC Limit Z Max” , “HC\_Z\_MAX\_VALUE” , sc.unitLINEAR ,-1e17 ,1e17 ,25.4 ,1 ,0},  
–{“ESS HC Limit Z Min” , “HC\_Z\_MIN\_VALUE” , sc.unitLINEAR ,-1e17 ,1e17 ,-2.54 ,1 ,0},

– Description, , variable name , units ,min ,max ,default ,scale, mode  
–{“AD1 Delay after Arc OK ENABLE” , “AD1\_DELAY\_ENABLED” , sc.unit0DECPLACE ,0 ,1 , 1 ,1 ,0},  
{“AD1 Delay after Arc OK Time” , “AD1\_DELAY\_VALUE” , sc.unitTIME ,0 ,10 , AD1Default ,1 ,1},  
–{“AD2 M62/M63, 1 = ENABLE 0 = DISABLE” ,“AD2\_M62\_M63\_ENABLED”, sc.unit0DECPLACE ,0 ,1 ,0 ,1 ,0},  
–{“AD3 Velocity ENABLE” ,“AD3\_VELOCITY\_ENABLED”, sc.unit0DECPLACE ,0 ,1 ,1 ,1 ,0},  
–{“AD3 Velocity Percent” ,“AD3\_VELOCITY\_PERCENT”,sc.unitPERCENT ,0 ,1 ,0.95 ,100 ,0},  
–{“AD4 Voltage ENABLE” ,“VOLTAGE\_AD\_ENABLED”, sc.unit0DECPLACE ,0 ,1 ,0 ,1 ,0},  
–{“AD4 ATV Sample Buffer” ,“VOLTAGE\_AD\_ATV\_BUFFER\_SIZE” , sc.unitTIME ,0.001,0.8 ,0.8 ,1000 ,0},  
–{“AD4 Voltage Precondition Percent” ,“VOLTAGE\_AD\_PRECONDITION\_WINDOW\_PERCENT”, sc.unitPERCENT ,0 ,10 ,0.0401 ,100 ,0},  
–{“ADR Voltage Throttling Percent” ,“VOLTAGE\_AD\_AD4\_THC\_THROTTLING\_PERCENT”, sc.unitPERCENT ,0 ,10 ,0 ,100 ,0},  
–{“AD5 Inhibit Above Current Tip Volts” ," VOLTAGE\_AD\_AD5\_ATV\_PERCENT\_ABOVE\_CURRENT\_TIP\_VOLTS" , sc.unit2DECPLACE ,0 ,50 ,15.1 ,1 ,0},  
–{“AD6 Inhibit Below Current Tip Volts” ,“VOLTAGE\_AD\_AD6\_ATV\_PERCENT\_BELOW\_CURRENT\_TIP\_VOLTS” , sc.unit2DECPLACE ,0 ,50 ,14.4 ,1 ,0},

}

for i, def in ipairs(varDefs) do  
local mode = def[8]  
if(mode == 1) then  
post.DefineCustomToolParam(“PlasmaTool”, def[1],def[2],def[3],def[6],def[4],def[5])  
else  
post.DefineCustomOption(def[1],def[2],def[3],def[4],def[5],def[6])  
if mode \< 3 then  
post.DefineVariable(def[2],def[3],def[4],def[5])  
end  
end  
end

varVals={}  
function CheckOptions()  
local found = false;  
for i, def in ipairs(varDefs) do  
local varName = def[2]  
if(\_G[varName] ~= varVals[varName] and def[8] \< 2) then  
varVals[varName] = \_G[varName]  
found = true  
local mult = def[7]  
if(def[3] == sc.unitLINEAR) then mult = mult \* scale end  
post.Text(" m2020 (“, varName,”=“)  
post.Number(\_G[varName] \* mult, “0.##”)  
post.Text(”)\n");  
end  
end

– Pierce delay  
if (lastPierceDelay ~= pierceDelay) then  
lastPierceDelay = pierceDelay  
post.Text(" m2020 (ESS\_DELAY\_AFTER\_ARC\_OKAY=", pierceDelay, “)\n”)  
found = true  
end

if found then  
post.Text(" G4 P0.1\n")  
end  
end

function OnInit()  
varVals={}  
offX = 0  
offY = 0  
offZ = 0  
restartCount = 1  
lastPierceDelay = pierceDelay  
wasReferenced = false  
–post.TextDirect(“%\n”)

– Radial reference distance check variables  
refX = 0  
refY = 0

post.SetCommentChars (“()”, “”) --make sure ( and ) characters do not appear in system text  
post.Text (" (Filename: “, fileName, “)\n”)  
post.Text (” (Post processor: “, postName, " v”, postVersion, “)\n”)  
post.Text (" (Date: “, date, “)\n”)  
if(scale == metric) then  
post.Text (” G21 (Units: Metric)\n") --metric mode  
else  
post.Text (" G20 (Units: Inches)\n") --inch mode  
end  
post.Text (" G53 G90 G91.1 G40\n")

– post.Text (" G61 (Exact Stop Mode - NOT normally used with Plasma)\n")  
post.Text (" G64 (Constant Velocity Mode - normally used with Plasma)\n")

minArcSize = 0.2 --arcs smaller than this are converted to moves  
firstRef = true  
currentZAxis = “Z”

CheckOptions()  
end

function OnNewLine()  
post.Text (“N”)  
post.Number (lineNumber, “0000”)  
lineNumber = lineNumber + 10  
end

function OnFinish()  
endZ = safeZ + 0.1 --force a Z move to guarantee turn torch off  
OnRapid()  
post.ModalText(" G53")  
post.ModalText(" G00")  
post.ModalNumber(" Z", endZpark \* scale, “0.0000”) --lifts to the specified machine coordinate  
post.Eol()  
post.ModalText(" G90")  
post.Eol()  
post.Text(" M30\n")  
post.TextDirect(“%\n”)  
end

function OnRapid()  
if (endX \> 1e17 and endY \> 1e17) then return end  
local len = math.hypot((endX + offX)-currentX , (endY + offY)-currentY)  
if (len \< 1e-17) and (((endZ + offZ)-currentZ) \< 1e-17) then return end

post.ModalText (" G00")  
post.ModalNumber (" X", (endX + offX) \* scale, “0.0000”)  
post.ModalNumber (" Y", (endY + offY) \* scale, “0.0000”)

---------normal Z rapid moves removed. All upward rapid moves will be handled by M3000

post.Eol()  
end

function OnMove()  
local len = math.hypot(endX - currentX , endY - currentY)

– always clearing work shift at final cut height  
if (not wasReferenced) then  
post.ModalText(" G01")  
post.ModalNumber(" " … currentZAxis, (cutHeight + offZ) \* scale, “0.0000”)  
post.ModalNumber (" F", feedRate \* scale, “0.0###”)  
post.Eol()  
post.Text(" M3001 (Clear work shift)\n")  
wasReferenced = true  
end

post.ModalText (" G01")  
post.ModalNumber (" X", (endX + offX) \* scale, “0.0000”)  
post.ModalNumber (" Y", (endY + offY) \* scale, “0.0000”)  
if(offZ) then  
post.ModalNumber (" " … currentZAxis, (endZ + offZ) \* scale, “0.0000”)  
end  
post.ModalNumber (" F", feedRate \* scale, “0.0###”)  
post.Eol()

end

function OnArc()  
local radius = math.hypot(currentX - arcCentreX, currentY - arcCentreY)

if(arcAngle \<0) then  
post.ModalText (" G03")  
else  
post.ModalText (" G02")  
end  
post.ModalNumber (" X", (endX + offX) \* scale, “0.0000”)  
post.ModalNumber (" Y", (endY + offY) \* scale, “0.0000”)  
if(offZ) then  
post.ModalNumber (" " … currentZAxis, (endZ + offZ) \* scale, “0.0000”)  
end  
post.Text (" I")  
post.Number ((arcCentreX - currentX) \* scale, “0.0000”)  
post.Text (" J")  
post.Number ((arcCentreY - currentY) \* scale, “0.0000”)  
post.ModalNumber (" F", feedRate \* scale, “0.0###”)  
post.Eol()  
end

function OnPenDown()  
wasReferenced = false

– Small incremental move to execute code snippets  
post.ModalText(" G00")  
post.ModalText(" G91")  
post.Text(" Z")  
post.Number (-(scale)\*.1 , “0.0000”) --force a small move  
post.Eol()  
post.ModalText(" G90")  
post.Eol()

– Restart point  
post.Text(string.format(" (\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<RESTART POINT #%s\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>)\n", restartCount))  
restartCount = restartCount + 1

– Reference  
if firstRef then  
Reference()  
else  
– Ref distance check.  
local refCurrentDistance = math.hypot((currentX - refX), (currentY - refY))  
if (refCurrentDistance \> refDistance) then  
Reference()  
end  
end

post.ModalText (" G00")  
post.Text(" Z")  
post.Number (pierceHeight \* scale, “0.0000”)  
post.Eol()

if (preheat \> 0) then  
post.Text (“\n G04 P”)  
post.Number (preheat,“0.###”)  
post.Eol()  
end  
post.Text (“\n G4 P0.002\n”, torchOnCode, " \n")  
post.ModalText (" G00")  
post.Text(" Z")  
post.Number ((pierceHeight \* scale) - 0.001 , “0.0000”) --force a small move  
post.Eol()

end

function Reference()  
–check for first probe in this function and do a slow probe on first probe  
if firstRef then --this section just does a full slow probe  
post.ModalText(refCode)  
post.ModalNumber (" F", refFeed \* scale, “0.0###”)  
post.Eol()  
else --this section moves rapid to slowProbe Z height then probes slow  
post.Text(" G00 Z")  
post.Number(slowProbe\*scale, “0.0000”)  
post.Eol()  
post.ModalText(refCode)  
post.ModalNumber (" F", refFeed \* scale, “0.0###”)  
post.Eol()  
end

firstRef = false  
wasReferenced = true  
refX = currentX  
refY = currentY

```
  -- Restart point moved to OnPenDown() so that every start is a restart point

```

if (touchOffType == 1) then  
– Mechanical touch off  
post.Text(" M3003 (Zero Z Axis - Mechanical)\n")  
else  
– Ohmic touch off  
post.Text(" M3002 (Zero Z Axis - Ohmic)\n")  
end

– Macro to clear work shift that had accounted  
– for THC movement that wasn’t synced to Mach4.  
– After a probe move the THC movement is synced  
– back to Mach4.  
post.Text(" M3001 (Clear work shift)\n")

– Tell the ESS we zero’d the Z so it can update  
– for min/max Z (if enabled in ESS).  
post.Text(" m2020 (HC\_WORK\_Z\_ZEROED=1)\n G4 P0.1\n")

end

function OnPenUp()  
post.Text (torchOffCode, “\n”)

if (endDelay \> 0) then  
post.Text (" G04 P")  
post.Number (endDelay,“0.###”)  
post.Eol()  
end

– Motion after torchOffCode  
post.ModalText(" G91")  
post.ModalText(" G00")  
post.ModalNumber(" Z", 0.5 \* scale, “0.0000”)  
post.Eol()  
post.ModalText(" G90")  
post.Eol()

– Macro to account for possible THC movement  
– that has not been synced back to Mach4.  
post.Text(" M3000 (Set work shift)\n")  
end

function OnNewOperation()  
post.Text (" (Operation: ", operationName, “)\n”)  
CheckOptions()  
end

function OnToolChange()  
CheckOptions()  
end

function OnNewPart()  
post.Text(" (Part: “,partName,”)\n");  
end

function OnComment()  
post.Text(" (“,commentText,”)\n")  
end  
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

---

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [May 2, 2024, 5:54pm UTC](https://forum.avidcnc.com/t/how-to-adjust-the-torch-height-after-cut/2099/11 "2024-05-02T17:54:31Z")

</div>

Nevermind there is a setting in sheetcam at set custom post option.

Tnx.
