I would like to edit the postprocess file

Hi there!
My controller does not like some of the Gcode that is being generated.
It’s a standalone SMC5-5-N-N. It doesn’t like text line that has a ; in front of it. The controller thinks it is an " M0 " pause command. :frowning:
Example of code line “;layer C0”
Anyways Id like to try to edit the postprocessor file that generates the Gcode. Where would I locate this file and what is it named?


We do not use post-process scripts in LightBurn. All of the gcode output is purely dictated by the main program code and there’s nothing that is user editable to change that. We’ve talked about adding that but it has no current time estimate or even are were sure that it will be done.
Since the SMC5-5-N-N looks to be an unsupported controller for LightBurn your only real option would be to export the gcode and the process that with your own postprocess script to reformat the gcode in a manner compatible with your controller.
Sorry for the inconvenience. We try to support as many controllers as we can, but we still have to focus on the most commonly used for common laser systems.

1 Like

Hi Adam,
Thanks for the quick reply! :slight_smile:
Bummer, but not the end of the world.
I have been opening the created Gcode file and editing out the offending line by back spacing them out. I just completed a gcode file where I had to find and remove about 200 lines by hand, took about 15-20 minutes LOL not much fun.

So the only offending thing in your gcode is the comment lines? I’m pretty sure all our comments are all single lines and not at the end of valid gcode.
Would you be comfortable running a python script?

Another thought! I’m using the grbl-m3 as my device is there another one I should try maybe?


Not really, they all have comments. I could also talk to @LightBurn about adding an option to disable comment output in the gcode.
But a script to strip them from the gcode would be easy enough (like 10 lines of python) if you are comfortable with running a python script.

Here is a sample of the code I highlighted the lines that cause my controller to think its getting a M0 with -----. Also the line that states the boundary when it sees that line my machine actually goes to those cords scary.
but if I remove the lines or put the line in between brackets its ok ( )

Sorry can you explain the python part a bit more? I’ve heard of it but not overly familiar wit its purpose.

; LightBurn 0.9.20--------

; GRBL-M3 (1.1e or earlier) device profile, user origin------

; Bounds: X108.95 Y238.82 to X308.95 Y438.64--------



G00 G17 G40 G21 G54


G0 X0 Y0


; Cut @ 1400 mm/min, 75% power-----------




; Layer C01-------------




What OS do you use?

Win 10 64 bit.


Oh wow - so it’s completely ignoring any characters it doesn’t understand and trying to run everything else as “valid” gcode. That is scary.

No worries. Python is a scripting language. There would be other options in this case, it’s just what I’m used to - unfortunately, unlike Mac OS and Linux, Windows doesn’t really have any decent built in scripting options but you can install python.

Basically, download and install this: https://www.python.org/ftp/python/3.9.1/python-3.9.1-amd64.exe
And then you can run python scripts from the windows cmd window.

With this hypothetical post-processing script you would save the gcode file locally and then run: python smc5_post.py laserjob.gcode
The script would then strip out the comment lines that are causing you trouble and you would then send that file to your controller.

Granted, this is all hypothetical. I have no idea if your controller would have other problems with that LightBurn emits.

If you think you would be up for running a python script as described, I’ll send you one that does that. Under normal circumstances we definitely don’t do custom script programming for customers, but this is so little actual code that it would take me 1 minute to write. And I’m just curious.

1 Like

Wow too cool!!!
I started watching some how too videos on YT for Python.
Sure I’m up for it! I love to learn new stuff.

So far I’ve run about five laser jobs with the LightBurn generated Gcode and it works really well, once I edit out the comments.

LightBurn is an easy and amazing piece of software.
I use Fusion 360 for all of my CNC router table milling work, have been using it for about three years or more.
So I just need the python then?, not the Pycharm IDE?

Edit OK I have Python installed and working on the PC.


Ok, download this python script:


(Just right-click the above link and choose “Save link as…”)

Put it somewhere you can run it from the command line.

Then run:

python nocomment.py <your_file.gcode>

But with whatever path to your file is instead of your_file.gcode
Note: it doesn’t care what the extension is (gc, gcode, etc. will all work)
Also, unless the file is in the same directory as the python script you will need to provide either the full file path or a valid relative file path.

It will pretty much instantaneously remove all comments and then you should be good to go.

1 Like

:stuck_out_tongue_winking_eye: WHHHHHaaaaattttttttt??? :stuck_out_tongue_winking_eye:

PowerShell FTW!!!

I :heart: PowerShell and while I was progressing through the thread, my instinct was “oh, I’d write a powershell script for this”.

Edit: Oh ok… See I was just thinking about this and I think I just realized: you said that on purpose because you knew I would say WHHHHHaaaaattttttttt in that really high pitched Adam Sandler voice.

1 Like

Haha, no, it was more that I misspoke. What I should’ve said was:

Windows doesn’t really have any decent cross-platform scripting options built-in

So yes, I’m well aware of PowerShell… though I admit that I’m not super proficient in using it for scripting - my knowledge basically ends at the fact that you can do a lot of .NET style stuff with it (and I’ve written a lot of C# in my day).

And I actually considered writing the script with it so that Glen didn’t have to install anything… however, I’ve spent much of my career writing either cross-platform or Linux specific software, so to me PowerShell is not very useful because it’s not portable to other OS’s. Whereas Python is default installed on all Linux and Mac OS systems. I knew if I wrote it in something Windows specific someone else would immediately come back with “hey! but I want to use that and I’m on a Mac!” so I figured I’d save the hassle and make it work for anyone, regardless of OS.

Believe me, I’m super happy that Microsoft made PowerShell as it’s worlds better than batch scripting. I just find Python a better option when it needs to be portable.

1 Like

Well isn’t that cool! Thanks I’ll give that a try today and get back to you :smile:


OK I tried to save it by right mouse clicking the line you provided. Here are the options in the attached photo. I tried several copy paste methods but the file (text) wont paste. I tried Copy link and save target as.


“Save target as” should work.

What do you mean the text won’t paste?

You can also try downlading the file video the link below, but you’ll have to remove the .txt from the filename before you can run it.

nocomment.py.txt (579 Bytes)

Getting closer LOL have the file with the TXT removed. It is in my “C:\users\Glen” folder. I also moved a Gcode file into the same folder with your file. but I must be doing something wrong or missing a step. The Gcode did not change after preforming the attempt in CMD window
see the attached photo.


What is fck for in your invocation of the script?

You should just do python nocomment.py mandela.gc

Though, it looks like on your system you may be able to just leave out the python call - it’s mostly just a habit for me because it never hurts to specifically call python

If you have a file in “C:\users\Glen” with the same name it would be:

python nocomment.py C:\Users\Glen\mandela.gc

(assuming you had nocomment.py in a different folder)

Or, another option since it seems that your system already has .py files properly associated with python, just stick nocomment.py on your desktop or somewhere convenient and then you can literally just take the .gc file and drag it onto nocomment.py. You will very briefly see a cmd window pop up and go away and after that your file should be comment free!

OK got it to work! It didn’t like my Gcode file name having two parts to it.
Didn’t like “fck mandela” so I renamed it mandela and that worked from the CMD screen. Now however, I don’t want to save my Gcode directly to user glen I added a folder called “lightburn” in the user glen folder, but for the life of me I cant get the syntax correct to get it to open the folder and files in the CMD. see phot of my attempt. I feel like a real pumpkin head!

Other then using msconfig command I haven’t used a terminal since DOS 3.2 days LOL Fdisk format C…