Skip to content

burnshall-ui/vibeCNC

Repository files navigation

Vibe CNC

██╗   ██╗██╗██████╗ ███████╗     ██████╗███╗   ██╗ ██████╗
██║   ██║██║██╔══██╗██╔════╝    ██╔════╝████╗  ██║██╔════╝
██║   ██║██║██████╔╝█████╗      ██║     ██╔██╗ ██║██║
╚██╗ ██╔╝██║██╔══██╗██╔══╝      ██║     ██║╚██╗██║██║
 ╚████╔╝ ██║██████╔╝███████╗    ╚██████╗██║ ╚████║╚██████╗
  ╚═══╝  ╚═╝╚═════╝ ╚══════╝     ╚═════╝╚═╝  ╚═══╝ ╚═════╝

A modern, Fanuc-style CNC simulator with AI-powered G-Code assistance

Python PyQt6 License


Features

Live Simulation

  • Progressive Path Drawing - Toolpaths appear line-by-line as the program executes, just like a real CNC
  • Real-Time Position Display - Live X, Z, Tool, Spindle Speed, and Feedrate overlay
  • 2D Visualization - Interactive lathe simulation with zoom, pan, and click-to-jump
  • Collision Detection - Automatic chuck limit warnings with visual highlights

AI-Powered Assistance

  • Dual AI Support - Works with both Claude (cloud) and Ollama (local)
  • Smart Code Review - Analyzes G-Code for policy violations and safety issues
  • Code Generation - Generate G-Code snippets from natural language
  • Context-Aware - Understands your tooling, material, and machine configuration

Professional Tools

  • Syntax Highlighting - Fanuc-style color coding with line numbers
  • Autocomplete & IntelliSense - Context-aware G/M-code completion with Ctrl+Space
  • Tool Library - Quick access with double-click insertion, right-click to edit (in-app editor)
  • Macro Library - Reusable G-Code macros (G65, M98) with in-app editor
  • Find & Replace - Full-featured search with Ctrl+F/Ctrl+H, regex support
  • Recent Files - Quick access to last 5 programs
  • Settings Dialog - In-app configuration editor (machine, AI, paths, UI)
  • Policy Engine - Enforce safety rules and coding standards
  • G41/G42 Compensation - Tool nose radius compensation with arc handling and corner intersections
  • CAMotics Integration - 3D simulation support (optional)

Fanuc-Style UI

  • Authentic Look - CRT green on black, yellow highlights
  • Control Panel - CYCLE START, FEED HOLD, OPT STOP, SINGLE BLOCK
  • Keyboard Shortcuts - F5 for quick sim, Spacebar for cycle start
  • Adaptive Scaling - Responsive font sizing for any screen

Screenshots

Coming soon - Add your screenshots to /docs/screenshots/


Installation

Prerequisites

  • Python 3.13 (or 3.10+)
  • Ollama (for local AI) - Download
  • CAMotics (optional, for 3D simulation) - Download

Quick Start

# Clone the repository
git clone https://github.com/burnshall-ui/vibeCNC.git
cd vibeCNC

# Install dependencies
pip install -r requirements.txt

# Run the application
python vibe_cnc.py

For Local AI (Ollama)

# Install Ollama from https://ollama.com

# Pull a model (recommended: granite3.3:8b for speed)
ollama pull granite3.3:8b

# Start Ollama (if not running as service)
ollama serve

For Cloud AI (Claude)

# Set your API key
setx ANTHROPIC_API_KEY "sk-ant-..."

# Update config.yaml
# Change ai.mode to "claude"

Usage

Basic Workflow

  1. Load a Program - OPEN button or Ctrl+O
  2. Edit G-Code - Syntax highlighting and line numbers
  3. Run Simulation - Press CYCLE START (green button) or Spacebar
  4. Watch Live - Toolpaths draw progressively with real-time position info
  5. AI Review - Click KI: ANALYZE for safety checks
  6. Generate Code - Use KI: GEN-CODE or type in chat

Keyboard Shortcuts

