--************************************************ --*** Set these values up to suit your machine *** --************************************************ --Axis swapping. --this translates the X axis in SheetCam to the machine's equivalent xAxis = "A" --this translates the Y axis in SheetCam to the machine's equivalent yAxis = "Y" --Define the rotary axis. Set to xAxis if SheetCam's X axis is rotary otherwise use yAxis rotaryAxis = xAxis --The number of units for one full rotation of the rotary axis oneRev = 360 --************************************************ --*** End of settings *** --************************************************ function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("Purelogic ROTARY post processor for Pumotix\n") ctrl:AppendText("\n") ctrl:AppendText("Modal G-codes and coordinates\n") ctrl:AppendText("Comments enclosed with ( and )\n") ctrl:AppendText("M03/M05 turn the torch on/off\n") ctrl:AppendText("Incremental IJ\n") end post.DefineVariable("diameter",sc.unitLinear,0,1e17) function OnInit() post.SetCommentChars ("()", "[]") --make sure ( and ) characters do not appear in system text 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 G91.1 G40\n F1\n") post.Text (" M101\n") post.Text (" G00") post.ModalNumber (" Z", safeZ * scale, "0.0000") post.Eol() cscale = 0 xScale = scale yScale = scale end function OnNewLine() post.Text ("N") post.Number (lineNumber, "0000") lineNumber = lineNumber + 10 end function OnFinish() post.Text (" M05\n M30\n") end function OnRapid() -- disable Z movement if(math.hypot(endX-currentX , endY-currentY) < 0.001) then return end post.ModalText (" G00") post.ModalNumber (" " .. xAxis, endX * xScale, "0.0000") post.ModalNumber (" " .. yAxis, endY * yScale, "0.0000") post.Eol() end function OnMove() if(math.hypot(endX-currentX , endY-currentY) < 0.001) then return end post.ModalText (" G01") post.ModalNumber (" " .. xAxis, endX * xScale, "0.0000") post.ModalNumber (" " .. yAxis, endY * yScale, "0.0000") post.ModalNumber (" F", feedRate * scale, "0.###") post.Eol() end function OnArc() post.ArcAsMoves(0.1) end function OnPenDown() post.Text(" M100\n") post.Text (" G00") post.ModalNumber (" Z", pierceHeight * scale, "0.0000") post.Eol() post.Text(" M03\n") if (pierceDelay > 0.001) then post.Text (" G04 P") post.Number (pierceDelay,"0.###") post.Eol() end post.Text (" G00") post.ModalNumber (" Z", cutHeight * scale, "0.0000") post.Eol() post.CancelModalNumbers() post.ModalText ("") end function OnPenUp() -- Move head Up to safety Z post.Text (" M05\n") post.Text (" G00") post.ModalNumber (" Z", safeZ * scale, "0.0000") post.Eol() post.CancelModalNumbers() post.ModalText ("") end function OnNewOperation() if ((feedRate <= 0) and (operationClass ~= "VariableOperation")) then post.Warning("WARNING: Feed rate is zero") end if not diameter then if (operationClass ~= "VariableOperation") then post.Error("You need to define the tube diameter first") end return end local scl = oneRev/(math.pi * diameter) if(cscale ~= scl) then cscale = scl post.Text(" (diameter: ") post.Number (diameter * scale, "0.0##") post.Text(")\n") post.Text (" M94 P") post.Number (diameter * scale,"0.0##") post.Eol() if(rotaryAxis == xAxis) then xScale = cscale yScale = scale else xScale = scale yScale = cscale end end post.CancelModalNumbers() post.ModalText ("") end function OnComment() post.Text(" (",commentText,")\n") end function OnNewPart() end function OnDrill() OnRapid() post.Text(" M100\n") post.Text (" G00") post.ModalNumber (" Z", pierceHeight * scale, "0.0000") post.Eol() post.Text(" M03\n") if (pierceDelay > 0.001) then post.Text (" G04 P") post.Number (pierceDelay,"0.###") post.Eol() end post.CancelModalNumbers() post.ModalText ("") -- Move head Up to safety Z post.Text (" M05\n") post.Text (" G00") post.ModalNumber (" Z", safeZ * scale, "0.0000") post.Eol() post.CancelModalNumbers() post.ModalText ("") OnRapid() end