I found a very useful Apple Script for converting M3-GRBL code to something that Mach 3 can use.
M3-GRBL uses the M3 and M5 commands for the laser. Mach 3 needs M11/M10 commands but there is nothing in Lightburn that generates G-code in this way.
I have been manually using a text editor to EDIT>FIND>FIND AND REPLACE the M3 and M5 codes with the M11/10 codes. It only takes a few seconds per file but for my application there are sometimes 10-20 files to work through.
Anyway I found a script that automates the EDIT>FIND>FIND AND REPLACE
I did not write this so I can not take credit. I did edit it to use the correct codes for my system
It still needs a bit of tweaking but it is a time saver.
If you are a Mac user and using Lightburn to generate G-code for Mach3 in the way that I am this will help you. Or someone may find a different use for it.
If anyone knows how to write a few lines to add an commands to the file please let me know. I still need to be able to add an M5 and M30 command at the end of the program.
Here is the apple script.
You may need to change the set to find list and text to replace with list items to fit your specific needs.
set textToFindList to {“M3”, “M5”}
set textToReplaceWithList to {“M11 P2 S100”, “M10 P2”}
if (length of textToFindList) is not equal to ¬
(length of textToReplaceWithList) then return
set theFile to choose file
– tell application “Finder” to duplicate file theFile with exact copy
set theText to read theFile as «class utf8»
repeat with i from 1 to length of textToFindList
set theText to my findAndReplaceInText(theText, ¬
item i of textToFindList, ¬
item i of textToReplaceWithList)
end repeat
my writeToFile(theText, theFile, true)
– # Handlers #
on findAndReplaceInText(theText, theSearchString, theReplacementString)
–considering case
set AppleScript’s text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript’s text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript’s text item delimiters to “”
return theText
–end considering
end findAndReplaceInText
on writeToFile(theText, theFile, overwriteExistingContent)
try
set theFile to theFile as string
if theFile contains “/” then
set theOpenedFile to open for access theFile with write permission
else
set theOpenedFile to open for access file theFile with write permission
end if
if overwriteExistingContent is true then set eof of theOpenedFile to 0
write theText to theOpenedFile starting at eof
close access theOpenedFile
return true
on error
try
close access file theFile
end try
return false
end try
end writeToFile