[Home]Simple LinuxCNC G-Code Generators

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Difference (from prior major revision) (no other diffs)

Changed: 3c3
The Python scripts hosted on this wiki page have been moved to a repository on Github, where you can download them individually, or as a Zip file:

Changed: 5c5
From the official Python web site http://python.org/ "Python is a dynamic object-oriented programming language that can be used for many kinds of software development." Python is powerful,open source, cross platform compatible and easy to learn and use. It has become one of the favorite languages of the LinuxCNC development group. A tutorial for Python can be found here http://docs.python.org/tutorial/

Removed: 7d6
This page contains links to Python scrips that generate simple G-Codes for LinuxCNC. For me to fire up a high dollar CAD program and the use the POST processor to generate simple routines is a time waster. So I'm writing a series of Python programs to do this. If you did an LinuxCNC install with Ubuntu you are good to go you have all you need. Make sure you make the mods to your ini file so you can open these up from Axis and paste the generated code directly into Axis... as shown at the bottom of the page.

Changed: 9,263c8

The programs will do Facing, Pockets, Slots, Drill Patterns etc. When they are all finished
I'll package them all up into one.

1. Drilling Speeds-n-Feeds

** This one helps you to calculate the speeds and feeds for drilling


** upload:drill.py Version 0.1
** Some interesting reading on chip loading upload:Chip%20Load%20on%20Drills.odt

2. Arc Generator

** This one takes the center of an arc, the diameter, the start and end angle and spits out the G-Code
** The start point for the arc and the G2/3 code for the arc are generated.
** There might be a couple of bugs left in the code. If you find one e-mail me and I'll fix it.
** upload:Arc%20Buddy.odt A very short tutorial on Arc Buddy
** upload:Arc%20Tutorial%202.odt A more advanced tutorial on making arcs.
** NEW a version of Arc Generator for front tool lathes.



** upload:arcbuddy13.py Version 1.3
** upload:arcbuddy14.py Version 1.4 adds send to axis with a feed rate so it will actually run.
** upload:arcbuddy15.py Version 1.5 adds the ability to use in Gedit and refined to have a choice of what to send.
** upload:arcbuddy16.py Version 1.6 9/2014 you can actually layout a path and create the G code for that path.
** upload:arcgenm18.py Version 1.8 of Mill Arc Generator
** upload:arcgenl18.py Version 1.8 of Lathe Arc Generator

This is a slightly different version of Arc Buddy that was modified by Sebastian Jardi Estadella for use in gEdit to insert the gcodes.
The instructions for use with gEdit are in the comments section.


3. Facing Software

The facing software is super simple. You input a few things and press a button and your code is saved to your NC directory ready to open in LinuxCNC!

** upload:face.py Version 1.4.0 Last Updated on 2012-07-13 License is GNU license.
*** for windows users download and rename face.py to face.pyw, download and install python2.4 [from Python.org]

** Features
*** Lead-in, lead-out value can now be changed - version 1.3.4
*** Now has a radio button to set the X0-Y0 (Home) position: Left-Rear or Left-Front - version 1.3.3b
****** To change the default, see the comments in the file
*** Now has a radio button for Inch/MM Version 1.3.2
*** Now accepts fractions in any field where this is appropriate. Version 1.3.1
*** One step file save after setting the NC File Directory Option.
*** Vertical Scroll Bar added to text box.
*** Added Spindle Speed setting that automaticly adds M2 and M5 if you specify a value
*** Can leave Depth of Cut, Spindle Speed and Stepover blank.
*** Added a menu!
*** NC File Directory is saved to an .ini file!
*** If you open in Axis you can directly save the g code to Axis!!!
** Undocumented Features
*** Assumes that the top of the material is Z0 and nothing is above Z0

4. Bolt Circle Array Software


**This program generates a circular array for canned drill cycles in a mill (ie 'bolt circle'). This program used face.py as a template, so it looks very similar. Some of the entry widgets have predefined values in them. Look carefully at these before pressing the 'Generate G-code' button (-Dan Falck). Note this generates a snippet of G code intended to be inserted into your G code.

5. Counterbore Software

** upload:counterbore.py
** Version 1.3.1

** This software generates the G-code for counterbores for socket head cap screws.
** If you have any comments just e mail me Big John T.

*** Pick a SHCS from one of the three lists and it puts the standard diameter and depth in for you.
*** Minimum entrys needed are hole diameter/depth, tool diameter and location of the hole.
*** M2 end of file option if you have to generate several size holes only use it on the last hole.
*** Editing of X & Y list with mouse clicks on item. Maintains order if one is edited and put back.
*** Speedy entry using number key pad and the key pad enter key for locations.

*** At this time there is a bug if you have a path that does not require a spiral... working on it


6. Grill Drilling Software

** Version 1.3 upload:grill-13.py
** Version 1.2 upload:grill-12.py

** This software peck drills a circular array of holes typically used as a speaker grill or
** as ventilation holes in a chassis panel.

*** can drill circular, elliptical, rectangular or oval rectangular shaped array of holes
*** usable as an axis filter program (see below)
*** gcode can be copied to the clipboard for easy insertion into other gcode programs



7. Bezel Engraving Software

** upload:bezel-11.py
** Version 1.1

