--************************************************ --*** Set these values up to suit your machine *** -- Values set HERE are in MM. If the value can be set in SheetCAM it is in the UNITS (MM or Inches) you have in SheetCAM --************************************************ lineNumber = 0 --set this to 1 if you want the G-Code to have assigned line numbers on each line. Default is 0 for LinuxCNC startCode = " M3 S69" --S command needed for LINUXCNC endCode = " M5" --****************************************************************************************************************************************** -- do not change the following values unless you are told to do so by an experienced LinuxCNC user or vendor of your controller or table toolTrack = .254 -- Default .254 mm. This is the blending tolerance in MM (deviation from toolpath) the Path Blending allows. -- Lower numbers favors tight tracking over the defined feedrate (slows down) toolTolerance = .116 -- Default .0254 mm.T his is the linear tolerance for multiple nodes in the same toolpath. -- Lower numbers cause nodes out of line by less than the toolTolerance amount to be a single line --******************************************************************************************************************************************* --************************************************************************** --*** End of settings *** --*** DO NOT CHANGE ANYTHING BELOW THIS LINE *** --************************************************************************** function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("Minimal Custom Post for Plasmac Branch of LinuxCNC for Linux: \n") ctrl:AppendText("Use with SheetCAM TNG version 6.0.14 or higher or Development ver 6.1.16 \n") ctrl:AppendText("Designed for use with LINUXCNC version 2.9-PRE Plasmac Branch\n") end if (toolTrack) then --nothing else toolTrack = .001 end post.DefineCustomOption("Ref Distance", "refDistance", sc.unitLINEAR, 0, 10000) function OnInit() offX = 0 offY = 0 offZ = 0 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 (" F10.0\n G90 G40\n") post.Text (" G64 P") post.Number (toolTrack * scale, "0.000") post.Text(" Q") post.Number (toolTolerance * scale, "0.000") post.Text (" (tracking tolerances set to " , toolTrack * scale, ") \n") off2X = .0254 off2Y = .0254 newOp = false newPart = false minArcSize = 0.2 --arcs smaller than this are converted to moves firstRef = true currentZAxis = "Z" finalCut = false dist = 9999999 end function OnNewLine() if (linenumber == 1) then post.Text ("N") post.Number (lineNumber, "0000") lineNumber = lineNumber + 10 else post.Text (" ") end end local function round(x, n)--added by TLC --n = math.pow(10, n or 0) x = x * 100 if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end return x / n end function OnFinish() finalCut = true endXRND = round(endX, 100) endYRND = round(endY, 100) curXRND = round(currentX, 100) curYRND = round(currentY, 100) if (endXRND == curXRND) and (endYRND == curYRND) then --see if the current X and Y position is the same final move post.Text (" (No Parking values detected. Moving back to zero, zero)\n ") endX = 0 endY = 0 else post.Text (" (End of job , noving to predefined Parking position)\n ") end if endZ > safeZ then --use the largest number --nothing else endZ = safeZ end offX = 0 offY = 0 offZ = 0 post.Text (" G92.1 \n") post.Text (" M5 M30\n") end function OnRapid() if(currentZ~= endZ)then return end -- don't post Z plunge moves post.ModalText (" G0 ") post.ModalNumber (" X", (endX + offX) * scale, "0.000") post.ModalNumber (" Y", (endY + offY) * scale, "0.000") post.Eol() end -- end on Rapid Function function OnMove() if(currentZ~= endZ)then return end --don't post Z plung moves post.ModalText (" G1") post.ModalNumber (" X", (endX + offX) * scale, "0.000") post.ModalNumber (" Y", (endY + offY) * scale, "0.000") post.Eol() end --end of OnMove function function OnArc() if(arcAngle <0) then post.ModalText (" G3") else post.ModalText (" G2") end post.ModalNumber (" X", (endX + offX) * scale, "0.000") post.ModalNumber (" Y", (endY + offY) * scale, "0.000") post.Text (" I") post.Number ((arcCentreX - currentX) * scale, "0.000") post.Text (" J") post.Number ((arcCentreY - currentY) * scale, "0.000") post.Eol() end -- end OnArcfunction function OnPenDown() -- uncomment next two lines for F word at the start of each cut -- post.Text (" F#<_hal[plasmac.cut-feed-rate]>") -- post.Eol() post.Text (startCode) post.Eol() end --end OnPenDown function function OnPenUp() post.Text (endCode) post.Eol() end --end OnPenUp function function OnNewOperation() newOp = true end--end function function OnToolChange() offX = 0 offY = 0 offZ = 0 if(newPart == true) then post.Text(" (Part: ",partName,")\n") newPart = false end if(newOp == true)then post.Text (" (Operation: ", operationName, ")\n") if (feedRate <= 0) then post.Warning("WARNING: Feed rate is zero") end newOp = false end -- new part for plasmac material table use post.Text (" M190 P") --set material number = tool number post.Number (tool, "0") post.Eol() post.Text (" M66 P3 L3 Q1 \n") --wait for file read post.Text (" F#<_hal[plasmac.cut-feed-rate]> \n") --end of plasmac material table setting post.Text (" G64 P") post.Number (toolTrack * scale, "0.000") post.Text(" Q") post.Number (toolTolerance * scale, "0.000") post.Text (" (tracking tolerances set to " , toolTrack * scale, ") \n") if (warnings == true) then post.Text (" M1") post.Text (" (Settings Check)\n") post.Text ("( ###########################)\n") post.Text (" (Paused: Check Settings )\n") post.Text (" ( Hit RUN to continue)\n") post.Text ("( ###########################)\n") else post.Text (" M1") post.Text (" (Pause off)\n") end --end warnings end --end for toolchangefunction function OnNewPart() newPart = true -- post.Text(" (Part: ",partName,")\n"); end