Post Processor System

The format of generated gcode files can be controlled using post processor definitions. These definitions can be created, copied and modified within the Post Processors section of the System tab.

The post processor used for a specific drawing is set under the machining options. Select the machining folder in the drawing tree and look in the Post Processor group of the machining properties. If no post processor is specified, the default post processor will be used.

[New! 0.9.8N]

To set the default post processor, right click the definition in the Post Processors section of the System tab, then select Set As Default. The default definition will be marked with a green arrow.

Machining Properties

Post Processor

This option is a drop down list that contains all the custom post processors defined in the system folder.

Leave this blank to use the default post processor.

Post Processor Macros

This option is used to pass user defined macros from the drawing to the post processor. This is a multi-line text field containing multiple macro definitions in the format $macro=value.

Example:
$o=1234
$stock_height=0.4

Post Processor Management

The list of available post processors is accessed from the Post Processor folder of the system tab. Here, post processor definitions can be created, modified, copied, renamed and deleted.

New post processors can be created via the context menu visible when right clicking the post processor folder. Alternatively, existing definitions can be copied, pasted then modified. This is a good way of creating variations of a working post processor.

If post processor files are modified or new ones created outside of CamBam or in another CamBam instance, the post processor list should be refreshed using the Tools - Reload Post Processors menu option.

Post processors are XML files with a .cbpp file extension, stored in the \post sub folder of the system folder.

Post Processor sections

The post processor definition contains a number of sections. Each section can contain a mixture of literal text, which is output to the destination gcode file directly, and text macros of the format {$macro}. The macro definitions are defined within other sections of the post processor, or by defining user macros in the Post Processor Macros property of drawing's machining options. The macros are evaluated and the resulting text values are written to the gcode output.

Note: If any of the following sections are not visible in the property editor, make sure the Advanced property view button is selected.

(Main) - Post File

This section defines the general structure of the gcode file. It typically includes three macros that are evaluated internally based on rules defined in further sections of the post processor.

{$header} - This macro is evaluated using the Header section described below.
{$mops} - This macro is evaluated to a list of blocks of text, one block per each machining operation. Each block is formatted using the rules in the MOP section.
{$footer} - This macro is evaluated using the Footer section described below.

Example:

%
O{$o}
( MY FANUC POST )
{$header}
G0 X10Y10Z0
{$mops}
{$footer}
%
Note: The value of {$o} macro is passed to the post processor using the drawing's Post Processor Macros property which may contain a value such as '$o=1234'.

The % characters are output literally and would be omitted if not using an RS232 file transfer program.

(Main) - Header

Defines the text rules used by the {$header} macro.

Example:

{$comment} {$cbfile.name} {$date} {$endcomment}
{$tooltable}
{$comment} CUTVIEWER {$endcomment}
{$comment} FROM/0,0,5 {$endcomment}
{$comment} TOOL/MILL,1,0,20.0,0 {$endcomment}
{$comment}STOCK/BLOCK,{$stock_width},{$stock_length},
    {$stock_height},{$stock_x},{$stock_y},{$stock_z} {$endcomment}
{$cbfile.header}
{$units} {$distancemode} {$velocitymode} {$cuttercomp(off)}
{$toolchange(first)}
G54 ( Use fixture 1 )
{$clearance}

Once again, the Post Processor Macros property is used to pass the {$stock_...} macros to the post processor, which in this example may contain text such as:

$stock_length=150
$stock_width=150
$stock_height=12.7
$stock_x=75
$stock_y=75
$stock_z=12.7

(Main) - Footer

Defines the text rules used by the {$footer} macro.

Example:

{$clearance}
G28 G91 Z0
G90 G53 X-15.0 Y0.0
M09
{$spindle(off)}
{$endrewind}

(Main) - MOP

Defines how each item of the {$mops} macro is formatted. This information will be repeated in the gcode output for each active machining operation.

Example:

{$comment} {$mop.name} {$endcomment}
{$toolchange}
{$velocitymode} {$workplane}
{$mop.header}
{$spindle} {$s}
{$blocks}
{$mop.footer}

(Main) Start Cut

[New! 0.9.8L]

Macro to use when about to feed cut. This may be used for plasma or laser cutters to power on the cutting tool.

