Command line utility to 'clean' GCode

v0.8.5.4 is up in GitHub right now, along with the releases for OSX, Windows and Linux.

  • This fixes issue #1 removing the redundant (and according to the spec wrong) G0 command right at the start of some GCode files, e.g. those generating by Fusion 360.
  • The DedupLinearToArc function has also been improved to ‘screw up even less’. There still seems to be an issue in a handful of cases, current suspect is movement through the 3rd axis relative to the current ‘plane’.
  • A little bit of refactoring to remove some redundant constant values.
2 Likes

v0.8.6.0 is now up on GitHub, and the releases for Linux, OSX, and Windows as well.

This fixes the mis-handling of the I J K arguments, as a result I think this is now pretty close to being v1.
I’d appreciate anyone who wants to throw their own gcode at it to see how it compares.

I have attached 07_slot_cutting.zip which shows my results Please advise. Thanks

Forgot --annotate
it works now
sorry
Still want to visit Botany Bay

1 Like

Glad I could help :grinning:

1 Like

Version 0.8.7.0 is up on Github align with the releases for Windows, OSX and Linux

https://github.com/md8n/GCodeClean/releases/tag/0.8.7.0

This release was inspired by @Thormj’s thread https://forums.maslowcnc.com/t/buffering-and-making-sure-im-up-to-date/ and what MakerCam :nauseated_face: (which uses Flash :face_vomiting:) give him for GCode.

So it now converts very short arcs (G2 and G3) into straight lines (G1).
And then ironically it feeds that back into the LinearToArcDedup algorithm, which results in much better curves.

I’ve also added command line options to set the general tolerance value (this affects the clipping of decimal places, and some maths operations), and an arcTolerance value for the above function.

3 Likes

Version 0.8.8.0 is now on Github along with the release for Linux, OSX and Windows

This is a partial answer to all those “why does it pointlessly raise and lower z-axis?” type of issues that we all have.

  • First, all positive z-axis values are clamped to a single value. The default is 0.2"" or 5mm.
  • Second, there is a command line option to change this value to something else (within limits).
  • Finally, the existing deduping algorithm will remove some of the now pointless duplicate z-axis movements.

I’d appreciate it if anyone can reply with GCode files that have the “uppy downy thing” happening (AKA “Raveling Nancy” for those who know their Blackadder).

3 Likes

Version 0.8.8.2 is now on Github along with the release for Linux, OSX and Windows

Well … who would have thought that GCode line numbers could be such a pain in the …

Anyway, here’s a minor release for them.

2 Likes

I know it’s called GCodeClean and it does a few M-Codes but would it be possible to get the rest of the M-Codes? Sorry to be a bother. Thanks
M0 (Program Stop)
M1 (Optional Program Stop)
M2 (Program End)
M3 (Turn Spindle: Clockwise)
M4 (Turn Spindle: Counterclockwise)
M5 (Turn Spindle: Stop)
M6 (Tool Change)
M7 (Coolant: Mist, On)
M8 (Coolant: Flood, On)
M9 (Coolant: Mist and Flood, Off)
M10
M11
M13
M19
M21
M22
M23
M24
M30 (Program End, Pallet Shuttle, and Reset)
M41
M42
M43
M44
M48 (Speed and Feed Overrides: Enable)
M49 (Speed and Feed Overrides: Disable)
M52
M60 (Pallet Shuttle and Program Stop)
M98
M99

The ones that have labels are from the NIST spec.
The others are form ‘other’ things. What device are you targetting to get those codes?

Thanks for your response. I own a miniature horizontal CNC mill and am a C# Visual Studio SQL programmer for a living. The programs the vendor provides with the mill have no comments.

After spending hours trying to memorize G-codes so I could understand their code, I was completely thrilled to find you efforts. I ran the vendor’s code through your program and finally was able to see what it was doing.

Paramount Die Company is very close to where I live and I want to talk to them about a part time programming job. http://www.paradie.com/
They use GibbsCam software and from their product line, it looks like they use lathes.

Here is the list of M Codes – CNC Milling and Lathe I was looking at:
Complete list of G and M codes which are common in almost all the cnc controls which are used in cnc machine workshops around the world.

Thanks,
Captain Jim Cummings

I don’t think the question is what the M codes are, but rather, what is it you
are thinking that the utility should do to these codes.

David Lang

If your utility could just display the Description that they have beside the codes, it would save the tremendous effort required to either memorize or look up each code as it it used.

Captain Jim

Hi Jim,

GCodeClean originally started life as a VS Code plugin, precisely so I could hover the mouse over any command and get it to tell me what it meant.

So yes, I still want it to be able to ‘transcribe’ some GCode with explanatory comments.

Thanks for that reference. I’ll compare those codes with the ones for RepRap 3D printers as well.

Ultimately I want to encapsulate all these codes and their ‘meaning’ so that GCodeClean can reliably manipulate any GCode file (within reason anyway).

Might be handy to put the gcode descriptions in an editable file (yes, I know source code is editable, but it’s a bigger project), at least for the non-RS274X codes added for 3D printers and controller vendor additions.

The code is already set up for me to add a command line option for this.
However, I need to expand the definition file so that command groups can be identified, as well as the priorities between commands, etc. And that requires dome refactoring.

OK - I’ve grabbed what I could from those tables and included in the tokenDefinitions.json file, which is where that stuff lives.

You should be able to git pull and rebuild the whole thing. Or just get the updated file and copy it over the existing one.

I still don’t have the associated ‘semantics’ for those commands to know how they should be grouped and prioritised, just the descriptions.

That looks excellent. Attached are my results. Thanks for your efforts.

ComplateCodeList-gcc.zip (1019 Bytes)

No problems, obviously if you have a reliable source for those other codes feel free to send me a reference, or put them into tokenDefinitions.json yourself and send me a pull request (you may need to do a fork to get github to accept it back)