Postprocessor Configuration

Introduction

This wiki page gives a overview about the Intention of different section and variable names which allows configuration of the postprocessor. It is possible to have more then one postprocessor configuration file.

Using different Postprocessor files

While the tool is not directly integrated it is possible to have different postprocessor configuration files. You can choose between all valid postprocessor configuration files stored in the \postpro_config directory.

Postprocessor Version

This description is valid for the dxf2gcode pyQt4 Version starting with svn rev. 417 dated August 2013.

Explanation of the Sections

Do not edit any section or variable names, this will result in Import errors while dxf2gcode is initialising.

#  Section and variable names must be valid Python identifiers
#      do not use whitespace in names

# do not edit the following section name:

This is the introduction of the postprocessor file. There is no Need to Change it.

Version

[Version]

    # do not edit the following value:
    config_version = 4

This section is intended for changes of the prostprocessor file itself. While the tool evolves over time this counter will be increased to indicate that the configuration of the postprocessor was changed.

General

[General]
    output_format = .ngx
    output_text = G-CODE for EMC2
    output_type = g-code

This three configurations are shown in the save file dialog and are used by the user to differentiate between the possibly different postprocessor configurations.

    abs_export = True
    cancel_cc_for_depth = False
    cc_outside_the_piece = True
    export_ccw_arcs_only = False
    max_arc_radius = 10000.0
    export_arcs_as_lines = False
  • abs_export possible values are True and False. This may be used for G90 or G91 code which switches between absolute and relative coordinates.
  • cancel_cc_for_depth; possible values are True and False. If the cutter compensation is used e.g. G41 or G42 this option may cancel the compensation while the depth (Z-Axis) is used and enable the compensation again after the depth is reached.
  • cc_outside_the_piece; possible values are True and False. If the cutter compensation is used this will cancel the cutter compensation with G40 after the tool is retracted to the retraction area.
  • export_ccw_arcs_only; possible values are True and False. This my be used for the export to dxf which only accepts arcs which are in counterclockwise direction. Turning this on for normal G-Code will cause in unintended outputs.
  • max_arc_radius; this values indicated which arc's with radius higher then this value will be exported as a line.
  • export_arcs_as_lines; set this to true if you want to export als arcs as line segment, e.g. your maschine can't handle G2 or G3 commands. The tolerance as given for import will be used to define the number of segments.
    code_begin_mm = G21 (Unit in mm)
    code_begin_in = G20 (Units in inches)
    code_begin =  G90 (Absolute distance mode) G64 P0.001 (Exact Path 0.001 tol.) G17 G40 (Cancel diameter comp.) G49 (Cancel length comp.)
    code_end = M2 (Prgram end)
    

This is code which will be written at the very begin and end of the exported file.

Number Format

[Number_Format]
    pre_decimals = 4
    post_decimals = 3
    decimal_seperator = .
    pre_decimal_zero_padding = False
    post_decimal_zero_padding = True
    signed_values = False

This is the section which enables the user to change the formatting of the eported numbers. This example has a fixed length for the numbers: e.g. ' 100.000' ' 10.000' ' 1.000'

  • pre_decimals; gives the identation for the values.
  • post_decimals; gives the accuracy of the output after which will be rounded.
  • decimal_seperator; give the separator which is used (e.g. (.) or (,))
  • pre_decimal_zero_padding; If true all values will be given with zeros up to pre_decimals (e.g. 0001.000)
  • post_decimal_zero_padding; If false e.g. 1.000 will be given as 1 only.
  • signed_values; if True 1.000 will be givne as +1.000

Line Numbers

[Line_Numbers]
    use_line_nrs = False
    line_nrs_begin = 10
    line_nrs_step = 10

Enables the user to have lines numbers for the exported G-Code.

Program

[Program]
    tool_change = T%tool_nr M6%nlS%speed%nl
    feed_change = F%feed%nl
    rap_pos_plane = G0 X%XE Y%YE%nl
    rap_pos_depth = G0 Z%ZE %nl
    lin_mov_plane = G1 X%XE Y%YE%nl
    lin_mov_depth = G1 Z%ZE%nl
    arc_int_cw = G2 X%XE Y%YE I%I J%J%nl
    arc_int_ccw = G3 X%XE Y%YE I%I J%J%nl
    cutter_comp_off = G40%nl
    cutter_comp_left = G41%nl
    cutter_comp_right = G42%nl
    pre_shape_cut = M3 M8%nl
    post_shape_cut = M9 M5%nl
    comment = %nl(%comment)%nl

This section gives the format how different actions of the export have to be interpreted. These actions will be done for each export of a shape, line, arc, tool change, feed change etc.

  • tool_change; this will be done after each layer. If different tools are used.
  • feed_change; this will be done after each change between cutting in plane or depth
  • rap_pos_plane; this will be done between each shape to cut.
  • rap_pos_depth;
  • lin_mov_plane;
  • lin_mov_plane;
  • arc_int_cw;
  • arc_int_ccw;
  • cutter_comp_off;
  • cutter_comp_left;
  • cutter_comp_right;
  • pre_shape_cut; This will be done before starting to cut a shape/ contour.
  • post_shape_cut; This will be donw after cutting a shape or contour.
  • comment; at some places during the export more comments are given to make the code better readable.

The following section gives the possible key words which may be used in the actions explained above.

"%feed"
The feed rate used

"%speed"
The tool speed used

"%tool_nr"
The tool Nr.used

"%nl"
New line to be included

