Help‎ > ‎

Editing post processor script files

For some features of g-code output, there may not be a simple configuration parameter that can be set.

It may be necessary to edit the script file, or make some new script files.

If your installation of HeeksCNC is just making output for one milling machine, then it may be ok to edit the script files directly.
For example, to remove the "O123(Test program)" output that appears at the top of the program, you could simply edit the python file
"", found here "C:\Program Files (x86)\HeeksCNC\HeeksCNC\nc"

(For editing Python script files, it is best to use an editor designed for the job because Python files should not contain a mixture of SPACE characters and TAB characters.
I use "Editra" for editing Python script files.)

If you search for "program_begin" in "", you will find its' definition:

    def program_begin(self, id, name=''):
        self.write((self.PROGRAM() % id) + self.SPACE() + (self.COMMENT(name)))

This is a function, which will be called at the beginning of each program output.
You can stop it outputting the "O123(Test program)", by changing it to:

    def program_begin(self, id, name=''):

Or you could change it to output something of your own design, like this:
    def program_begin(self, id, name=''):
        self.write('(Program number = ' + str(id) + ' and the name is "' + name + '")\n"')

The problem with this approach, is that one day you might want to upgrade to a newer version of HeeksCNC, in which "" has changed.
You will then have to carefully merge your changes with the changes made by Heeks Software.

So, for a more permanent solution, it is better to make your own Python machine file.
This would be a machine definition, which inherits from the "" code, and adds its own changes.

Like this: Here is the contents of a sample file called "", which must be put in the same folder as the existing ""

import nc
import iso

class Creator(iso.Creator):
    def __init__(self):

    def program_begin(self, id, name=''):

nc.creator = Creator()

This will output the same as the "iso" machine, except it will perform "program_begin" differently.

There are various parts of the iso output which are defined as functions.
For example there is code to output a space between each g-code command.
It is:
    def SPACE_STR(self): return ''

which means that the default is to not output a space.

You can add this to your "" script:
    def SPACE_STR(self): return ' '

and you will get spaces between each command.

If you are a Python programmer, you can configure any kind of NC output from HeeksCNC.

Here are some other common post-processor hacks
Output in Microns