High-performance UG NX CAM post-processor with intelligent G-code optimization
Documentation ·
Changelog ·
Releases
NX Post-Processor is a Windows-native tool for merging, optimizing, and validating CNC G-code output from Siemens NX CAM. It handles multi-tool programs, work coordinate systems, and cutter compensation with production-grade safety checks.
| Module | Description |
|---|---|
| G41/G40 Cutter Compensation | 4 risk strategies (SAFE / BALANCED / FAST / EXTREME) with adaptive D-number management |
| G54/G56 Multi-WCS | Automatic H-offset calculation, coordinate inheritance, dual-pass merge |
| Modal State Machine | NC event system, lexer, and state tracker for semantic G-code analysis |
| M70 Safety Audit | Interference detection, compensation limit protection, shop-floor pre-check |
| Tool Merge Engine | Flying-knife filter, preselect optimization, configurable sort strategies |
# Visual Studio Developer Command Prompt
mkdir build 2>$null
cl /std:c++17 /EHsc /O2 /utf-8 /Fe:build\ug_native.exe src\main.cpp src\nc_lexer.cpp src\nc_events.cpp src\nc_modal_state.cppIf your tree only links
main.cppin practice, use the command you already use locally. The modules undersrc/provide the NC lexer/event/modal core.
# Single file processing
ug_native.exe --normal output.ptp input.ptp --side-comp-g41
# Multi-tool merge with G54/G56
ug_native.exe --merge out.H.ptp out.HH.ptp *.ptp --g54g56 --multi-wcs "G54:0,G56:10"
# Trace merge decisions
ug_native.exe --trace-merge trace.txt *.ptp --g54g56 --multi-wcs "G54:0,G56:10"
# Safety audit
ug_native.exe --safety-report report.txt *.ptpRegression tests use in-repo synthetic fixtures under tests/fixtures/ (no private shop NC required).
# Build the binary first, then:
cd tests
python test_tooltips.py
python test_1000zip_package.py
python test_g54g56_mode.py
python test_side_comp_all_modes.py
# or run all:
python -m pytest . -vnx-post-processor/
├── src/ # C++17 source code
│ ├── main.cpp # Core engine / GUI
│ ├── nc_lexer.cpp/h # G-code lexical analyzer
│ ├── nc_events.cpp/h # NC event system
│ └── nc_modal_state.cpp/h # Modal state machine
├── tests/ # Python regression tests + fixtures
│ └── fixtures/ # Synthetic .ptp samples (public-safe)
├── ugbook/ # UG NX Post Builder definitions
│ ├── ugbook-9-3-enhanced.tcl # Event handlers + enhancements
│ ├── ugbook-9-3-enhanced.def # Address & block templates
│ └── ugbook-9-3-enhanced.pui # UI configuration
├── docs/ # Technical documentation
├── CHANGELOG.md
├── CONTRIBUTING.md
└── LICENSE
┌─────────────────────────────────────────────────────┐
│ CLI Interface │
├─────────────┬───────────────┬───────────────────────┤
│ --normal │ --merge │ --trace / --safety │
├─────────────┴───────────────┴───────────────────────┤
│ Core Processing Pipeline │
│ ┌──────────┐ ┌──────────┐ ┌────────────────┐ │
│ │ NC Lexer │→ │ NC Events│→ │ Modal State │ │
│ └──────────┘ └──────────┘ └────────────────┘ │
├─────────────────────────────────────────────────────┤
│ Feature Modules │
│ ┌─────────┐ ┌──────────┐ ┌─────────┐ ┌────────┐ │
│ │G41/G40 │ │Multi-WCS │ │ Merge │ │ Safety │ │
│ │Compensn │ │G54/G56 │ │ Engine │ │ Audit │ │
│ └─────────┘ └──────────┘ └─────────┘ └────────┘ │
├─────────────────────────────────────────────────────┤
│ Output Generation │
│ G-code files (.ptp) / Trace / Diff / Report │
└─────────────────────────────────────────────────────┘
The ugbook/ directory contains enhanced UG NX Post Builder 6.0 definitions:
| File | Purpose | Enhancements |
|---|---|---|
.tcl |
Event handlers | Dynamic D-number, Smart Z-skip, Multi-WCS hooks |
.def |
Address & block templates | Full 66 BLOCK_TEMPLATE definitions |
.pui |
UI configuration | Enhanced event sequence with init/cleanup hooks |
These files are designed for use with Siemens NX Post Builder and implement the same algorithms as the C++ binary in TCL form.
Always verify on a safe dry-run before running on a machine. This project is not affiliated with Siemens.
| Document | Description |
|---|---|
| Merge Report | C++ to TCL logic merge details |
| H-Offset Rules | G54/G56 H-number calculation |
| Error Attribution | Modal algorithm analysis |
| M70 Interference | Compensation interference analysis |
| New Features | Feature additions summary |
See CONTRIBUTING.md for development setup, build instructions, and PR guidelines.
Built with precision for CNC manufacturing