A collection of Python scripts to enhance and automate your CNC G-code workflow before sending jobs to LinuxCNC.
These tools help you combine, clean, validate, and augment G-code generated by any CAD/CAM system (such as Fusion 360, FreeCAD, etc.) before running it on your CNC machine.
- Simplify multi-operation workflows from multiple CAM files
- Ensure safe toolchanges and predictable start/end sequences
- Remove unnecessary comments or lines
- Automatically renumber lines for clarity and compatibility
- Validate G-code for common issues before risking a machine run
The script f360_seam.py (name historic, works for all G-code sources!) allows you to:
- Merge multiple G-code files into a single program
- Keep only the relevant header and ending blocks
- Renumber all N-lines (
N10,N20, etc.) for clarity (configurable) - Optionally insert safe toolchange subroutine calls
- Remove unnecessary or repetitive comments
- Validate the final output and provide a summary report
- Log all actions and warnings to file or console
python f360_seam.py operations/ merged.ngc
python f360_seam.py job1.ngc job2.ngc job3.ngc final_job.ngc
python f360_seam.py --insert-toolchange-call --log process.log mydir/ result.ngc- Works with any standard G-code files for LinuxCNC
- Directory mode (merge all
.ngcfiles in folder, ordered by number) - File list mode (manual order)
- Flexible comment filtering (operation/toolchange comments kept, or keep all)
- Output validation (toolchange count, end marker, summary)
- Insert safe toolchange calls compatible with LinuxCNC remap/subroutine setup
- Verbose/debug output, with logging to file
To use the safe toolchange call feature, configure your LinuxCNC install as follows:
Add this to your INI file:
[RS274NGC]
REMAP=M6 modalgroup=6 ngc=toolchangeCreate toolchange.ngc in your nc_subroutines directory:
G53 G0 Z0
G53 G0 X0 Y0
M0 (Change tool and press cycle start)See the LinuxCNC Remap documentation for advanced usage.
Keep your tools library in linuxcnc in sync with the toolsfile for linux cnc. Uses the exported JSON from fusion to create the tools.tbl file
py .\f360_toollib_convert.py Library.json- More pre-processing utilities (block delete, param substitution, etc.)
- Support for more CAM-generated G-code variants
- Unit tests and example data
PRs and suggestions are very welcome! Please add clear test cases/examples if you propose new features.
GSeam is free software: you may use, modify, and share it, provided that any changes or improvements are contributed back to this project (copyleft).
- Commercial and non-commercial use allowed
- Modification allowed, but you must submit your improvements via pull request or equivalent for the benefit of all users