Path Optimizer for pcb-gcode
The last couple of days I used the CNC machine to create a PCB for a project I am working on. As the CNC was etching away the copper, I noticed that between paths (i.e. while the spindle was not cutting) there was a lot of unnecessary travel. This happened quite a few times during my 35 minute job. Because I am using slow feedrate, about 10in/min, that unnecessary travel must have added 2-3 minutes. So if you are here looking how to optimize gcode you are at the right place
So to solve this, we need some optimization. What a better thing to spend your afternoon than firing up python, calling a friend and colleague over your PC, and solve this problem. So me and Mike, decided to solve this the easiest and quickest way possible, just by using brute force method to combine the different paths together. The goal is of course to minimize the unnecessary travel of the spindle.
Since this is a python script, it is multi platform. I personally tested it on my Ubuntu and Windows XP.
Let me just show you a couple of screen shots of a job, run on a simulator. This is the PCB of my last project. First let’s see the screenshot before optimizing the code
The white line represents the travelling between two paths. As you can see there are a lot of those white lines! Now let’s see the second screenshot which is the same PCB job, but this time with optimized gcode
As you can see the white lines are reduced. Also notice the clock (below the STOP sign) of the simulator. We just saved a few minutes!
First of all we assume that you already installed python on your system. Download the optimizer script. There is no GUI yet (feel free to expand the code, use git) so we need to run it from command line. Just write
python cncopt.py your_file_here
The script will run and give you some stats on the performance of the optimization.
As shown, in my PCB gcode, the optimized code reduced the travel time from 33 inches to 14. That is a decrease of about 60%. The optimized file will have the same filename with an additional .optimized at the end.
Please note that this was a one-afternoon project just for the fun of it. All comments and feedback are welcome. I hope you find it useful.
I would like to thank Mike as we developed this together.
You can find the project on GitHub https://github.com/demestav/PCB-GCode-Path-Optimizer
Incoming search terms:
- cncopt py (68)
- gcode optimizer (30)
- g code optimizer (29)
- g-code optimizer (4)
- g-code optimieren (3)
- pcb gcode (2)
- optimize gcode (2)
- path optimisation pcb-gcode (2)
- gcode optimizer python (2)
- pcb gcode optimize (1)