kicad-sch-api 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kicad-sch-api might be problematic. Click here for more details.
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/.claude/commands/dev/update-and-commit.md +21 -9
- kicad_sch_api-0.2.1/CHANGELOG.md +112 -0
- {kicad_sch_api-0.2.0/kicad_sch_api.egg-info → kicad_sch_api-0.2.1}/PKG-INFO +212 -40
- kicad_sch_api-0.2.1/README.md +439 -0
- kicad_sch_api-0.2.1/examples/pin_to_pin_wiring_demo.py +98 -0
- kicad_sch_api-0.2.1/examples/simple_circuit_with_pin_wiring.py +64 -0
- kicad_sch_api-0.2.1/examples/simple_two_resistor_routing.py +123 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/__init__.py +6 -2
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/cli.py +67 -62
- kicad_sch_api-0.2.1/kicad_sch_api/core/component_bounds.py +477 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/components.py +22 -10
- kicad_sch_api-0.2.1/kicad_sch_api/core/config.py +127 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/formatter.py +183 -23
- kicad_sch_api-0.2.1/kicad_sch_api/core/geometry.py +111 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/ic_manager.py +43 -37
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/junctions.py +17 -22
- kicad_sch_api-0.2.1/kicad_sch_api/core/manhattan_routing.py +430 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/parser.py +495 -196
- kicad_sch_api-0.2.1/kicad_sch_api/core/pin_utils.py +149 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/schematic.py +630 -207
- kicad_sch_api-0.2.1/kicad_sch_api/core/simple_manhattan.py +228 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/types.py +9 -4
- kicad_sch_api-0.2.1/kicad_sch_api/core/wire_routing.py +380 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/wires.py +29 -25
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/discovery/__init__.py +1 -1
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/discovery/search_index.py +142 -107
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/library/cache.py +70 -62
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1/kicad_sch_api.egg-info}/PKG-INFO +212 -40
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api.egg-info/SOURCES.txt +19 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/pyproject.toml +2 -2
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/two_resistors/two_resistors.kicad_sch +10 -10
- kicad_sch_api-0.2.1/tests/test_bounding_box_rectangles.py +251 -0
- kicad_sch_api-0.2.1/tests/test_component_removal.py +166 -0
- kicad_sch_api-0.2.1/tests/test_element_removal.py +111 -0
- kicad_sch_api-0.2.1/tests/test_grid_snapping.py +236 -0
- kicad_sch_api-0.2.1/tests/test_manhattan_routing.py +255 -0
- kicad_sch_api-0.2.1/tests/test_pin_positioning.py +462 -0
- kicad_sch_api-0.2.1/tests/test_pin_to_pin_wiring.py +179 -0
- kicad_sch_api-0.2.1/tests/test_removal_against_references.py +185 -0
- kicad_sch_api-0.2.0/README.md +0 -267
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/.claude/commands/dev/dead-code-analysis.md +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/.claude/commands/dev/publish-pypi.md +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/.claude/commands/dev/review-implementation.md +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/.claude/commands/dev/run-tests.md +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/.claude/commands/dev/update-memory-bank.md +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/.claude/commands/test/run-reference-tests.md +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/LICENSE +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/MANIFEST.in +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/examples/advanced_usage.py +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/examples/basic_usage.py +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/examples/mcp_basic_example.py +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/examples/mcp_integration.py +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/core/__init__.py +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/library/__init__.py +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/py.typed +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/utils/__init__.py +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api/utils/validation.py +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api.egg-info/dependency_links.txt +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api.egg-info/entry_points.txt +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api.egg-info/requires.txt +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/kicad_sch_api.egg-info/top_level.txt +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/setup.cfg +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/README.md +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/blank_schematic/blank_schematic.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/blank_schematic/blank_schematic.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/multi_unit_7400/multi_unit_7400.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/multi_unit_7400/multi_unit_7400.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/power_symbols/power_symbols.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/power_symbols/power_symbols.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/resistor_divider/resistor_divider.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/resistor_divider/resistor_divider.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/sch_title/sch_title.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/sch_title/sch_title.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_extended_component/single_extended_component.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_extended_component/single_extended_component.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_hierarchical_sheet/single_hierarchical_sheet.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_hierarchical_sheet/single_hierarchical_sheet.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_hierarchical_sheet/subcircuit1.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_label/single_label.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_label/single_label.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_label_hierarchical/single_label_hierarchical.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_label_hierarchical/single_label_hierarchical.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_resistor/single_resistor.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_resistor/single_resistor.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_text/single_text.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_text/single_text.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_text_box/single_text_box.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_text_box/single_text_box.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_wire/single_wire.kicad_pro +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/single_wire/single_wire.kicad_sch +0 -0
- {kicad_sch_api-0.2.0 → kicad_sch_api-0.2.1}/tests/reference_tests/reference_kicad_projects/two_resistors/two_resistors.kicad_pro +0 -0
|
@@ -10,11 +10,22 @@ Comprehensive workflow for documenting progress, updating documentation, and com
|
|
|
10
10
|
|
|
11
11
|
## Process
|
|
12
12
|
|
|
13
|
-
### 1. Update Documentation (
|
|
14
|
-
|
|
13
|
+
### 1. Update Documentation (REQUIRED for Features)
|
|
14
|
+
**IMPORTANT: Always update documentation BEFORE committing new features**
|
|
15
|
+
- IF new user-facing features: Update README.md with examples
|
|
16
|
+
- IF new API methods: Add to Advanced Features section in README.md
|
|
17
|
+
- IF version increment needed: Update CHANGELOG.md with new version entry
|
|
15
18
|
- IF new MCP tools: Update tool documentation
|
|
16
|
-
-
|
|
17
|
-
- NO documentation changes for internal fixes or refactoring
|
|
19
|
+
- ALWAYS document new public methods with code examples
|
|
20
|
+
- NO documentation changes needed for internal fixes or refactoring
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Documentation update checklist for new features:
|
|
24
|
+
# 1. Add examples to README.md "Basic Usage" or "Advanced Features" sections
|
|
25
|
+
# 2. Create CHANGELOG.md entry with version bump (patch/minor/major)
|
|
26
|
+
# 3. Update any relevant example files in examples/
|
|
27
|
+
# 4. Ensure CLAUDE.md reflects new functionality if developer-relevant
|
|
28
|
+
```
|
|
18
29
|
|
|
19
30
|
### 2. Format Code Before Committing
|
|
20
31
|
**IMPORTANT: Always format code before committing**
|
|
@@ -50,8 +61,8 @@ uv run python -c "import kicad_sch_api; print('✅ Import successful')" || echo
|
|
|
50
61
|
# Check status and review changes
|
|
51
62
|
git status
|
|
52
63
|
|
|
53
|
-
# Add specific files (be selective)
|
|
54
|
-
git add kicad_sch_api/ tests/ README.md pyproject.toml
|
|
64
|
+
# Add specific files (be selective) - ALWAYS include documentation if updated
|
|
65
|
+
git add kicad_sch_api/ tests/ README.md CHANGELOG.md pyproject.toml
|
|
55
66
|
|
|
56
67
|
# Remove unwanted files if any
|
|
57
68
|
git rm unwanted-file.py 2>/dev/null || true
|
|
@@ -79,8 +90,8 @@ git add kicad_sch_api/
|
|
|
79
90
|
# Tests - include if relevant
|
|
80
91
|
git add tests/
|
|
81
92
|
|
|
82
|
-
# Documentation - include if updated
|
|
83
|
-
git add README.md CLAUDE.md
|
|
93
|
+
# Documentation - ALWAYS include if updated (REQUIRED for features)
|
|
94
|
+
git add README.md CHANGELOG.md CLAUDE.md
|
|
84
95
|
|
|
85
96
|
# Configuration - include if changed
|
|
86
97
|
git add pyproject.toml pytest.ini
|
|
@@ -150,7 +161,8 @@ uv run python setup.py check --strict --metadata || echo "⚠️ Package metadat
|
|
|
150
161
|
- `kicad_sch_api/` - Core library code
|
|
151
162
|
- `tests/` - Test files (when relevant)
|
|
152
163
|
- `pyproject.toml` - Package configuration
|
|
153
|
-
- `README.md` - User documentation
|
|
164
|
+
- `README.md` - User documentation (REQUIRED for new features)
|
|
165
|
+
- `CHANGELOG.md` - Version history (REQUIRED for new features)
|
|
154
166
|
|
|
155
167
|
### Include When Relevant
|
|
156
168
|
- `mcp-server/` - MCP server changes
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.3.1] - 2025-01-20
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Pin-to-Pin Wire Drawing**: Intelligent wire routing between component pins
|
|
12
|
+
- `add_wire_between_pins()` method for direct pin-to-pin connections
|
|
13
|
+
- `add_wire_to_pin()` method for connecting arbitrary points to component pins
|
|
14
|
+
- `get_component_pin_position()` method for pin position queries
|
|
15
|
+
- Automatic pin position calculation using existing pin positioning functionality
|
|
16
|
+
- Support for both Point objects and tuple coordinates
|
|
17
|
+
- Comprehensive error handling for invalid components and pins
|
|
18
|
+
- 11 dedicated test cases covering all functionality and edge cases
|
|
19
|
+
|
|
20
|
+
### Enhanced
|
|
21
|
+
- **Wire Management**: Improved wire creation with pin-aware routing
|
|
22
|
+
- Seamless integration with existing WireCollection
|
|
23
|
+
- UUID-based wire tracking for all pin-to-pin connections
|
|
24
|
+
- Maintains exact format preservation for all wire types
|
|
25
|
+
|
|
26
|
+
### Technical Notes
|
|
27
|
+
- Built on existing pin positioning functionality from recent commits
|
|
28
|
+
- All wire drawing maintains KiCAD's coordinate system (inverted Y-axis)
|
|
29
|
+
- Zero test failures achieved - comprehensive validation of all functionality
|
|
30
|
+
- Example files included demonstrating voltage divider and complex circuit creation
|
|
31
|
+
|
|
32
|
+
## [0.3.0] - 2025-01-20
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- **Comprehensive Component Removal**: Full component removal functionality with lib_symbols cleanup
|
|
36
|
+
- `ComponentCollection.remove()` method for removing components by reference
|
|
37
|
+
- Automatic lib_symbols synchronization to remove unused symbol definitions
|
|
38
|
+
- Complete test suite with 4 dedicated removal tests
|
|
39
|
+
|
|
40
|
+
- **Element Removal Operations**: Removal support for all schematic elements
|
|
41
|
+
- Wire removal via `Schematic.remove_wire()` and `WireCollection.remove()`
|
|
42
|
+
- Label removal via `Schematic.remove_label()`
|
|
43
|
+
- Hierarchical label removal via `Schematic.remove_hierarchical_label()`
|
|
44
|
+
- Junction removal via `JunctionCollection.remove()`
|
|
45
|
+
- 5 comprehensive element removal tests
|
|
46
|
+
|
|
47
|
+
- **Reference-Based Validation**: Advanced removal testing against KiCAD reference files
|
|
48
|
+
- `test_single_resistor_to_blank()` - validates resistor removal matches blank schematic exactly
|
|
49
|
+
- `test_two_resistors_remove_one_matches_single()` - validates selective removal preserves remaining components
|
|
50
|
+
- Byte-for-byte format preservation during removal operations
|
|
51
|
+
|
|
52
|
+
- **Professional Configuration System**: Centralized configuration management eliminating anti-patterns
|
|
53
|
+
- `KiCADConfig` class with structured configuration categories
|
|
54
|
+
- Property positioning, grid settings, sheet settings, and tolerance configuration
|
|
55
|
+
- Configurable via public `ksa.config` API for user customization
|
|
56
|
+
- Eliminates hardcoded test coordinates and magic numbers from production code
|
|
57
|
+
|
|
58
|
+
- **Enhanced UUID Support**: UUID parameters for exact format matching
|
|
59
|
+
- `add_label()`, `add_sheet()`, and `add_sheet_pin()` now accept optional `uuid` parameter
|
|
60
|
+
- Deterministic UUID management for test reproducibility
|
|
61
|
+
- Support for both auto-generated and user-specified UUIDs
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
- **Format Preservation**: Achieved byte-for-byte compatibility with KiCAD reference files
|
|
65
|
+
- Custom S-expression formatters for wire `pts` elements
|
|
66
|
+
- Proper float formatting matching KiCAD precision (0.0000 vs 0.0)
|
|
67
|
+
- Fixed coordinate and color formatting inconsistencies
|
|
68
|
+
- All 29 tests now pass with exact format preservation
|
|
69
|
+
|
|
70
|
+
- **Anti-Pattern Elimination**: Removed hardcoded values and test-specific production code
|
|
71
|
+
- Moved test coordinate logic to configurable positioning system
|
|
72
|
+
- Eliminated hardcoded test names in title block generation
|
|
73
|
+
- Centralized magic numbers into structured configuration classes
|
|
74
|
+
- Professional separation of concerns between tests and production code
|
|
75
|
+
|
|
76
|
+
- **Wire Removal Synchronization**: Fixed inconsistency between collection and data structures
|
|
77
|
+
- `remove_wire()` now updates both WireCollection and underlying schematic data
|
|
78
|
+
- Ensures removal operations maintain data integrity across API layers
|
|
79
|
+
|
|
80
|
+
### Changed
|
|
81
|
+
- **Version Bump**: Updated from 0.2.0 to 0.3.0 for major feature additions
|
|
82
|
+
- **Test Coverage**: Expanded from 17 to 29 tests with comprehensive removal validation
|
|
83
|
+
- **Code Quality**: Achieved enterprise-grade configuration management and extensibility
|
|
84
|
+
|
|
85
|
+
### Documentation
|
|
86
|
+
- Updated `CLAUDE.md` with comprehensive removal API documentation
|
|
87
|
+
- Added `REFACTORING_SUMMARY.md` detailing anti-pattern elimination
|
|
88
|
+
- Enhanced README.md with new features and professional configuration examples
|
|
89
|
+
- Documented all new removal methods and configuration options
|
|
90
|
+
|
|
91
|
+
### Technical Notes
|
|
92
|
+
- All changes maintain 100% backward compatibility
|
|
93
|
+
- No breaking API changes - existing code continues to work unchanged
|
|
94
|
+
- Performance optimizations through centralized configuration
|
|
95
|
+
- Enhanced extensibility for future component types and workflows
|
|
96
|
+
|
|
97
|
+
## [0.2.0] - 2025-01-19
|
|
98
|
+
|
|
99
|
+
### Added
|
|
100
|
+
- Initial public release
|
|
101
|
+
- Basic schematic manipulation functionality
|
|
102
|
+
- Component management with ComponentCollection
|
|
103
|
+
- Wire and label creation
|
|
104
|
+
- Symbol library integration
|
|
105
|
+
- Format preservation foundation
|
|
106
|
+
|
|
107
|
+
## [0.1.0] - 2025-01-18
|
|
108
|
+
|
|
109
|
+
### Added
|
|
110
|
+
- Initial development version
|
|
111
|
+
- Core S-expression parsing
|
|
112
|
+
- Basic schematic loading and saving
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kicad-sch-api
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Professional KiCAD schematic manipulation library with exact format preservation
|
|
5
5
|
Author-email: Circuit-Synth <shane@circuit-synth.com>
|
|
6
6
|
Maintainer-email: Circuit-Synth <shane@circuit-synth.com>
|
|
@@ -56,6 +56,9 @@ Create and manipulate KiCAD schematic files programmatically with guaranteed exa
|
|
|
56
56
|
- **🏗️ Professional Component Management**: Object-oriented collections with search and validation
|
|
57
57
|
- **⚡ High Performance**: Optimized for large schematics with intelligent caching
|
|
58
58
|
- **🔍 Real KiCAD Library Integration**: Access to actual KiCAD symbol libraries and validation
|
|
59
|
+
- **📐 Component Bounding Boxes**: Precise component boundary calculation and visualization
|
|
60
|
+
- **🎨 Colored Rectangle Graphics**: KiCAD-compatible rectangles with all stroke types and colors
|
|
61
|
+
- **🛣️ Manhattan Routing**: Intelligent wire routing with obstacle avoidance
|
|
59
62
|
- **🤖 AI Agent Ready**: MCP server for seamless integration with AI development tools
|
|
60
63
|
- **📚 Hierarchical Design**: Complete support for multi-sheet schematic projects
|
|
61
64
|
|
|
@@ -100,6 +103,16 @@ capacitor = sch.components.add(
|
|
|
100
103
|
footprint="Capacitor_SMD:C_0603_1608Metric"
|
|
101
104
|
)
|
|
102
105
|
|
|
106
|
+
# Add wires for connectivity
|
|
107
|
+
sch.wires.add(start=(100, 110), end=(150, 110))
|
|
108
|
+
|
|
109
|
+
# Pin-to-pin wiring (NEW in v0.3.1)
|
|
110
|
+
wire_uuid = sch.add_wire_between_pins("R1", "2", "C1", "1") # Connect R1 pin 2 to C1 pin 1
|
|
111
|
+
external_wire = sch.add_wire_to_pin((50, 100), "R1", "1") # Connect external point to R1 pin 1
|
|
112
|
+
|
|
113
|
+
# Add labels for nets
|
|
114
|
+
sch.add_label("VCC", position=(125, 110))
|
|
115
|
+
|
|
103
116
|
# Save with exact format preservation
|
|
104
117
|
sch.save("my_circuit.kicad_sch")
|
|
105
118
|
```
|
|
@@ -134,6 +147,131 @@ power_sch.save("power.kicad_sch")
|
|
|
134
147
|
|
|
135
148
|
## 🔧 Advanced Features
|
|
136
149
|
|
|
150
|
+
### Component Bounding Boxes and Colored Graphics (NEW in v0.3.1)
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from kicad_sch_api.core.component_bounds import get_component_bounding_box
|
|
154
|
+
|
|
155
|
+
# Add components
|
|
156
|
+
resistor = sch.components.add("Device:R", "R1", "10k", (100, 100))
|
|
157
|
+
opamp = sch.components.add("Amplifier_Operational:LM358", "U1", "LM358", (150, 100))
|
|
158
|
+
|
|
159
|
+
# Get component bounding boxes
|
|
160
|
+
bbox_body = get_component_bounding_box(resistor, include_properties=False)
|
|
161
|
+
bbox_full = get_component_bounding_box(resistor, include_properties=True)
|
|
162
|
+
|
|
163
|
+
# Draw colored bounding box rectangles
|
|
164
|
+
sch.draw_bounding_box(bbox_body, stroke_width=0.5, stroke_color="blue", stroke_type="solid")
|
|
165
|
+
sch.draw_bounding_box(bbox_full, stroke_width=0.3, stroke_color="red", stroke_type="dash")
|
|
166
|
+
|
|
167
|
+
# Draw bounding boxes for all components at once
|
|
168
|
+
bbox_uuids = sch.draw_component_bounding_boxes(
|
|
169
|
+
include_properties=True,
|
|
170
|
+
stroke_width=0.4,
|
|
171
|
+
stroke_color="green",
|
|
172
|
+
stroke_type="dot"
|
|
173
|
+
)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Manhattan Routing with Obstacle Avoidance (NEW in v0.3.1)
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from kicad_sch_api.core.manhattan_routing import ManhattanRouter
|
|
180
|
+
from kicad_sch_api.core.types import Point
|
|
181
|
+
|
|
182
|
+
# Create router
|
|
183
|
+
router = ManhattanRouter()
|
|
184
|
+
|
|
185
|
+
# Add components that act as obstacles
|
|
186
|
+
r1 = sch.components.add("Device:R", "R1", "1k", (50, 50))
|
|
187
|
+
r2 = sch.components.add("Device:R", "R2", "2k", (150, 150))
|
|
188
|
+
obstacle = sch.components.add("Device:C", "C1", "100nF", (100, 100))
|
|
189
|
+
|
|
190
|
+
# Get obstacle bounding boxes
|
|
191
|
+
obstacle_bbox = get_component_bounding_box(obstacle, include_properties=False)
|
|
192
|
+
|
|
193
|
+
# Route around obstacles
|
|
194
|
+
start_point = Point(r1.position.x, r1.position.y)
|
|
195
|
+
end_point = Point(r2.position.x, r2.position.y)
|
|
196
|
+
path = router.route_between_points(start_point, end_point, [obstacle_bbox], clearance=2.0)
|
|
197
|
+
|
|
198
|
+
# Add wires along the path
|
|
199
|
+
for i in range(len(path) - 1):
|
|
200
|
+
sch.wires.add(path[i], path[i + 1])
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Pin-to-Pin Wiring
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
# Connect component pins directly - automatically calculates pin positions
|
|
207
|
+
wire_uuid = sch.add_wire_between_pins("R1", "2", "R2", "1") # R1 pin 2 to R2 pin 1
|
|
208
|
+
|
|
209
|
+
# Connect arbitrary point to component pin
|
|
210
|
+
external_wire = sch.add_wire_to_pin((75, 125), "R1", "1") # External point to R1 pin 1
|
|
211
|
+
tuple_wire = sch.add_wire_to_pin(Point(100, 150), "C1", "2") # Using Point object
|
|
212
|
+
|
|
213
|
+
# Get component pin positions for advanced operations
|
|
214
|
+
pin_position = sch.get_component_pin_position("R1", "1")
|
|
215
|
+
if pin_position:
|
|
216
|
+
print(f"R1 pin 1 is at ({pin_position.x:.2f}, {pin_position.y:.2f})")
|
|
217
|
+
|
|
218
|
+
# Error handling - returns None for invalid components/pins
|
|
219
|
+
invalid_wire = sch.add_wire_between_pins("R999", "1", "R1", "1") # Returns None
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Component Bounding Box Visualization (NEW in v0.3.1)
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from kicad_sch_api.core.component_bounds import get_component_bounding_box
|
|
226
|
+
|
|
227
|
+
# Get component bounding box (body only)
|
|
228
|
+
resistor = sch.components.get("R1")
|
|
229
|
+
bbox = get_component_bounding_box(resistor, include_properties=False)
|
|
230
|
+
print(f"R1 body size: {bbox.width:.2f}×{bbox.height:.2f}mm")
|
|
231
|
+
|
|
232
|
+
# Get bounding box including properties (reference, value, etc.)
|
|
233
|
+
bbox_with_props = get_component_bounding_box(resistor, include_properties=True)
|
|
234
|
+
print(f"R1 with labels: {bbox_with_props.width:.2f}×{bbox_with_props.height:.2f}mm")
|
|
235
|
+
|
|
236
|
+
# Draw bounding box as rectangle graphics (for visualization/debugging)
|
|
237
|
+
rect_uuid = sch.draw_bounding_box(bbox)
|
|
238
|
+
print(f"Drew bounding box rectangle: {rect_uuid}")
|
|
239
|
+
|
|
240
|
+
# Draw bounding boxes for all components
|
|
241
|
+
bbox_uuids = sch.draw_component_bounding_boxes(
|
|
242
|
+
include_properties=False # True to include reference/value labels
|
|
243
|
+
)
|
|
244
|
+
print(f"Drew {len(bbox_uuids)} component bounding boxes")
|
|
245
|
+
|
|
246
|
+
# Expand bounding box for clearance analysis
|
|
247
|
+
expanded_bbox = bbox.expand(2.54) # Expand by 2.54mm (0.1 inch)
|
|
248
|
+
clearance_rect = sch.draw_bounding_box(expanded_bbox)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Manhattan Routing with Obstacle Avoidance (NEW in v0.3.1)
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
# Automatic Manhattan routing between component pins
|
|
255
|
+
wire_segments = sch.auto_route_pins(
|
|
256
|
+
"R1", "2", # From component R1, pin 2
|
|
257
|
+
"R2", "1", # To component R2, pin 1
|
|
258
|
+
routing_mode="manhattan", # Manhattan (L-shaped) routing
|
|
259
|
+
avoid_components=True # Avoid component bounding boxes
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# Direct routing (straight line)
|
|
263
|
+
direct_wire = sch.auto_route_pins("C1", "1", "C2", "2", routing_mode="direct")
|
|
264
|
+
|
|
265
|
+
# Manual obstacle avoidance using bounding boxes
|
|
266
|
+
bbox_r1 = get_component_bounding_box(sch.components.get("R1"))
|
|
267
|
+
bbox_r2 = get_component_bounding_box(sch.components.get("R2"))
|
|
268
|
+
|
|
269
|
+
# Check if routing path intersects with component
|
|
270
|
+
def path_clear(start, end, obstacles):
|
|
271
|
+
# Custom collision detection logic
|
|
272
|
+
return not any(bbox.intersects_line(start, end) for bbox in obstacles)
|
|
273
|
+
```
|
|
274
|
+
|
|
137
275
|
### Component Search and Management
|
|
138
276
|
|
|
139
277
|
```python
|
|
@@ -154,6 +292,53 @@ validation_result = sch.components.validate_component(
|
|
|
154
292
|
)
|
|
155
293
|
```
|
|
156
294
|
|
|
295
|
+
### Component and Element Removal
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
# Remove components by reference
|
|
299
|
+
removed = sch.components.remove("R1") # Returns True if removed
|
|
300
|
+
|
|
301
|
+
# Remove wires, labels, and other elements
|
|
302
|
+
sch.remove_wire(wire_uuid)
|
|
303
|
+
sch.remove_label(label_uuid)
|
|
304
|
+
sch.remove_hierarchical_label(label_uuid)
|
|
305
|
+
|
|
306
|
+
# Remove from collections
|
|
307
|
+
sch.wires.remove(wire_uuid)
|
|
308
|
+
sch.junctions.remove(junction_uuid)
|
|
309
|
+
|
|
310
|
+
# lib_symbols are automatically cleaned up when last component of type is removed
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Configuration and Customization
|
|
314
|
+
|
|
315
|
+
```python
|
|
316
|
+
import kicad_sch_api as ksa
|
|
317
|
+
|
|
318
|
+
# Access global configuration
|
|
319
|
+
config = ksa.config
|
|
320
|
+
|
|
321
|
+
# Customize property positioning
|
|
322
|
+
config.properties.reference_y = -2.0 # Move reference labels higher
|
|
323
|
+
config.properties.value_y = 2.0 # Move value labels lower
|
|
324
|
+
|
|
325
|
+
# Customize tolerances and precision
|
|
326
|
+
config.tolerance.position_tolerance = 0.05 # Tighter position matching
|
|
327
|
+
config.tolerance.wire_segment_min = 0.005 # Different wire segment threshold
|
|
328
|
+
|
|
329
|
+
# Customize defaults
|
|
330
|
+
config.defaults.project_name = "my_company_project"
|
|
331
|
+
config.defaults.stroke_width = 0.1
|
|
332
|
+
|
|
333
|
+
# Grid and spacing customization
|
|
334
|
+
config.grid.unit_spacing = 10.0 # Tighter multi-unit IC spacing
|
|
335
|
+
config.grid.component_spacing = 5.0 # Closer component placement
|
|
336
|
+
|
|
337
|
+
# Sheet settings for hierarchical designs
|
|
338
|
+
config.sheet.name_offset_y = -1.0 # Different sheet label position
|
|
339
|
+
config.sheet.file_offset_y = 1.0 # Different file label position
|
|
340
|
+
```
|
|
341
|
+
|
|
157
342
|
### KiCAD Integration
|
|
158
343
|
|
|
159
344
|
```python
|
|
@@ -170,48 +355,23 @@ net_info = netlist.analyze_net("VCC")
|
|
|
170
355
|
|
|
171
356
|
## 🤖 AI Agent Integration
|
|
172
357
|
|
|
173
|
-
This library serves as the
|
|
174
|
-
|
|
175
|
-
### MCP Server Integration
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
# Install the dedicated MCP server (separate package)
|
|
179
|
-
pip install mcp-kicad-sch-api
|
|
180
|
-
|
|
181
|
-
# Configure for Claude Code
|
|
182
|
-
code mcp install mcp-kicad-sch-api
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Library Design for MCP Compatibility
|
|
186
|
-
|
|
187
|
-
This library is specifically designed to provide:
|
|
188
|
-
- **Stable API**: Consistent interface for MCP servers to build upon
|
|
189
|
-
- **Format Preservation**: Guaranteed exact KiCAD output for reliable automation
|
|
190
|
-
- **Professional Validation**: Component and library validation for quality assurance
|
|
191
|
-
- **Performance**: Optimized for AI agent workloads with caching and bulk operations
|
|
192
|
-
|
|
193
|
-
### Usage with AI Agents
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
# Natural language commands to your AI agent:
|
|
197
|
-
"Create a voltage divider with two 10kΩ resistors"
|
|
198
|
-
"Add an ESP32 microcontroller with USB connector"
|
|
199
|
-
"Generate a hierarchical schematic with power supply subcircuit"
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
**Related MCP Servers:**
|
|
203
|
-
- **[mcp-kicad-sch-api](https://github.com/circuit-synth/mcp-kicad-sch-api)**: Full-featured MCP server built on this library
|
|
358
|
+
This library serves as the foundation for AI agent integration. For Claude Code or other AI agents, use the **[mcp-kicad-sch-api](https://github.com/circuit-synth/mcp-kicad-sch-api)** MCP server (included as a submodule in `submodules/mcp-kicad-sch-api/`).
|
|
204
359
|
|
|
205
360
|
## 🏗️ Architecture
|
|
206
361
|
|
|
207
362
|
### Library Structure
|
|
208
363
|
|
|
209
364
|
```
|
|
210
|
-
|
|
211
|
-
├──
|
|
212
|
-
├──
|
|
213
|
-
├──
|
|
214
|
-
|
|
365
|
+
kicad-sch-api/
|
|
366
|
+
├── kicad_sch_api/ # Core Python library
|
|
367
|
+
│ ├── core/ # Core schematic manipulation
|
|
368
|
+
│ ├── library/ # KiCAD library integration
|
|
369
|
+
│ ├── discovery/ # Component search and indexing
|
|
370
|
+
│ └── utils/ # Validation and utilities
|
|
371
|
+
├── submodules/ # Related projects as submodules
|
|
372
|
+
│ └── mcp-kicad-sch-api/ # MCP server for AI agents
|
|
373
|
+
├── tests/ # Comprehensive test suite
|
|
374
|
+
└── examples/ # Usage examples and tutorials
|
|
215
375
|
```
|
|
216
376
|
|
|
217
377
|
### Design Principles
|
|
@@ -225,18 +385,30 @@ kicad_sch_api/
|
|
|
225
385
|
## 🧪 Testing & Quality
|
|
226
386
|
|
|
227
387
|
```bash
|
|
228
|
-
# Run all tests
|
|
388
|
+
# Run all tests (29 tests covering all functionality)
|
|
229
389
|
uv run pytest tests/ -v
|
|
230
390
|
|
|
231
|
-
# Format preservation tests (critical)
|
|
391
|
+
# Format preservation tests (critical - exact KiCAD output matching)
|
|
232
392
|
uv run pytest tests/reference_tests/ -v
|
|
233
393
|
|
|
394
|
+
# Component removal tests (comprehensive removal functionality)
|
|
395
|
+
uv run pytest tests/test_*_removal.py -v
|
|
396
|
+
|
|
234
397
|
# Code quality checks
|
|
235
398
|
uv run black kicad_sch_api/ tests/
|
|
236
399
|
uv run mypy kicad_sch_api/
|
|
237
400
|
uv run flake8 kicad_sch_api/ tests/
|
|
238
401
|
```
|
|
239
402
|
|
|
403
|
+
### Test Categories
|
|
404
|
+
|
|
405
|
+
- **Format Preservation**: Byte-for-byte compatibility with KiCAD native files
|
|
406
|
+
- **Component Management**: Creation, modification, and removal of components
|
|
407
|
+
- **Element Operations**: Wires, labels, junctions, hierarchical sheets
|
|
408
|
+
- **Configuration**: Customizable settings and behavior
|
|
409
|
+
- **Performance**: Large schematic handling and optimization
|
|
410
|
+
- **Integration**: Real KiCAD library compatibility
|
|
411
|
+
|
|
240
412
|
## 🆚 Why This Library?
|
|
241
413
|
|
|
242
414
|
### vs. Direct KiCAD File Editing
|
|
@@ -301,7 +473,7 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
301
473
|
|
|
302
474
|
## 🔗 Related Projects
|
|
303
475
|
|
|
304
|
-
- **[mcp-kicad-sch-api](https://github.com/circuit-synth/mcp-kicad-sch-api)**: MCP server for AI agents built on this library
|
|
476
|
+
- **[mcp-kicad-sch-api](https://github.com/circuit-synth/mcp-kicad-sch-api)**: MCP server for AI agents built on this library (included as submodule)
|
|
305
477
|
- **[circuit-synth](https://github.com/circuit-synth/circuit-synth)**: High-level circuit design automation using this library
|
|
306
478
|
- **[Claude Code](https://claude.ai/code)**: AI development environment with MCP support
|
|
307
479
|
- **[KiCAD](https://kicad.org/)**: Open source electronics design automation suite
|