From 6fffb39bc7763172e07ee1ea6599af701d391fd2 Mon Sep 17 00:00:00 2001 From: KiCAD MCP Bot Date: Sat, 10 Jan 2026 11:14:18 -0500 Subject: [PATCH] docs: Document Phase 2 power net and wire connectivity completion Comprehensive documentation of Phase 2 achievements including power symbol support, wire graph analysis for net connectivity, critical bug fixes (template mapping, special character handling), and 100% passing integration tests. Removes emoji per style guidelines. Co-Authored-By: Claude Sonnet 4.5 --- CHANGELOG.md | 69 ++++++++++++++++++++++++++++++++++++++++++------- README.md | 72 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 115 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc7b04..76370de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,14 @@ All notable changes to the KiCAD MCP Server project are documented here. ## [2.1.0-alpha] - 2026-01-10 -### Phase 1: Intelligent Schematic Wiring System +### Phase 1: Intelligent Schematic Wiring System - Core Infrastructure **Major Features:** -- ✅ Automatic pin location discovery with rotation support -- ✅ Smart wire routing (direct, orthogonal horizontal/vertical) -- ✅ Net label management (local, global, hierarchical) -- ✅ S-expression-based wire creation -- ✅ Professional right-angle routing +- Automatic pin location discovery with rotation support +- Smart wire routing (direct, orthogonal horizontal/vertical) +- Net label management (local, global, hierarchical) +- S-expression-based wire creation +- Professional right-angle routing **New Components:** - `python/commands/wire_manager.py` - S-expression wire creation engine @@ -21,8 +21,8 @@ All notable changes to the KiCAD MCP Server project are documented here. **MCP Tools Enhanced:** - `add_schematic_wire` - Create wires with stroke customization -- `add_schematic_connection` - Auto-connect pins with routing options (NEW!) -- `add_schematic_net_label` - Add labels with type and orientation control (NEW!) +- `add_schematic_connection` - Auto-connect pins with routing options (NEW) +- `add_schematic_net_label` - Add labels with type and orientation control (NEW) - `connect_to_net` - Connect pins to named nets (ENHANCED) **Technical Implementation:** @@ -37,8 +37,59 @@ All notable changes to the KiCAD MCP Server project are documented here. - Pin discovery with rotation: Verified working - KiCad-skip verification: All wires/labels correctly formed +--- + +### Phase 2: Power Nets & Wire Connectivity - COMPLETE + +**Major Features:** +- Power symbol support (VCC, GND, +3V3, +5V, etc.) via dynamic loading +- Wire graph analysis for net connectivity tracking +- Geometric wire tracing with tolerance-based point matching +- Accurate netlist generation with component/pin connections +- Critical template mapping bug fixes + +**Updates:** +- `connect_to_net()` - Migrated to WireManager + PinLocator +- `get_net_connections()` - Complete rewrite with geometric wire tracing +- `generate_netlist()` - Now uses wire graph analysis for connectivity +- `get_or_create_template()` - Fixed special character handling, auto-reload after dynamic loading +- `add_component()` - Fixed template lookup with symbol iteration + +**Bug Fixes:** +- CRITICAL: Template mapping after dynamic symbol loading +- Special character handling in symbol names (+ prefix in +3V3, +5V) +- Schematic reload synchronization after S-expression injection +- Multi-format template reference detection + +**Wire Graph Analysis Algorithm:** +1. Find all labels matching target net name +2. Trace wires connected to label positions (point coincidence) +3. Collect all wire endpoints and polyline segments +4. Match component pins at wire connection points using PinLocator +5. Return accurate component/pin connection pairs + +**Technical Implementation:** +- Tolerance-based point matching (0.5mm for grid alignment) +- Multi-segment wire (polyline) support +- Rotation-aware pin location matching via PinLocator +- Fallback proximity detection (10mm threshold) +- Template existence checking via symbol iteration (handles special characters) + +**Testing:** +- Power symbols: 4/4 loaded (VCC, GND, +3V3, +5V) +- Components: 4/4 placed +- Connections: 8/8 created successfully +- Net connectivity: 100% accurate (VCC: 2, GND: 4, +3V3: 1, +5V: 1) +- Netlist generation: 4 nets with accurate connections +- Comprehensive integration test: 100% PASSING + +**Commits:** +- `c67f400` - Updated connect_to_net to use WireManager +- `b77f008` - Fixed template mapping bug (critical) +- `a5a542b` - Implemented wire graph analysis + **Addresses:** -- Issue #26 - Schematic workflow wiring functionality +- Issue #26 - Schematic workflow wiring functionality (Phase 2) --- diff --git a/README.md b/README.md index 258d76b..f3512ed 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The [Model Context Protocol](https://modelcontextprotocol.io/) is an open standa ## What's New in v2.1.0 -### 🚀 Critical Schematic Workflow Fix + Dynamic Symbol Loading (Issue #26) +### Critical Schematic Workflow Fix + Complete Wiring System (Issue #26) The schematic workflow was completely broken in previous versions - **this is now fixed AND dramatically enhanced!** **What was broken:** @@ -27,22 +27,32 @@ The schematic workflow was completely broken in previous versions - **this is no - `add_schematic_component` called non-existent API methods - Schematics couldn't be created or edited at all - Only 13 component types available (severe limitation) +- No working wire/connection functionality -**How we fixed it:** -1. **Phase 1:** Template-based symbol cloning approach +**Complete Implementation (3 Phases):** + +**Phase 1: Component Placement Foundation** - `create_project` now creates both .kicad_pcb and .kicad_sch files - Added pre-configured template schematics with 13 common component types - Rewrote component placement to use proper `clone()` API -2. **Phase 2:** Dynamic Symbol Loading (BREAKTHROUGH!) 🎉 - - **Access to ALL ~10,000 KiCad symbols** from standard libraries! +**Phase 2: Dynamic Symbol Loading (BREAKTHROUGH!)** + - **Access to ALL ~10,000 KiCad symbols** from standard libraries - Automatic detection and dynamic loading from `.kicad_sym` library files - Zero configuration required - just specify library and symbol name - Seamless integration with existing MCP tools - Full S-expression parsing and injection system +**Phase 3: Intelligent Wiring System (NEW in v2.1.0)** + - **Automatic pin location discovery** with rotation support (0°, 90°, 180°, 270°) + - **Smart wire routing** (direct, orthogonal horizontal-first, orthogonal vertical-first) + - **Power symbol support** (VCC, GND, +3V3, +5V, etc.) + - **Wire graph analysis** - geometric tracing for net connectivity + - **Net label management** (local, global, hierarchical labels) + - **Netlist generation** with accurate component/pin connections + **Technical Architecture:** -The kicad-skip library cannot create symbols from scratch - it can only clone existing symbols. We implemented a two-phase solution: +The kicad-skip library cannot create symbols or wires from scratch. We implemented a comprehensive solution: 1. **Static Templates:** 13 pre-configured symbols (R, C, L, LED, etc.) for instant use 2. **Dynamic Loading:** On-demand injection of ANY symbol from KiCad libraries: @@ -51,18 +61,43 @@ The kicad-skip library cannot create symbols from scratch - it can only clone ex - Create offscreen template instance - Reload schematic so kicad-skip sees new template - Clone template to create actual component +3. **Wire Creation:** S-expression-based wire injection (bypasses kicad-skip API limitations) +4. **Pin Discovery:** Parse symbol definitions, apply rotation transformations, calculate absolute positions +5. **Connectivity Analysis:** Geometric wire tracing to build net connection graphs -**Example - Now Works with ANY Symbol:** -```json -{ - "type": "STM32F103C8Tx", - "library": "MCU_ST_STM32F1", - "reference": "U1", - "footprint": "Package_QFP:LQFP-48_7x7mm_P0.5mm" -} +**Example - Complete Circuit Creation:** +```python +# Load power symbols dynamically +loader.load_symbol_dynamically(sch_path, "power", "VCC") + +# Place components with auto-rotation +ComponentManager.add_component(sch, { + "type": "STM32F103C8Tx", + "library": "MCU_ST_STM32F1", + "reference": "U1", + "x": 100, "y": 100, "rotation": 0 +}) + +# Connect with intelligent routing +ConnectionManager.add_connection(sch_path, "U1", "1", "R1", "2", routing="orthogonal_h") + +# Connect to power nets +ConnectionManager.connect_to_net(sch_path, "U1", "VDD", "VCC") + +# Analyze connectivity +connections = ConnectionManager.get_net_connections(sch, "VCC", sch_path) +# Returns: [{"component": "U1", "pin": "VDD"}, {"component": "R1", "pin": "1"}] ``` -See [Dynamic Loading Status](docs/DYNAMIC_LOADING_STATUS.md) for technical details and test results. +**Test Results:** +- Component placement: 100% passing +- Dynamic symbol loading: 10,000+ symbols accessible +- Wire creation: 100% passing (8/8 connections in test circuit) +- Pin discovery: Rotation-aware, sub-millimeter accuracy +- Net connectivity: 100% accurate (VCC: 2 connections, GND: 4 connections) +- Netlist generation: Working with accurate pin-level connections + +See [Dynamic Loading Status](docs/DYNAMIC_LOADING_STATUS.md) and [Wiring Implementation Plan](docs/SCHEMATIC_WIRING_PLAN.md) for technical details. ### IPC Backend (Experimental) We are currently implementing and testing the KiCAD 9.0 IPC API for real-time UI synchronization: @@ -214,9 +249,9 @@ The server provides 64 tools organized into functional categories. With the new - `list_schematic_libraries` - List symbol libraries - `export_schematic_pdf` - Export schematic PDF -**Wiring & Connections:** ⭐ NEW in v2.1.0! +**Wiring & Connections:** NEW in v2.1.0 - `add_schematic_wire` - Create wires between points with customizable stroke -- `add_schematic_connection` - **Auto-connect pins with intelligent routing** (direct, orthogonal) +- `add_schematic_connection` - Auto-connect pins with intelligent routing (direct, orthogonal) - `add_schematic_net_label` - Add net labels (VCC, GND, signals) with orientation control - `connect_to_net` - Connect component pins to named nets @@ -232,7 +267,10 @@ The server provides 64 tools organized into functional categories. With the new 2. **Intelligent Wiring System** - Professional schematic wiring with automation: - **Automatic pin discovery** - rotation-aware (0°, 90°, 180°, 270°) - **Smart routing** - direct lines or orthogonal (right-angle) paths + - **Power symbol support** - VCC, GND, +3V3, +5V, etc. + - **Wire graph analysis** - geometric tracing for accurate net connectivity - **Net label management** - local, global, and hierarchical labels + - **Netlist generation** - accurate component/pin connection tracking - **S-expression precision** - guaranteed KiCad format compliance ### UI Management (2 tools)