How to Post-Process FreeCAD Toolpaths

Post-processing in FreeCAD converts generic internal toolpaths generated in the CAM (formerly Path) workbench into machine-specific G-code dialects tailored to your CNC controller, such as GRBL, LinuxCNC, Mach3, or Fanuc. This guide explains how to select the correct post-processor for your machine, configure custom export arguments, run the post-processing engine to output ready-to-run G-code files, and locate the underlying Python scripts for deeper customization.

1. Select the Post-Processor in the Job Setup

Machine dialect configuration is primarily controlled within the FreeCAD Job object:

  1. Open your project containing completed CAM operations and double-click the Job object in the tree view to open the Job Edit panel.
  2. Navigate to the Output tab.
  3. Locate the Processor dropdown menu. FreeCAD includes numerous pre-installed post-processors for various platforms (e.g., grbl, linuxcnc, centroid, marlin, haas, mach3_4).
  4. Select the script corresponding to your controller hardware and firmware.
  5. In the Output File field, define a default output destination and file extension (such as .nc, .gcode, .tap, or .ngc) required by your machine control software.
  6. Click OK to save the job settings.

2. Configure Processor Arguments

Many FreeCAD post-processors accept optional arguments to alter the generated code structure:

  1. Return to the Output tab of your Job settings.
  2. In the Arguments field, enter any flags supported by your chosen processor. Common arguments include:
    • --no-show-editor: Prevents FreeCAD from opening the generated G-code in an integrated text editor upon completion.
    • --precision=N: Sets floating-point coordinate precision to N decimal places.
    • --inches or --metric: Forces units regardless of the document's native display units.
    • --no-comments: Strips human-readable comments to save memory on older controllers.
  3. Multiple arguments can be separated by spaces.

3. Generate the Machine Dialect Code

Once the operations and processor settings are defined:

  1. Select the Job object or select specific operations within the Job in the Tree view.
  2. Click the Post Process button on the CAM workbench toolbar (represented by a green page icon with a yellow gear or sheet of code). Alternatively, choose CAM > Post Process from the top menu.
  3. A file save dialog will appear. Confirm the file destination, name, and file extension.
  4. Click Save. FreeCAD parses the internal motion vectors and tool commands, translating them into the chosen controller dialect.
  5. If the editor was not suppressed, review the generated G-code in the pop-up window to verify header commands (e.g., G17, G21, G90), tool changes (M6), and spindle triggers (M3).

4. Customizing Post-Processor Scripts

FreeCAD's post-processors are written in Python, allowing full access to edit existing dialects or develop custom machine scripts:

  1. Locate the default post-processor scripts in the FreeCAD installation directory under Mod/CAM/Path/Post/scripts (or Mod/Path/PathScripts/post in older versions).
  2. Custom or modified scripts should be placed inside your local FreeCAD user directory:
    • Linux: ~/.local/share/FreeCAD/CAM/Post/
    • Windows: %APPDATA%\FreeCAD\CAM\Post\
    • macOS: ~/Library/Application Support/FreeCAD/CAM/Post/
  3. Any .py file placed in the user directory will automatically appear in the Job setup processor selection list, overriding system defaults with the same name.