fix(property-positioning): Add positioning rules for 6 IC components (#176)#177
Open
shanemmattner wants to merge 2 commits into
Open
fix(property-positioning): Add positioning rules for 6 IC components (#176)#177shanemmattner wants to merge 2 commits into
shanemmattner wants to merge 2 commits into
Conversation
Adds property positioning rules for IC components that were falling back to the resistor pattern, causing property text to be placed incorrectly. Components added: - RF_Module:ESP32-WROOM-32 (large RF module, 40mm × 86mm) - 74xx:74LS245 (SOIC-20W level shifter) - Interface_UART:MAX3485 (SOIC-8 transceiver) - Regulator_Linear:AMS1117-3.3 (SOT-223 LDO) - Regulator_Switching:TPS54202DDC (SOT-23-6 buck converter) - Transistor_FET:AO3401A (SOT-23 P-FET) Property positions extracted from KiCAD symbol library files and added to POSITIONING_RULES dictionary in property_positioning.py. Changes: - kicad_sch_api/core/property_positioning.py: Added 6 IC positioning rules - tests/unit/test_ic_property_positioning.py: 23 unit tests for IC rules - docs/prd/ic-property-positioning-prd.md: PRD documentation Fixes #176 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Completely rewrote property positioning to load positions dynamically from KiCAD symbol library files instead of using hard-coded rules. This provides a generic, scalable solution that works for ALL components, not just specific ICs. **How it works:** 1. Symbol library cache extracts property positions from .kicad_sym files 2. Property positions stored in SymbolDefinition.property_positions dict 3. get_property_position() queries symbol library FIRST, falls back to hard-coded rules 4. No hard-coded rules needed for IC components - all loaded dynamically **Benefits:** - Works for ANY component in KiCAD symbol libraries (thousands of components) - No maintenance burden - positions automatically match KiCAD's native placement - Scales infinitely - new components work automatically - Hard-coded rules remain as fallback for compatibility **Changes:** - kicad_sch_api/library/cache.py: - Added property_positions field to SymbolDefinition - Added _extract_property_position() method to parse (at x y rotation) - Extract property positions during symbol parsing - kicad_sch_api/core/property_positioning.py: - Added _get_offset_from_symbol_library() function - Updated get_property_position() to query symbol library first - Removed hard-coded IC rules (no longer needed) - tests/unit/test_ic_property_positioning.py: - Rewrote tests to verify dynamic loading - 15 tests verify IC positions loaded from symbol libraries - All tests pass ✅ **Testing:** ``` ESP32: Reference (-12.70, +34.29) ✓ 74LS245: Reference (-7.62, +16.51) ✓ MAX3485: Reference (-6.98, +13.97) ✓ AMS1117: Reference (-3.81, +3.17) ✓ TPS54202: Reference (-7.62, +6.35) ✓ AO3401A: Reference (+5.08, +1.91) ✓ ``` All positions match KiCAD symbol library files exactly. Fixes #176 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements dynamic property positioning that loads positions from KiCAD symbol library files instead of using hard-coded rules. This provides a generic, scalable solution that works for ALL components automatically.
Problem
kicad-sch-api was missing property positioning rules for IC components. When generating schematics with ICs, the library fell back to the resistor pattern (offset +2.54mm, -1.27mm) which is completely inappropriate for large ICs like ESP32-WROOM-32 (40mm × 86mm).
Original approach: Hard-code rules for each IC (not scalable)
New approach: Load positions dynamically from
.kicad_symfiles (works for everything)Solution
Generic Dynamic Loading Architecture
Property positions are now extracted from KiCAD symbol library files (
.kicad_sym) during symbol loading and cached for performance.Flow:
.kicad_symfiles(property "Reference" (at x y rotation) ...)from each symbolSymbolDefinition.property_positionsdictget_property_position()queries symbol library FIRSTBenefits of Dynamic Approach
✅ Works for ALL components - Not just the 6 tested ICs, but thousands of KiCAD components
✅ Zero maintenance - Positions automatically match KiCAD's native placement
✅ Infinitely scalable - New components work without code changes
✅ Backward compatible - Hard-coded rules remain as fallback
Changes
Core Implementation
kicad_sch_api/library/cache.py:
property_positions: Dict[str, Tuple[float, float, float]]toSymbolDefinition_extract_property_position()method to parse(at x y rotation)from properties_parse_kicad_symbol_file()kicad_sch_api/core/property_positioning.py:
_get_offset_from_symbol_library()to query symbol cacheget_property_position()to try symbol library FIRST, fall back to hard-coded rulestests/unit/test_ic_property_positioning.py:
Testing
✅ All 15 dynamic loading tests pass:
✅ All existing tests pass:
Impact
Before (Hard-coded approach):
After (Dynamic loading):
Example: How It Works
When generating a schematic with ESP32-WROOM-32:
RF_Module.kicad_symproperty_positions["Reference"] = (-12.7, 34.29, 0)Related
🤖 Generated with Claude Code