"%XE"
The X position at the end

"%-XE"
The negative X position at the end

"%XS"
The X position at the begin

"%-XE"
The negative X position at the end

"%YE"
The Y position at the end

"%-YE"
The negative Y position at the end

"%YS"
The Y position at the begin

"%-YS"
The negative Y position at the end

"%ZE"
The Z position at the end

"%-ZE"
The negative Z position at the end

"%I"
The distance between Start and Centre in X

"%-I"
The neg. dis. between Start and Centre in X

"%J"
The distance between Start and Centre in Y

"%-J"
The neg. dis. between Start and Centre in Y

"%XO"
The X Centre of an Arc

"%-XO"
The negative X Centre of an Arc

"%YO"
The Y Centre of an Arc

"%-YO"
The negative Y Centre of an Arc

"%R"
The radius of an Arc

"%AngS"
The starting angle of an Arc in deg.

"%-AngS"
The negative starting angle of an Arc in deg.

"%AngE"
The end angle of an Arc in deg.

"%-AngE"
The negative end angle of an Arc in deg.

"%ext"
The positiv extend angle of an Arc in deg.

"%-ext"
The negative extend angle of an Arc in deg.

"%comment"
The given comment in the code

Examples

[Postprocessor-Example China Laser Cutter] Example configuration for laser cutter
[Postprocessor-Example Python] Example configuration of export to python classes
[Postprocessor-Example Styrofoam] Example configuration of styrofoam cutters
[Postprocessor-Example Lathe] Example configuration of a lathe

Postprocessor Configuration Styrofoam

This is a configuration that will ignore the Z-Axis and turn "the spindle" (i.e. the heat of the hot wire) on before any movement and turn turn it off right before the end of the program. You will find it in a seperate Wiki Page.

FAQ - Frequently Asked Questions

How to replace the Axis Letters

For using different Axis just replace the leading letters. e.g. replace axes Y by Z:

rap_pos_plane = G0 X%XE Y%YE%nl
rap_pos_plane = G0 X%XE Z%YE%nl

How to replace the I and J Axis Letter for CW and CCW Arcs by a Radius R

For using radius instead of incremental I and J Axis distance to center of radius use the following:

    arc_int_cw = G2 X%XE Y%YE R%R%nl
    arc_int_ccw = G3 X%XE Y%YE R%R%nl

How to remove all comments from the export.

In order to remove all the comments at the begin of the code you need to change the output format to dxf type.

 [General]
output_type = dxf

All other comments in between the code can be removed by an option in the Program section.

[Program]
 comment = ""

How do i invert an axis or both axis

if you want to reverse the axis just put an addition negative sign there in the Postprocessor:
You need to do it on all positions where you find X and I values if you want to switch the X axis only. If you want to do it for the Y Axis do it for Y and J also. Therefor you need to change the followowing 4 lines to the following:

[Program]
rap_pos_plane = G0 X%-XE Y%-YE%nl
lin_mov_plane = G1 X%-XE Y%-YE%nl
arc_int_cw = G2 X%-XE Y%-YE I%-I J%-J%nl
arc_int_ccw = G3 X%-XE Y%-YE I%-I J%-J%nl

I want to remove the Z-Axis from my GCODE how can i do that

This may be required if you want to use DXF2GCODE to generate code for Laser cutting or styrofoam cutting. You can do the change in the GUI or also in the postprocessor file itself. Both ways are explained below

Method 1: GUI

You will find it in the postroprocessor configuration Graphical User Interface (GUI) in the left list >>G-code codes

Here you can see how it should look like in the GUI.

Method 2: Postprocessor Configuration File

Within the configuration files its in the [Program] - Section
The following two lines / parameters needs to be changed

[Program]
    # This will be done between each shape to cut.
    rap_pos_depth = G0 Z%ZE %nl
    # This will be used for shape cutting.
    lin_mov_depth = G1 Z%ZE%nl

Just remove all the content of the line and you will not have anything in the outputed g-code.

[Program]
    # This will be done between each shape to cut.
    rap_pos_depth =
    # This will be used for shape cutting.
    lin_mov_depth =

Related

Wiki: Home
Wiki: Postprocessor-Example China Laser Cutter
Wiki: Postprocessor-Example Lathe
Wiki: Postprocessor-Example Python
Wiki: Postprocessor-Example Styrofoam

Discussion

  • chrisko

    chrisko - 2015-04-22

    Feel free to comment here.

     
  • spicer

    spicer - 2019-02-17

    Nice tool.
    Linux CNC (EMC2) need O{number} in front of the IF command in the G-Code.
    I use a Plasma-Cutter. This need the spindle start after positioning the Z axis in the workposition and spindle stop before retraction Z axis.

    Temporary I solve the problem with the following in "Linear feed move for Z plane":

    #400 = [#400 + 1]%nlO[#400] IF [#<_spindle_on> EQ 0]%nl    M3 M8 G4 P2%nlO[#400] ENDIF%nlG1 Z%ZE%nl
    

    This generates the code:

    #400 = [#400 + 1]
    O[#400] IF [#<_spindle_on> EQ 0]
        M3 M8 G4 P2
    O[#400] ENDIF
    

    At the start:

    #400=100
    

    I removed M3 in "Placed in front of any shape".
    And add M5 in "Rapid positioning for Z plane":

    M5%nlG0 Z%ZE %nl
    

    Maybe someone knows a better solution.

     

    Last edit: spicer 2019-02-17

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.