** This software engraves a bezel like you would see on the front panel of a stereo around the volume control knobs.
*** adjustable number of minor and major ticks
*** adjustable start and stop positions
*** center position is marked with a dot for later drilling operations
*** usable as an axis filter program (see below)
*** gcode can be copied to the clipboard for easy insertion into other gcode programs
*** use of variables for center point and Z values for easy code block reuse


8. Text Engraving Software

** upload:engrave-11.py
** Version 1.1
** upload:cxf-fonts.tgz cxf fonts for this application. Qcad version 3 fonts will not work (format changed)

** This software engraves a text string.
*** uses Qcad font files (nice stroked font definitions)
*** you will need to obtain .cxf font files from the link above or use the ones from the qcad V2 package
*** supports flipped(about x axis) or mirrored(about y axis) text
*** mirrored text is useful for back cutting on Plexiglas panels
*** usable as an axis filter program (see below)
*** independent X and Y scaling so the look of a font can be modified
*** adjustable character and word spacing
*** string can be plotted at any arbitrary angle
*** gcode can be copied to the clipboard for easy insertion into other gcode programs
*** use of gcode variables for start point, scaling, rotation and Z values for easy code block reuse or tweaking


9. Multi-line Text Engraving Software

** upload:engrave-lines-v4.zip

** This software is a command-line program based upon the above engrave-11.py by Lawrence Glaister.
*** All options can be set on the command-line from switches to engrave up to 10 lines of text
*** X offset indents can be set for any line using -i switch followed by string of line numbers
*** Will output a single .ngc file which offsets position at each new line
*** Otherwise works as engrave-11 and uses it as the code generation engine
*** Outputs to stdout so can be redirected to a file
*** NB requires old version of QCad fonts (available separately at wwwDOTmgwareDOTcoDOTukSLASHLinuxCNCSLASHqcad?-fonts.zip)

** upload:Selection_003.png

10. Pycam - Drop Cutter Surfacing Software


A GPL 3D CNC Toolpath Generation program written by Lode Leroy

** Requires python, pyopengl, and togl to run under linux
Download from here:

11. Dxf2gcode - import a 2D DXF file and produce G-code


Written by Christian Kohloeffel.


Download from here:

This program seems to work pretty well with DXF files from QCAD.

12. Rectangular-Circular Pocketing Generator

**This is for Generating simple Pocket Style Toolpaths with Different depth/stepover
**Version 1 does only support Zero Path but you can simply edit the final path to G41 new spiral depth mode (04 2011)
**Screenshot :
*** Written by Sammel Lothar Germany

13. Grid Rectangular Circular SpiderNet G-code Generator

**This was written to test the speed and the acurathy of a milling mashine,
with the grid alot of moves are taken and you can see the accurate by,
checking Zero Border on the grid if it not harming the outside Shape!
Now all shapes and functions are includet Aug_2010!

*** upload:grid_v1.py
*** Written by Sammel Lothar Germany

14. Airfoil G-code Generator 3-4Axis XY-XYUV Foam EDM Style

** This is a generator for a Airfoil data it has 1550 Airfoil Wing Profile Data in stock
Download from here 1MB ZIP:
** it uses Tkinter Time PIL -> StartFile? 0_xyuv_Gcodegenerator.py
*** Written by Sammel Lothar Germany

15. Other G Code Generators

: [CP1] is a conversational machining program written by Ray Henry and Matt Shaver with additional MOP's by Lawrence Glaister.
: [TTT] is a TrueType tracer with DXF and G-Code output

16. Using Python scripts with Axis

** To download a file right click on it and select "Save link as"

Do the following...

** Place the .py files in your nc directory so it is easy to find
** Right click on the .py file in your file browser and select Properties. On the Permissions tab check Execute on the Owner line.
** Add the following lines to the [FILTER] section of the Axis ini file
*** [FILTER]
*** PROGRAM_EXTENSION = .py Python Script
*** py = python

** If you don't have a [FILTER] section just add it
** Now use File Open in AXIS to open face.py and after you generate the g-code select Write to AXIS and Quit

17. Using Python scripts with Windows

** Rename the file from .py to .pyw
** Download and install the python program

18. Using Python scripts online


Here are some python generators that can be used from LinuxCNC and online too.
They are simple, but you can easily make new ones for yourself... using the
hugomatic library, that abstracts the user interface.
This is beta software, so please provide feedback.

19. mGcodeGenerator

**A script for Blender. It can generate gcode ideal for LinuxCNC :) it exports from mesh ( vertex / edge / edges (outlines) / objects ) to 2d, 2.5d and full 3d for (3axis mill).

20. OpenVoronoi and OpenCAMLib?

There are some sample scripts and screenshots that use OpenVoronoi and OpenCAMLib? at https://github.com/aewallin/linuxcnc-scripts

21. gcmc - G-Code Meta Compiler

[Gcmc] is a front-end language for generating G-code, SVG and DXF for CNC mills, lathes, laser cutters and other numerical controlled machines employing G-code, SVG or DXF. The language is a context-free grammar created to overcome the archaic format of G-code programming and aims to be more readable and understandable. Gcmc makes extensive use of vector mathematics to support the 3D nature of CNC machining.


Please submit issues and improvements there.

Simple LinuxCNC G-Code Generators Written in Python

The Python scripts hosted on this wiki page have been moved to a repository on Github, where you can download them individually, or as a Zip file:


Please submit issues and improvements there.

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited February 5, 2017 5:06 am by Njh (diff)
Published under a Creative Commons License