The start of cutting is determined when a feed move is detected where Z is below the stock surface.

(Main) End Cut

[New! 0.9.8L]

Macro to use when finished a feed cut. This may be used for plasma or laser cutters to power off the cutting tool.

The end of cutting is determined when a rapid is detected or a feed move where Z is at or above the stock surface.

For example, to power off a laser to avoid holding tabs, use square holding tabs and set the holding tab height so that the top part of the tab move is above the stock surface. The Start Cut macro will then be invoked when the feed move resumes below the stock surface.

(Main) Post Processor Macros

[New! 0.9.8N]

This property can be used to set default values for any custom macros used in the post processor.

Custom macro values will be overridden by the values set in the Post Processor Macros property of the machining options.

Tools - Tool Table Item

Defines how each item of the {$tooltable} macro is produced. Tool tables are typically inserted in the header of a file and contain commented text describing the list of tools that will be used in the gcode file.

Example:

{$comment} T{$tool.index} : {$tool.diameter} {$endcomment}

Tools - Tool Change

Defines how the {$toolchange} macro is formatted.

Example:

{$clearance}
{$comment} T{$tool.index} : {$tool.diameter} {$endcomment}
{$comment} Tool Radius and Taper coming soon {$endcomment}
{$comment} TOOL/MILL, {$tool.diameter}, {$tool.radius}, 
    {$tool.length}, 0 {$endcomment}
T{$tool.index} M6

G Codes - G0, G1, G2, G3, G81, G82, G83

These sections define how the commonly used gcode operators are output.

G Codes - Arc Center Absolute

Used in the {$mop.header} macro to specify that ArcCenterMode is set to Absolute. Mach3 recognizes G90.1

G Codes - Arc Center Incremental

Used in the {$mop.header} macro to specify that ArcCenterMode is set to Absolute. Mach3 recognizes G91.1

G Codes - Canned Cycle Start

[New! 0.9.8h]

Code sequence used at the start of a group of canned cycle blocks. Typically G98 for initial level return after canned cycles.

G Codes - Canned Cycle End

[New! 0.9.8h]

Code sequence used at the end of a group of canned cycle blocks. Typically G80.

G Codes - Cutter Comp Off, Cutter Comp Left, Cutter Comp Right

[New! 0.9.8h]

Used in the {$cuttercomp(off|L|R)} macros. Typically Off=G40, Left=G41, Right=G42.

G Codes - Distance Absolute, Distance Incremental

[New! 0.9.8h]

Typically absolute=G90, incremental=G91. NOTE! Incremental distance mode is not currently supported.

G Codes - Units (Inches), Units (Metric)

[New! 0.9.8h]

Typically inches=G20, millimeters=G21.

G Codes - Velocity Mode - ExactStop, Velocity Mode - Constant Velocity

[New! 0.9.8h]

Typically exact stop=G61, constant velocity=G64.

G Codes - Workplane XY, Workplane XZ, Workplane YZ

[New! 0.9.8h]

Typically XY=G17, XZ=G18, YZ=G19.

G Codes - X Mode Diameter

Used in the {$lathexmode} macro to specify that X values are in diameter mode. For example; EMC2 recognizes G7.

G Codes - X Mode Radius

[New! 0.9.8h]

Used in the {$lathexmode} macro to specify that X values are in radius mode. For example; EMC2 recognizes G8.

M Codes - End Rewind

Typically M30.

M Codes - Repeat

[New! 0.9.8h]

Typically M47.

M Codes - Spindle CW, Spindle CCW, Spindle Off

[New! 0.9.8h]

Typically CW=M3, CCW=M4, Off=M5.

M Codes - Stop

[New! 0.9.8h]

Typically M0.

Moves - Rapid, Feed Move, Arc CW, Arc CCW

These sections define how the commonly used gcode move instructions are formatted.

Example:

Rapid
{$g0} {$_f} {$_x} {$_y} {$_z} {$_a} {$_b} {$_c}
Feed Move
{$_g1} {$_f} {$_x} {$_y} {$_z} {$_a} {$_b} {$_c}
Arc CW
{$g2} {$_f} {$_x} {$_y} {$_z} {$i} {$j}
Arc CCW
{$g3} {$_f} {$_x} {$_y} {$_z} {$i} {$j}
Note: The gcode operators {$g...} and their parameters can specified using an underscore ( _ ) prefix. This is to show values that are modal (or sticky). That is, they will only be output if the current value has changed. Omitting the underscore will force the parameter to be always output.

