How to Generate Pocket Toolpaths in FreeCAD

Generating G-code toolpaths for pocket milling in FreeCAD involves preparing a 3D model, setting up a machining Job within the CAM (formerly Path) Workbench, applying a Pocket Shape operation, and running a post-processor. This step-by-step guide covers how to select your geometry, configure cutting depths and stepovers, simulate the toolpath to prevent collisions, and export ready-to-run G-code for your CNC controller.

1. Open the CAM Workbench and Create a Job

  1. Open your 3D model in FreeCAD (ensure your part contains a closed pocket feature).
  2. Switch to the CAM Workbench (labeled as Path in FreeCAD versions prior to v0.21) using the workbench drop-down menu.
  3. Click the Create Job button in the toolbar.
  4. In the Job dialog:
    • Geometry Tab: Ensure your part is selected as the base object.
    • Output Tab: Choose the appropriate Post Processor matching your CNC machine's controller (e.g., grbl, linuxcnc, marlin).
    • Setup Sheet / Stock Tab: Define the raw material dimensions, adjusting the stock bounding box and setting your Work Coordinate System (WCS) origin (X, Y, Z zero).
    • Tools Tab: Add an appropriate end mill from your tool library and assign it to the job.
  5. Click OK to create the Job.

2. Create the Pocket Operation

  1. Expand the Job in the tree view to view its sub-elements.
  2. In the 3D view, select the bottom face (or the inner bottom edges) of the pocket you wish to clear.
  3. Click the Pocket Shape operation button in the CAM toolbar.

3. Configure Operation Properties

In the Pocket configuration task panel, set your machining parameters across the tabs:

  • Base Geometry: Verify that your selected pocket face appears in the list.
  • Depths:
    • Start Depth: The top surface where cutting begins (usually stock top or zero).
    • Final Depth: The target depth of the pocket floor.
    • Step Down: The maximum axial depth of cut per pass. FreeCAD will calculate the required number of Z-passes automatically.
  • Heights: Set safe clearance heights for non-cutting rapid moves.
    • Clearance Height: Height for long-distance rapid travel.
    • Safe Height: Height at which the tool switches from rapid travel to the plunge feed rate.
  • Operation:
    • Pattern: Choose your clearing strategy (e.g., Offset or ZigZag).
    • Cut Mode: Select Climb or Conventional milling.
    • Step Over: Set the horizontal engagement percentage (typically 40%–60% of the tool diameter).
    • Keep Tool Down: Enable this to reduce unnecessary retracts between cut passes.
    • Use Outline: Enable if you want the tool to trace the perimeter to leave a clean edge.

Click Apply to calculate the toolpath, review the visible green travel lines, and click OK to close the dialog.

4. Simulate the Toolpath

  1. Highlight your Job in the tree view.
  2. Click the CAM Simulator button in the toolbar.
  3. Use the playback controls to watch the material removal process.
  4. Check for gouges, rapid plunge movements directly into solid stock, or incorrect depth levels.
  5. Click OK to exit simulation mode. If issues arise, double-click the Pocket operation in the tree view to adjust settings.

5. Export the G-Code

  1. Select the Job object in the tree hierarchy.
  2. Click the Post-Process button on the toolbar (or select CAM > Post-Process).
  3. Choose a destination folder and filename, typically using .gcode or .nc as the extension.
  4. Click Save. FreeCAD will process the toolpath through your selected post-processor, outputting clean, machine-ready G-code.