fix: locate placed symbols when (lib_name) precedes (lib_id)
KiCad serialises rescued or locally-customised library entries with an
extra (lib_name "...") child before (lib_id "..."):
(symbol
(lib_name "RESISTOR_0603_4")
(lib_id "MF_Passives:RESISTOR_0603")
(at 132.08 44.45 90)
...)
The block-matching regex in _handle_get_schematic_component,
_handle_edit_schematic_component, and _handle_delete_schematic_component
required (lib_id IMMEDIATELY after (symbol, so any placed component
using this form was silently invisible to lookup. The user-visible
symptom is "Component '<ref>' not found in schematic" even though the
component is plainly present (and reachable through list / IPC paths).
This bug also affected set/remove_schematic_component_property and the
existing footprint/value/reference rewriting paths in edit, since they
all share the same lookup code.
The parent-position lookup used a similarly-strict regex
((symbol (lib_id "...") (at ...))), which silently fell back to (0,0)
on (lib_name)-first symbols and caused new properties added through
the custom-properties path to anchor at the schematic origin instead
of the parent symbol.
Fix: relax the symbol-block opening pattern to (symbol\s+\( — matching
any opening paren after (symbol — and read the symbol's origin from
the first (at ...) inside the block. Library-definition entries inside
(lib_symbols ...) are still excluded by the existing range check
(they use the (symbol "name" ...) form with a quoted string, not a
paren).
Adds 7 regression tests in TestLibNameBeforeLibIdOrdering using a
real-world (lib_name)-first resistor block, covering get / edit /
set-property / remove-property / delete and verifying that newly
added properties anchor to the symbol origin instead of (0, 0).
This commit is contained in:
14
CHANGELOG.md
14
CHANGELOG.md
@@ -4,6 +4,20 @@ All notable changes to the KiCAD MCP Server project are documented here.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **Schematic symbol lookup**: `get_schematic_component`,
|
||||
`edit_schematic_component`, `set_schematic_component_property`,
|
||||
`remove_schematic_component_property`, and `delete_schematic_component`
|
||||
no longer fail with `Component '<ref>' not found in schematic` when the
|
||||
placed symbol uses KiCad's rescued / locally-customised serialisation
|
||||
form `(symbol (lib_name "...") (lib_id "...") ...)`. The block-matching
|
||||
regex now accepts any opening paren after `(symbol`, and the
|
||||
parent-position lookup uses the first `(at ...)` inside the symbol
|
||||
block, so newly-added properties anchor to the symbol origin instead of
|
||||
silently falling back to `(0, 0)`. Added 7 regression tests reproducing
|
||||
the failure on a real-world user schematic.
|
||||
|
||||
### New MCP Tools
|
||||
|
||||
- `set_schematic_component_property` — Add or update a single custom property
|
||||
|
||||
Reference in New Issue
Block a user