function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText('LinuxCNC PlasmaC post processor\n') ctrl:AppendText('\n') end -- Created 11 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.0001 post.Text (' G21 (units: metric)\n') --metric mode units = 'mm' precision = '0.000' else post.Text (' G20 (units: inches)\n') --inch mode minMove = 0.000004 units = '"' precision = '0.00000' end post.Text (' G40 (cutter compensation: off)\n') post.Text (' G90 (distance mode: absolute)\n') post.Text (' M52 P1 (adaptive feed: on)\n') post.Text (' G64 P0.254 Q0.025 (tracking tolerances: 0.254)\n') 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 = 'Cut' 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' toolNum = 1 elseif string.match (toolName, 'Centre Spot') then cutType = 'Centre Spot' toolNum = 0 tinyMove = false else cutType = 'Cut' toolNum = 0 end if toolNum ~= oldTool then post.Text (' M6 T', toolNum, '\n') post.Text (' G43\n') oldTool = toolNum end post.Text (' M190 P' , tool,' (',toolName, ')\n') post.Text (' M66 P3 L3 Q2 (wait for valid change)\n') post.Text (' F#<_hal[plasmac.cut-feed-rate]>\n') post.Text (';\n') end function OnPenDown() post.Text ('\n M3 $', toolNum, ' S1\n') if cutType == 'Air Scribe' then scribeLength = scribeLength + entityLength scribes = scribes + 1 elseif cutType == 'Centre Spot' then spots = spots + 1 else pierces = pierces + 1 end cutLength = cutLength + entityLength end function OnPenUp() tinyMove = false post.Text (' M5\n') post.Text (' (End', ' #', cut, ' ', partName, ' ', 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', ' #', cut, ' ', partName, ' ', cutType) if cutType == 'Cut' or cutType == 'Air Scribe' then post.Text (', ') post.Number (entityLength, '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 == 'Cut' 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) elseif tinyMove == false then post.Text(' G91\n G1 X') post.Number(minMove, '0.######') post.Text('\n G90\n') tinyMove = true end post.Eol() end function OnArc() if cutType == 'Cut' 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) elseif tinyMove == false then post.Text(' G91\n G1 X') post.Number(minMove, '0.######') post.Text('\n G90\n') tinyMove = true 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 == 'Cut' 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 (' M6 T0\n') post.Text (' G43\n') 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