Canned Cycles - Drill, Drill Dwell, Drill Peck

These sections define how the commonly used canned cycle instructions are formatted.

Drill
{$g81} {$_x} {$_y} {$_z} {$_r} {$_f}
Drill Dwell
{$g82} {$_x} {$_y} {$_z} {$p} {$_r} {$_f}
[p]Drill Peck[p]
{$g83} {$_x} {$_y} {$_z} {$p} {$_q} {$_r} {$_f}

Lathe - Lathe Tool Radius Offset

If False, the toolpath at the center of the tool radius is output.

If True, an appropriate tool radius offset is applied. The toolpath will be offset by a negative tool radius in the lathe X axis. The direction of the Z tool radius offset is determined by the cut direction. For right hand cuts the toolpath Z will be offset by a negative tool radius. For left hand cuts, a positive tool radius Z offset is used.

Tool radius offsets

In the diagram above, the red cross represents the toolpath reference point when Lathe Tool Radius Offset is set True. If False, the dot at the tool radius center will be the reference point. The reference point is sometimes referred to as the 'Imaginary' or 'Virtual' tool point.

Lathe - Lathe X Mode

For lathe operations, specifies whether X values are radius or diameter mode.

Line Numbering

[New! 0.9.8N]

Line Numbering - Add Line Numbers

If True then line numbers will be inserted at the begining of g-code lines.

Line Numbering - Line Number Format

Controls how the line number values are presented. '0' characters denote a place holder that will contain either a significant digit or a 0. A '#' character will output a significant digit or space character where there is no significant digit at that position.

Line Numbering - Line Number Increment

Line numbers will be incremented by this amount each time a line number is added.

Line Numbering - Line Number Prefix

This text (typically an 'N' character) will be written before the line number value.

Line Numbering - Line Number Skip

Lines where the first non space character is in this list will not receive a line number.

Line Numbering - Line Number Space After

If True then a space character will be inserted after the line number value.

Line Numbering - Line Number Start

The initial for the first line number used.

Options - Arc Output

Controls how arcs are output to gcode.
If Convert To Lines, small line moves are used rather than arc commands.
Helix Convert To Lines is similar to Convert To Lines, but only for helical arcs (i.e. arcs with varying Z).

Options - Arc Center Mode

[New! 0.9.8N]

This property controls whether the I and J parameters for arc moves (G2, G3) use absolute coordinates or incremental, relative to the arc end points. If this setting is different to the way the CNC controller interprets arc moves, the resulting toolpath may look a mess of random arcs in the controller.

Default When default is set in the drawing's machining properties, the post processor Arc Center Mode will be used. A default value in the post processor will use Incremental (C-P1).

Absolute I & J are absolute coordinates of the arc center point.

Incremental (C-P1) I & J are coordinates of the arc center, offset from the first arc point. This is the typical incremental mode. In previous versions this option was just called Incremental.

Incremental (P1-C) I & J are offsets of the first arc point from the arc center.

Incremental (C-P2) I & J are arc center offsets from the second arc point.

Incremental (P2-C) I & J are offsets of the second arc point from the arc center.

Options - Arc To Lines Tolerance

If Arc Output=Convert To Lines is used, this value controls the maximum allowed error when converting arcs to lines. Smaller tolerances will result in smoother curves but larger files.

Options - Clearance Plane Axis

Used to specify which direction clearance moves are made. Usually Z, but may be set to X or Z for lathe operations.

Options - Comment, End Comment

Defines the text to be used at the beginning and end of a comment.

Example 1:

Comment: (
End Comment: )

Example 2:

Comment: ;
End Comment:

Options - End Of Line

[New! 0.9.8h]

Character sequence used at the end of a line. Escape code \r and \n can be used.

Options - Invert Arcs

Controls the behaviour od XZ (G18) arcs only.

For milling operations, this should be set False. The direction of the g-code arcs will then be relative to the positive Y axis (using a right hand coordinate system).