Key Action
Space CYCLE START (run/resume simulation)
F FEED HOLD (pause simulation)
Esc Stop simulation
F5 Quick CAMotics simulation
Ctrl+Space Trigger autocomplete (IntelliSense)
Ctrl+L Lint only (no AI)
Ctrl+F Find dialog
Ctrl+H Find & Replace dialog
Ctrl+S Save file
Ctrl+Shift+S Save and copy to VM
Ctrl+O Open file
Ctrl++ Zoom in
Ctrl+- Zoom out

Simulation Controls

  • CYCLE START (Green) - Start or resume program execution
  • FEED HOLD (Orange) - Pause at current line
  • OPT STOP (Gray) - Enable/disable M01 stops
  • SINGLE BLOCK (Gray) - Execute one line at a time

Configuration

Quick Config: Use the in-app ⚙️ SETTINGS button for GUI-based configuration.

Manual Config: Edit config.yaml to customize:

UI Settings

ui:
  font_base_pt: 12          # Base font size
  dark_bg: "#1A1A1A"        # Dark background
  fanuc_yellow: "#FFC800"   # Accent color

AI Settings

ai:
  mode: "ollama"            # "claude" or "ollama"
  offline: false            # true = no AI calls

  ollama:
    base_url: "http://127.0.0.1:11111/api/chat"
    model: "granite3.3:8b"  # Fast and accurate

  anthropic:
    model: "claude-sonnet-4-20250514"
    api_key_env: "ANTHROPIC_API_KEY"
    max_output_tokens: 800

Machine Settings

machine:
  chuck_z_limit: -5.0       # Collision warning threshold

policies:
  protected_m_codes: [62, 63, 64, 65]  # Don't modify these
  require_header_codes: ["G18", "G40", "G80", "G97"]
  require_units: "G21"      # Metric only
  require_origin: "G54"     # Work coordinate system

Tool Library

Quick Edit: Right-click any tool in the app → Tool Editor, or use + NEUES TOOL button.

Manual Edit: Edit tools/tools.json:

{
  "1": {
    "name": "CNMG1204P-SM",
    "type": "Drehmeissel",
    "insert_radius_mm": 8.2,
    "limits": {
      "vc_max": 320,
      "f_max": 0.4,
      "ap_max": 5.0
    }
  }
}

Architecture

vibe_cnc/
├── vibe_cnc.py                 # Main application (UI + wiring)
├── config.yaml                 # Configuration file
├── requirements.txt            # Python dependencies
│
├── vibe_cnc/
│   ├── claude_client.py        # AI client (Claude + Ollama)
│   ├── gcode_highlighter.py    # Syntax highlighting + editor
│   ├── gcode_plotter.py        # 2D visualization + live drawing
│   ├── lint_engine.py          # Policy enforcement
│   ├── camotics_bridge.py      # 3D simulation integration
│   ├── settings_manager.py     # Config loader
│   ├── tool_model.py           # Tool library
│   └── macro_model.py          # Macro library
│
├── tools/
│   ├── tools.json              # Tool database
│   └── macros.db               # SQLite macro storage
│
└── programs/                   # Sample G-Code programs

Roadmap

Completed

  • Live simulation with progressive drawing
  • Real-time position tracking
  • Dual AI support (Claude + Ollama)
  • Interactive 2D plotter
  • Tool and macro libraries with in-app editors
  • Fanuc-style controls
  • Find & Replace in editor
  • G41/G42 tool nose radius compensation
  • Settings dialog for configuration
  • Recent files list
  • Autocomplete & IntelliSense (context-aware G-Code completion)

In Progress

  • Program statistics (cycle time, tool changes)
  • Snippet library / favorites

Planned

  • Network simulation (RPC to LinuxCNC VM)
  • DXF import for geometry
  • Conversational programming wizard
  • Multi-language support (EN/DE)

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.


Acknowledgments

  • Fanuc - For inspiring the UI design
  • CAMotics - 3D simulation integration
  • Ollama - Local LLM inference
  • Anthropic - Claude AI API
  • PyQt6 - UI framework
  • Matplotlib - 2D plotting

📧 Contact

Project Link: https://github.com/burnshall-ui/vibeCNC


Built by machinist and CNC enthusiast

Enhanced with AI by Claude Code

About

Modern Fanuc-style CNC lathe simulator with AI-powered G-Code assistance, live toolpath visualization, and progressive drawing.

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages