function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("Mach3 WaterJet post processor\n") ctrl:AppendText("\n") ctrl:AppendText("Generic WaterJet Post\n") ctrl:AppendText("\n") ctrl:AppendText("Modal G-codes and coordinates\n") ctrl:AppendText("Comments enclosed with ( and )\n") ctrl:AppendText("M480 and M481 turn the jet on/off\n") ctrl:AppendText("ABS IJ\n") end -- This breaks the arc's up in 90 degree segments post.SetOptions(post.ARC_SEGMENTS) function OnInit() post.SetCommentChars ("()", "[]") --make sure ( and ) characters do not appear in system text post.Text (" (Filename: ", fileName, ")\n") post.Text (" (Post processor: ", postName, ")\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 (" G90 G90.1 G40 S500 M418\n") dist = 9999999 refdistance = 400 switchoffset = 0 minArcSize = 0.05 --arcs smaller than this are converted to moves end function OnNewLine() post.Text ("N") post.Number (lineNumber, "0000") lineNumber = lineNumber + 10 end function OnFinish() post.Text (" M30 (Program Rewind)\n") end function OnRapid() if(math.hypot(endX-currentX , endY-currentY) < 0.001 and endZ < currentZ) then return end dist = dist + math.hypot(endX-currentX , endY-currentY) post.Text (" G00") post.NonModalNumber (" X", endX * scale, "0.0000") post.NonModalNumber (" Y", endY * scale, "0.0000") -- post.ModalNumber (" M422 P", endZ * scale, "0.0000") -- post.Text (" (Z Positive Move)") post.Eol() end function OnMove() dist = dist + math.hypot(endX-currentX , endY-currentY) post.Text (" G01") post.NonModalNumber (" X", endX * scale, "0.0000") post.NonModalNumber (" Y", endY * scale, "0.0000") post.NonModalNumber (" F", feedRate * scale, "0.###") post.Eol() end --function OnArc() -- post.ArcAsMoves(0.01) --end function OnArc() dist = dist + math.hypot(endX-currentX , endY-currentY) if(arcAngle <0) then post.Text(" G03") else post.Text(" G02") end post.NonModalNumber (" X", endX * scale, "0.0000") post.NonModalNumber (" Y", endY * scale, "0.0000") post.Text (" I") post.Number ((arcCentreX) * scale, "0.0000") --post.Number ((arcCentreX - currentX) * scale, "0.0000") This is for incremental IJ mode post.Text (" J") post.Number ((arcCentreY) * scale, "0.0000") --post.Number ((arcCentreY - currentY) * scale, "0.0000") This is for incremental IJ mode post.NonModalNumber (" F", feedRate * scale, "0.0###") post.Eol() end function OnPenDown() post.Eol() post.Text (" M480 (Jets Down, Jets On, Abrasive On, Pierce Delay)") post.Eol() end function OnPenUp() post.Eol() post.Text (" M481 (Jets Up, Jets Off, Abrasive Off)") post.Eol() end function OnNewOperation() post.Text (" (Operation: ", operationName, ")\n") end function OnComment() post.Text(" (",commentText,")\n") end function OnToolChange() post.Text (" M06 T") post.Number (tool, "0") post.ModalNumber(" F",feedRate * scale,"0.0###") post.Text (" (", toolName, ")\n") if (feedRate <= 0) then post.Warning("WARNING: Feed rate is zero") end end function OnNewPart() post.Text(" (Part: ",partName,")\n"); end function OnDrill() OnRapid() OnPenDown() endZ = drillZ OnMove() OnPenUp() endZ = safeZ OnRapid() end