For lathe operations, this should usually be set True. Lathe arc directions are typically relative to the 'Up' direction. This would imply a positive Y axis using a left hand coordinate system. CamBam's drawing view is a right hand coordinate system so XZ arcs would need to be inverted when written to g-code.

Note: Coordinate handedness can be determined by pointing your thumb in the direction of positive X, second finger in the postive Y axis and third (middle) finger in the positive Z axis direction.

Options - Minimum Arc Length

A numerical value that controls the precision limits used for outputting arc moves (G2, G3). If the length of an arc is less than the Minimum Arc Length value then a straight move (G1) is used instead. This is useful for TurboCNC users where very small arcs can cause glitches that may appear as dimples in the toolpath.

Example:
Minimum Arc Length=1e-4

Options - Maximum Arc Radius

A numerical value that controls the maximum radius allowed for arc moves. If an arcs radius exceeds this value, a straight line move (G1) is used.

Example:
Maximum Arc Radius=1e6

Options - Number Format

This is a string formatting pattern that controls how floating point numbers are displayed.

A hash character (#) denotes an optional digit place holder and a 0 character denotes a digit that is always displayed, adding padding zeros if required.

It can also change the gcode instructions that are required. For example, if a toolpath contains a move from X=1.234 to X=1.233 and a number format of #.#0 is used, no move instruction will be written to the gcode as the coordinates are identical when formatted to 2 decimal places.

Options - Rapid Down To Clearance

[New! 0.9.8i]

If set True, and Z is above the clearance plane a rapid down to the clearance plane is used.
If False the current Z is maintained.

Options - Suppress Parser Errors

[New! 0.9.8L]

The post processor will parse gcode as it is created to update internal values such as registers. This can produce error messages for post processors that produce non-standard gcode. In many cases the gcode will still be correctly generated and the error messages can be ignored.

Setting Suppress Parser Errors to True will prevent the gcode parsing errors being displayed, which may otherwise hide genuine error messages.

Options - Upper Case

If set to True, the post processor converts all text written to the gcode file to upper case. This is particularly useful for Fanuc posts that do not support lower case characters.

Post Build - Post-Build Command and Post-Build Command Args

[New! 0.9.8j]

Post-Build Command can be used to specify an external application to modify the gcode produced from the post processor.

Post-Build Command Args contains any arguments to pass to the application.
The following macros are recognised:
{$outfile} is the filename of the raw gcode output.
{$cbfile.name} is the short name of the current CamBam document.

Note: Double quotes should be used in command arguments to avoid problems with spaces in filenames.

Example:
Post-Build Command=C:\bin\gcodelinenums.exe
Post-Build Command Args="{$outfile}" "{$outfile}.out"

Post Processor Macros

$arc.i
$arc.j
$arc.k
[New! 0.9.8L]

Outputs the I, J or K register value of the current arc move.

The register 'I', 'J' or 'K' prefix is not output.

$arc.radius
[New! 0.9.8L]

Outputs the radius of the current arc move.

Arcs that sweep 0 to 180 degrees will have a positive radius and arc sweeps > 180 to 360 degrees will output a negative radius.

$arc.start
$arc.sweep
$arc.end
[New! 0.9.8N]

Outputs the start, end or sweep angle of the current arc move.

Angles are measured in degrees, with 0 degrees along +X axis.

CCW arcs will have a positive sweep angle. CW arcs will have a negative sweep angle.

$blocks

This macro is generated internally and contains all the move instructions required by the current machine operation (MOP)'s.

$comment

Inserts the text defined in the Comment section of the post processor.

$cbfile.footer

Inserts the drawing’s Custom File Footer Machining option.

$cbfile.header

Inserts the drawing’s Custom File Header Machining option.

$cbfile.name

Inserts the drawing’s Name property.

$check(x,y,z)

Generated internally, this macro checks the x,y,z coordinate parameters against the current tool location. If different, a sequence of moves will be inserted to move to the new position, using the clearance plane and plunge feed rates where necessary.

$clearance

Rapids to the clearance plane.

$cuttercomp(off|L|R)

Cutter radius compensation. Note: CamBam does not currently calculate radius compensation codes for toolpaths.

Inserts the text defined in the Cutter Comp Off, Cutter Comp Left or Cutter Comp Right sections of the post processor.

Typically Off=G40, L=G41, R=G42

$date

Inserts the current date time stamp

$distancemode

Inserts the distance mode in use. The values are defined in the Distance Absolute and Distance Incremental sections of the post processor.

Currently this always equates to Distance Absolute (typically G90).

$endcomment

Inserts the text defined in the End Comment section of the post processor.

$endrewind

Inserts the text defined in the End Rewind section of the post processor.

Typically M30.

$footer

Evaluates the text in the Footer section of the post processor.

$g0, $g1, $g2, $g3
$g81, $g82, $g83
$_g0, $_g1, $_g2, $_g3
$_g81, $_g82, $_g83

These Gcode macros control how the gcodes are output. The format of each code is taken from the G... definitions in the post processor. This may be useful to control zero padding (eg G1 vs G01), or to use alternative G codes.

If the underscore (_) prefix is used, these instructions are assumed to be modal (or sticky). That is; the first occurrence of the code will be written but omitted if following blocks use the same instruction.

$header

Evaluates the text in the Header section of the post processor.

$mop.clearanceplane
[New! 0.9.8L]

Outputs the Clearance Plane value of the current machining operation.

$mop.cutfeedrate
[New! 0.9.8L]

Outputs the Cut Feedrate value of the current machining operation.

The 'F' register code prefix is not output.

$mop.depthincrement
[New! 0.9.8L]

Outputs the Depth Increment value of the current machining operation.

$mop.dwell
[New! 0.9.8L]

Outputs the Dwell value of the current drilling operation.

$mop.first.x
$mop.first.y
$mop.first.z
[New! 0.9.8N]

Insert the X, Y or Z coordinate of the first toolpath point of the current machining operation.

This macro may be useful after a tool change command, to move to the next machining X, Y coordinate at the tool change height, before plunging to the clearance plane.

$mop.footer

Inserts the current machining operation's Custom MOP Footer property.

$mop.header

Inserts the current machining operation's Custom MOP Header property.

$mop.holediameter
[New! 0.9.8L]

Outputs the Hole Diameter value of the current drilling operation.

$mop.name

Inserts the current machining operation's Name property.

$mop.peckdistance
[New! 0.9.8L]

Outputs the Peck Distance value of the current drilling operation.

$mop.plungefeedrate
[New! 0.9.8L]

Outputs the Plunge Feedrate value of the current machining operation.

The 'F' register code prefix is not output.

$mop.retractheight
[New! 0.9.8L]

Outputs the Retract Height value of the current drilling operation.

$mop.stocksurface
[New! 0.9.8L]

Outputs the Stock Surface value of the current machining operation.

$mop.tag
[New! 0.9.8L]

Outputs the Tag value of the current machining operation.

$mop.targetdepth
[New! 0.9.8L]

Outputs the Target Depth value of the current machining operation.

$move.x
$move.y
$move.z
[New! 0.9.8L]

Outputs the X, Y or Z register value of the current move.

The register code is not output.

$mops

Inserts a list of objects, one item for each enabled machining operation. Each list item is defined using the MOP section definition of the post processor.

$part.name

Inserts the name of the current part.

$post.toolchange
[New! 0.9.8N]

Inserts the post processor tool change macro. This may be useful to include in the tool definition Tool Change property.

$repeat

Inserts the text defined in the Repeat section of the post processor.

Typically M47.

$s

Inserts the current machining operation's Spindle Speed property.

$set(x|y|z|a|b|c|f|p|q|r,<value>)
[New! 0.9.8L]

Sets the current value of the specified X, Y or Z register. No gcode will be output.

Example:

$set(z,5.5)

This may be useful after a custom, controller based tool change macro, to inform the post processor of the controller's new coordinates.

The value NaN can also be used to set the register to an undefined state.

$spindle

Inserts a macro depending on the current machine operation's Spindle Direction property.

Nothing will be written to the gcode if the spindle is already in this state.

$spindle(off|cw|ccw)

Inserts the text defined in the Spindle Off, Spindle CW or Spindle CCW sections of the post processor.

Typical values are cw=M3, ccw=M4, off=M5

$stock.xsize, $stock.width, $stock_width

The X size of the stock block defined in the Machining or Part object.

Example: (For CutViewer STOCK definition)

{$comment} STOCK/BLOCK,{$stock_width},{$stock_length},{$stock_height},{$stock_x},{$stock_y},{$stock_z} {$endcomment}

$stock.ysize, $stock.length, $stock_length

The Y size of the stock block defined in the Machining or Part object.

$stock.zsize, $stock.height, $stock_height

The Z size of the stock block defined in the Machining or Part object.

$stock.xoffset

The X coordinate of the lower left corner of the stock block (relative to the machine's XY(0,0)), defined in the Machining or Part object.

$-stock.xoffset, $stock_x

The minus X coordinate of the lower left corner of the stock block (relative to the machine's XY(0,0)), defined in the Machining or Part object.

$stock.yoffset

The Y coordinate of the lower left corner of the stock block (relative to the machine's XY(0,0)), defined in the Machining or Part object.

$-stock.yoffset, $stock_y

The minus Y coordinate of the lower left corner of the stock block (relative to the machine's XY(0,0)), defined in the Machining or Part object.

$stock_z

The minus Z coordinate of the lower left corner of the stock block (relative to the machine's XY(0,0)), defined in the Machining or Part object.

$stop

Inserts the text defined in the Repeat section of the post processor.

Typically M0.

$tool.comment
[New! 0.9.8N]

Inserts the Comment property from the tool library for the current tool.

$tool.diameter

Inserts the current machining operation's Tool Diameter property.

Note: The $tool.diameter macro will not be defined until there has been a tool change command. If used in the header section, use a tool change such as $toolchange(first) before referring to $tool.diameter.

$tool.index

Inserts the current machining operation's Tool Number property.

$tool.length

Inserts the tool length property from the tool definition in the tool library.

$tool.name
[New! 0.9.8N]

Inserts the current tool's Name property (from tool library) or T(tool number) if there is no tool library entry.

$tool.profile
[New! 0.9.8L]

Inserts the Tool Profile property of the current tool.

$tool.radius

Uses the current machining operation's Tool Profile property to determine a radius. 0 for end mills and Diameter / 2 for bullnose.

$tool.veeangle
[New! 0.9.8N]

Inserts the current tool's Vee Angle property (from tool library) or 0 if there is no tool library entry.

$toolchange

Inserts a tool change instruction, based on the Tool Change definition in the post processor. If the tool number has not changed, no tool change code is inserted.

$toolchange(first)

Inserts a tool change instruction using the first tool in the current drawing's tool table.

$tooltable

Inserts a description for each tool that is referenced in the current drawing. Each item in the list is formatted using the Tool Table Item definition in the post processor.

$units

Outputs the drawing's Units property.

The codes used are taken from the Units (Inches) or Units (Metric) sections of the post processor.

Typically Inches = G20, Millimeters = G21.

$velocitymode

Inserts the current machining operation's Velocity Mode property

The codes used are taken from the Velocity Mode - Constant Velocity or Velocity Mode - Exact Stop sections of the post processor.

For example: Mach3 uses Exact Stop=G61, Constant Velocity=G64.

$workplane

Inserts the current machining operation's Work Plane property.

The codes used are taken from the Workplane XY | XZ | YZ sections of the post processor.

Typically XY=G17, XZ=G18, YZ=G19.

$x, $y, $z, $a, $b, $c
$i, $j, $f, $r, $p, $q
$_x, $_y, $_z, $_a, $_b
$_c, $_i, $_j, $_f, $_r
$_p, $_q

These macros insert the parameters used in common Gcode move operations. If an underscore (_) prefix is used, these parameters are treated as modal. That is they will only be output if the current value has changed. Omitting the underscore will force the parameter to be always output.

These macros will include the register code as well as the value, for example $x = X1.23

$xneg, $yneg, $zneg, ...
[New! 0.9.8h]

The same as the other register macros ($x, $_y etc), but with the value sign reversed.

$xabs, $yabs, $zabs, ...
[New! 0.9.8h]

The same as the other register macros ($x, $_y etc), but with the value always positive.

Copyright (c) 2017 HexRay Ltd