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:
- Open your project containing completed CAM operations and double-click the Job object in the tree view to open the Job Edit panel.
- Navigate to the Output tab.
- Locate the Processor dropdown menu. FreeCAD
includes numerous pre-installed post-processors for various platforms
(e.g.,
grbl,linuxcnc,centroid,marlin,haas,mach3_4). - Select the script corresponding to your controller hardware and firmware.
- 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. - Click OK to save the job settings.
2. Configure Processor Arguments
Many FreeCAD post-processors accept optional arguments to alter the generated code structure:
- Return to the Output tab of your Job settings.
- 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 toNdecimal places.--inchesor--metric: Forces units regardless of the document's native display units.--no-comments: Strips human-readable comments to save memory on older controllers.
- Multiple arguments can be separated by spaces.
3. Generate the Machine Dialect Code
Once the operations and processor settings are defined:
- Select the Job object or select specific operations within the Job in the Tree view.
- 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.
- A file save dialog will appear. Confirm the file destination, name, and file extension.
- Click Save. FreeCAD parses the internal motion vectors and tool commands, translating them into the chosen controller dialect.
- 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:
- Locate the default post-processor scripts in the FreeCAD
installation directory under
Mod/CAM/Path/Post/scripts(orMod/Path/PathScripts/postin older versions). - 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/
- Linux:
- Any
.pyfile placed in the user directory will automatically appear in the Job setup processor selection list, overriding system defaults with the same name.