Command line utility to 'clean' GCode

Hi Tim,

You will need to open up a command window (terminal window) to run the GCodeClean command.


Here’s an example direct from my machine.

The first three lines are the commands to change to the d: drive, and then to change directory cd to where GCodeClean lives on my system. Obviously yours will be different.

And then finally the cli command itself. Here I entered it without any options, and when you do that it shows help text for all of the available options.

More commonly, what you would enter would look something like this:
cli --filename Samples\Facade\Facade.nc --minimise soft

The command above tells cli to get the file Facade.nc located in a sub-folder Samples\Facade and to do soft minimisation of the output GCode

1 Like

Thanks! I have a large area to pocket with some intricate details. Using carbide create to pocket using a 1/4 bit then pocket using an 1/8" bit would gcodeclean clean up the duplicate paths? Thanks

-Tim

Not really - It’s a line by line cleaner. It’s designed to simplify lines and arcs within tolerances.

However, it does have an --annotate option which adds comments to lines to help you understand what each one does, that can help with editing the gcode file by hand (although you should always be careful with that)

What I’ve done sometimes to reduce commands is to do two drawings. So one with the pocket for instance, and then another with a simple path. Then either run them as two separate GCode files, or use an editor to merge them into one.

Sign up for the Carbide3D forum, then ask how to do this in the Carbide Create sub forum. Will Adams will explain it much better than I can. Then use GCodeClean to clean up arcs and change rapids to retracts to improve the resulting gcode even more

Not sure it it worked.

It didn’t.

One change that you will need to make is to put the whole file path in double quotes - where there are spaces in a value on a command line then that value needs to be in quotes.

e.g.
cli --filename "C:\Users\Tim Seidlitz\Desktop\weapons pics\widow\somefilename.gc"

Tried using it again on Windows 10. Gcode created by carbide create. Ran zClamp and opened the newly saved file in webcontrol it was just the contour and not the pocket.

Picture shows both mimise soft and zClamp but I tried them both separate as well, same outcome.

Don’t know what I’m doing wrong. I did it exactly as described above. Any help is appreciated.

-Tim

minimise soft and/or zclamp aren’t likely to make any difference. Could you please pm me with your file so I could try it for myself and then advise

PS - In Windows you can go Windows Key+Shift+S (:window:+Shift+S) to snip a part of the screen (or even the whole screen) - then just cut-n-paste it into anything. no need to use your phone
image

v0.9.5 has been released

See Releases · md8n/GCodeClean for it.

What’s included

  • Minor housekeeping - v0.9.4 got the dedupLinear functionality working for an arbitrary number of colinear movements, but there was still multiple calls to dedupLinear in the main program, when only one would now be required. So the excess calls were removed.
  • Better handling of very terse GCode input (thanks @TimS for finding it and providing me with a code sample). This was fixed by moving the call to Augment much higher up the list, thereby injecting the commands necessary.
  • BREAKING CHANGE - addition of lineNumbers command line option. Normal behaviour is now to remove any line numbers from the GCode (they are NOT recommended). But by turning this flag on line numbers will be preserved (:face_vomiting:). Please don’t use line numbers, this is GCode not BASIC, but if you must, go out and take a programming course.
2 Likes

Great use of the vomit emoji!

1 Like

My personal favourite is the unicorn doing a technicolour yawn
image

2 Likes

It seems to be working, I haven’t cut with it yet, will this weekend. Is there a cheatsheet that explains in newbie terms what each option really does? Thanks

-Tim

Does the gcode cleaner overwrite the gcode file? I think I want to have the before and after. Should I make a copy before running the cleaner?

I’m 99% sure that it creates a new file, but the first time you run it, save a
copy just in case I’m wrong.

David Lang

I’m calling it from webcontrol menu and I don’t want to overwrite the original uploaded file.

run it manually on a test file. I’m pretty sure that you have to tell it the
name of the output file (or it creates it from the input file)

it just does not make sense to try to overwrite the file that you are reading,
that is just inherently unreliable. But it does happen, which is why I’m only
99% sure :slight_smile:

David Lang

It automatically produces a new file.

I.e. testsquare.nc will become testsquare-gcc.nc

Both files will be available in the folder.

Which I can absolutely concur with.

GCodeClean takes the input filename and inserts a -gcc before the end. And if you feed that file back through it (although you shouldn’t because it is a one pass cleaner) then it will insert -gcc again.

1 Like

It works as stated except it is -gcc when I run it…