GRBL Laser Post Processor

Having problems with or questions about SheetCam? Post them here.
Post Reply
CrazyKen
Posts: 2
Joined: Thu Jan 04, 2024 9:19 pm

GRBL Laser Post Processor

Post by CrazyKen »

Hi All

I am currently editing a GRBL post processor to run a laser. I am trying to pull in the tool type to build my code but am not having much luck. I can get the operationName with this snippet

post.Text (" /*OPERATION ", operationName, " */ \n")

The output in gcode is /*OPERATION Laser engrave, Layer 1, T18: Laser, 1.5 mm kerf, 0 mm Deep */

This will change for each tool and the layer name.
Is there a way to extract the first part of the string up to the comma so it only outputs "Laser engrave"?
I have tried several things but new to editing post processors so need some help.

Thanks
User avatar
bLouChip
Posts: 124
Joined: Tue Nov 09, 2021 4:58 pm
Location: Raleigh, NC
Contact:

Re: GRBL Laser Post Processor

Post by bLouChip »

try this snippet, it worked for me in some test cases this morning...

Code: Select all

-- test code   
   -- match any char from begining of string to comma and return that substring
   local s = string.match ( operationName, "^.-," )   
   if s~= nil then 
      -- remove the comma at the end
      s = string.sub ( s, 1, string.len(s) - 1 )
      post.Text ( s, "\n" )
   else 
      post.Text ( "no comma found \n" )
   end
SC post processors are written in a language named Lua, here is the reference doc: https://www.lua.org/manual/5.1/manual.html#5.4
Happy coding :)
MillRight CNC MegaV XL XYZA Tri-CAM Mill/Plasma/Laser
grbl 1.1i, UGS, Win 11, LightBurn, SC, Aspire, and sometimes [con]Fusion360
my youtube channel
CrazyKen
Posts: 2
Joined: Thu Jan 04, 2024 9:19 pm

Re: GRBL Laser Post Processor

Post by CrazyKen »

That is exactly what I was looking for

thanks
User avatar
djreiswig
Posts: 484
Joined: Sat Feb 20, 2016 4:47 am
Location: SE Nebraska

Re: GRBL Laser Post Processor

Post by djreiswig »

There should be a built in variable for the tool name. Not sure what it's called. Look at the variable monitor in SheetCam and you should see it.
Post Reply