Vagrearg Logo  
 
gcmc - G-Code Meta Compiler

Introduction

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.

An introduction document is available. The introduction goes through basic syntax and program outline and describes an example to create involute gears in under 200 lines of code (under 100 lines when excluding source code comments).

Getting and building gcmc

You can get the source from the link below. The windows executable is a 32/64bit MinGW cross-compiled command-line version.
Source tarball: gcmc-1.9.0.tar.gz
Windows exe (32 bit): gcmc32-1.9.0.zip
Windows exe (64 bit): gcmc64-1.9.0.zip
Git repo: https://gitlab.com/gcmc/gcmc
Please note: the git repository has been moved from gitorious.org to gitlab.com. You should rebase your local repository if you have cloned it.

Older sources are available and a SHA1 sum and/or SHA256 sum may be used to verify the archives.

Building from source is straight forward and should function on Linux, *BSD, MinGW/MSYS and Cygwin:
$ tar xzf gcmc-1.9.0.tar.gz
$ cd gcmc-1.9.0
$ ./configure
$ make

After 'make' you should have an executable in the 'src' directory named 'gcmc'. For a MinGW cross-compile you should use 'mingw32-configure' or 'mingw64-configure' or whatever your cross-target is and it should result in 'gcmc.exe' after running one of 'mingw{32,64}-make'.

Building on any system with a different set of autotools may require you to re-configure the setup. You should be able to run 'autoreconf -f' to update to your system. Be sure to do so for both gcmc and gcmcfont. See the first part of doc/debian.build on how to re-configure. This should work across distributions.

Running gcmc

Running gcmc, assuming you are in the src directory, is as simple as:
$ ./gcmc -o output.ngc input.gcmc

This will convert the input file "input.gcmc" into a G-code file "output.ngc". The output is written to stdout if no -o option is given. Stdin is used if no input file is given.

You may compile and inspect the examples by running (from the top or the example directory):
$ make examples

This will give you G-code, SVG and DXF versions of the examples, which can be inspected with the appropriate programs.

The gcmc man-page gives you a complete summary of all option.

Changes

gcmc-1.9.0 - 2022-06-07
  • Feature: Add a debugger to debug gcmc scripts
  • Feature: Add SVG options -svg-no-pedantic and --dxf-no-pedantic to suppress warning about functions that cannot be mapped to the output format
  • Feature: Add SVG control of line width, color and opacity as special svg functions
  • Change: Make angular units consistent across the application by defaulting to radians; use the --degrees option for old behaviour
  • Fix: XZ-arc where radius sign was reversed
  • Fix: XZ-arc examples were wrong too
  • Fix: Properly highlight sign() function in syntax file
  • Fix: Do not emit unit-mismatch on comparison with literal constant zero
  • Fix: Cross-builds can now be both 32 and 64 bits and DLLs are properly collected
gcmc-1.8.3 - 2019-07-07
  • Fix: arc_* functions could generate a NaN in the SVG output
  • Fix: NaN and Inf now include sign due to changes newer printf behavior
gcmc-1.8.2 - 2017-02-19
  • Fix: spindle() function must first set speed with S before enabling spindle with M3/M4
gcmc-1.8.1 - 2017-02-11
  • Fix: Use-after-free bug in filename referencing when handling includes
  • Fix: Split the Bezier min-length and co-linear calculations to become slightly more accurate
gcmc-1.8.0 - 2016-07-25
  • Feature: Convert all internal string handling to Unicode (wchar_t)
  • Feature: to_float() and to_int() now can convert strings to values including units
  • Feature: Functions insert(), delete(), head(), tail() and reverse() can now operate on strings
  • Feature: Allow strings to be indexed as rvalues, returning the indexed character as string
  • Feature: Add to_val() and to_chr() functions to allow character manipulations
  • Feature: Add relocate() function to support adhoc relative offsets
  • Feature: Add TODO (wish)list
  • Fix: Several interpreter memory leaks plugged using valgrind
  • Fix: Allow delete() to delete all entries
  • Fix: Use correct source argument in insert() to insert into target
  • Fix: Fix relative arcs, specifically SVG, to use the correct movement
  • Fix: Fix arcs and circles, use global position whith undef end coord.
For older changes see Changes page for details.

Bugs reports and feature requests

Please report any bugs you may encounter to gcmc _at_ vagrearg.org. Please include an example that triggers the bug.

If you want more/extra/different features included, then write me an email with the request and a description what you want to add and want to achieve with the change or addition.

Gcmc documentation

gcmc man-page All command-line options and switches.
gcmc introduction page Starting with a simple step-by-step introduction to the basic concepts and ending with the creation of an example to create involute gears.
gcmc syntax page Detailed description of language syntax and its semantics.
gcmc function reference page All built-in functions described with all parameters, types and operational modes.
gcmc library page Library functions are more complex operations like tool compensation and canned drill sequences.

Gcmc examples and screenshots

(click on images to enlarge)

Text fonts (source: text-fonts.gcmc)

Text on a circle path (source: text-on-circle.gcmc)

Involute gears (sources: involute-gear.gcmc and involute-gear.inc.gcmc)


Cycloids (source: cycloids.gcmc)


Ball-in-a-Cube (source: ball-in-cube.gcmc)


Continuous curvature pocketing (sources: cc_hole.gcmc and cc_hole.inc.gcmc)


Sunflower floret arrangement of 500 holes (source: floret-vogel.gcmc)
Rapid path is about 55.5 meters without sorting the individual holes:

Sorting the holes with a simple nearest neighbor algorithm shortens the rapid path to about 4.1 meters:

Using a bin-sorting algorithm shortens the rapid path to about 3.7 meters using 20 bins:


Tool-size compensation of an open or closed path on either left or right side (source: tool-compensate.gcmc)


High-speed milling using trochoidal movement (source: trochoidal.gcmc)


Executive Decision Maker Pro box example (source)
NGCSVG
edm-pro-ngc edm-pro-svg
DXF
edm-pro-dxf
 
Cutter example (source)
NGCSVG
cutter-ngc cutter-svg
DXF
cutter-dxf
 
Wheels example (source)
NGCSVG
wheels-ngc wheels-svg
DXF
wheels-dxf


Posted: 2013-11-04
Updated: 2015-05-14

 
 
Overengineering @ request