This script optimizes Snapmaker Luban generated g-code files for faster line-filled grayscale laser engraving
@author: Keivan (www.piramja.de) / Facebook: https://www.facebook.com/piramja/
@descr: This script parses g-code files generated by Snapmaker Luban for laser engraving line-filled grayscale images and changes all working movements that have laser output below the threshold value to jogging movements, thus resulting in much higher engraving speed (depending on the image and the threshold of course.. and your given jogging speed)
@license: Public domain. Do with this script whatever you want, be free! But don't hold me responsible, it comes as is without any warranty!
@usage: It's pretty straight forward. You create your design in Luban, export your g-code file in the workspace tab. Then open the command line (cmd in Windows, python has to be installed and put in the PATH variable) and run:
python sm_laser_mask.py your_gcode_file.nc output_gcode_file.nc 50
where 50 is the threshold value and should be between 1 and 100. I had great results with a value of 50 so far but feel free to play around.
Then you can just import the generated .nc file back into Luban. That's it! Just notice that the processing time that Luban shows will not be changed, because it's calculated during generation and this script doesn't recalculate it. Let yourself be surprised how fast it will be (;
!!! IMPORTANT !!!! PLEASE MAKE SURE YOU KNOW WHAT YOU ARE DOING! I strongly recommend to test the output of this script with a g-code simulation software (CAMotics for example) to make sure it does what you expect. And have fun (: