function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText('LinuxCNC PlasmaC post processor\n') ctrl:AppendText('\n') end -- Version 0.4 24 Aug 2019 -- based on LinuxCNC plasma.scpost function OnInit() post.SetCommentChars ('()', '[]') --ensure ( and ) characters do not appear in system text post.Text ('; ', fileName, ' ', date , ' ', time, '\n') post.Text ('; postprocessor: ', postName, '\n') post.Text (';\n') if(scale == metric) then minMove = '0.000001' post.Text (' G21 (units: metric)\n') --metric mode units = 'mm' precision = '0.000' scaler = 1 else post.Text (' G20 (units: inches)\n') --inch mode minMove = '0.00000004' units = '"' precision = '0.00000' scaler = 0.03937 end post.Text (' G40 (cutter compensation: off)\n') post.Text (' G90 (distance mode: absolute)\n') post.Text (' M52 P1 (adaptive feed: on)\n') if(scale == metric) then post.Text (' G64 P0.254 Q0.025 (tracking tolerances: 0.254mm)\n') else post.Text (' G64 P0.01 Q0.001 (tracking tolerances: 0.01")\n') end post.Text (' F#<_hal[plasmac.cut-feed-rate]>\n') post.Text (';\n') bigArcs = 1 --stitch arc segments together minArcSize = 0.05 --arcs smaller than this are converted to moves cut = 1 cutLength = 0 cutType = 'Torch' pierces = 0 spots = 0 scribes = 0 scribeLength = 0 oldTool = 0 end function OnComment() post.Text(' (',commentText,')\n') end function OnToolChange() if string.match (toolName, 'Air Scribe') then cutType = 'Air Scribe' spindleNum = 1 toolNum = 1 elseif string.match (toolName, 'Centre Spot') or string.match (toolName, 'Center Spot') then cutType = 'Centre Spot' spindleNum = 2 toolNum = 0 else cutType = 'Torch' spindleNum = 0 toolNum = 0 end if toolNum ~= oldTool then post.Text (' T', toolNum, ' M6 (', string.lower(cutType), ' tool)\n') post.Text (' G43 H0 (apply tool offsets)\n') if oldTool == 1 then post.Text (' M65 P0 (air scribe stop)\n') elseif cutType == 'Air Scribe' then post.Text (' M64 P0 (air scribe start)\n') end post.Text (';\n') oldTool = toolNum end post.Text (' M190 P' , tool,' (',string.lower(toolName), ' material)\n') post.Text (' M66 P3 L3 Q2 (wait for valid change)\n') post.Text (';\n') post.Text (' F#<_hal[plasmac.cut-feed-rate]>\n') post.Text (';\n') end function OnPenDown() post.Text ('\n M3 $', spindleNum, ' S1\n') if cutType == 'Air Scribe' then scribeLength = scribeLength + (entityLength * scaler) scribes = scribes + 1 elseif cutType == 'Centre Spot' then post.Text (' G91 (relative distance mode)\n') post.Text (' G1 X', minMove, '(tiny move)\n') post.Text (' G90 (absolute distance mode)\n') spots = spots + 1 else pierces = pierces + 1 end cutLength = cutLength + (entityLength * scaler) end function OnPenUp() post.Text (' M5\n') if string.match (toolName, 'Air Scribe') then post.Text (' G4 P1 (pause for scribe retract)\n') end post.Text (' (end ', string.lower(partName), ' #', cut, ' ', ' ', string.lower(cutType), ')\n') post.Text (';\n') cut = cut + 1 end function OnRapid() if math.abs(currentX - endX) < 0.000001 and math.abs(currentY - endY) < 0.000001 then return end post.Text (' (start ', string.lower(partName), ' #', cut, ' ', string.lower(cutType)) if cutType == 'Torch' or cutType == 'Air Scribe' then post.Text (', ') post.Number (entityLength * scaler, '0.00') post.Text (units) end post.Text (')\n') post.ModalText('') post.ModalText (' G0') post.NonModalNumber (' X', endX * scale, precision) post.NonModalNumber (' Y', endY * scale, precision) post.Eol() end function OnMove() if cutType == 'Torch' or cutType == 'Air Scribe' then if math.abs(currentX - endX) < 0.000001 and math.abs(currentY - endY) < 0.000001 then return end post.ModalText('') post.ModalText (' G1') post.NonModalNumber (' X', endX * scale, precision) post.NonModalNumber (' Y', endY * scale, precision) end post.Eol() end function OnArc() if cutType == 'Torch' or cutType == 'Air Scribe' then post.ModalText('') if(arcAngle <0) then post.ModalText (' G3') else post.ModalText (' G2') end post.NonModalNumber (' X', endX * scale, precision) post.NonModalNumber (' Y', endY * scale, precision) post.Text (' I') post.Number ((arcCentreX - currentX) * scale, precision) post.Text (' J') post.Number ((arcCentreY - currentY) * scale, precision) end post.Eol() end function OnFinish() if spots > 0 then post.Text('\n(Centre Spots = ', spots, ')\n') end if pierces > 0 then post.Text('\n(Pierces = ', pierces, ')\n') end if cutType == 'Torch' then post.Text('\n(Cuts = ', pierces , ' Length = ') post.Number (cutLength, '0.00') post.Text (units, ')\n') end if scribes > 0 then post.Text('\n(Air Scribes = ', pierces , ' Length = ') post.Number (scribeLength, '0.00') post.Text (units, ')\n') end post.Text (';\n') if toolNum > 0 then post.Text (' T0 M6 (select torch)\n') post.Text (' G43 H0 (apply tool offsets)\n') if cutType == 'Air Scribe' then post.Text (' M65 P0\n') end end post.Text (' G40 (cutter compensation: off)\n') post.Text (' G90 (distance mode: absolute)\n') post.Text (' M5 (plasmac stop)\n') post.Text (' M30 (end program)\n') end