Commit b3505e0
feat: support top_level_sheets from .kicad_pro (Altium flat multi-page import) (#19)
* feat: support top_level_sheets from .kicad_pro for Altium-imported projects
When importing Altium Designer projects into KiCad, the importer registers
all schematic pages as top_level_sheets in .kicad_pro instead of creating
hierarchical (sheet ...) references. analyze_schematic.py only discovered
sub-sheets via (sheet ...) nodes, causing all non-root pages to be silently
ignored — typically losing 90%+ of components.
This change adds top_level_sheets detection after parse_all_sheets() returns.
When the root schematic has no sub-sheets but .kicad_pro lists multiple
top_level_sheets, each additional page is parsed and merged into the result.
Tested on a 25-page, 3100+ component RK3588 design imported from Altium.
Before: 206 components (one page). After: 3162 components (all 25 pages).
Closes #18
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: refresh power_symbols after top_level_sheets merge
* fix: address Copilot review on top_level_sheets merge
- Trigger flat-merge from find_first(root_tree, "sheet") is None instead
of `not no_hierarchy`. The redirect path calls analyze_schematic(root,
no_hierarchy=True), which previously gated the merge off — analyzing
any peer page of an Altium-flat project dropped to root-only content.
The new check also avoids triggering on hierarchical projects whose
(sheet ...) refs point to missing files.
- Store resolved abs paths in extra_sheets and sheets_parsed (matching
parse_all_sheets convention). Dedupe by resolved path so duplicate
top_level_sheets entries via different relative paths don't double-merge.
Validated on glitcher-flattened fixture (root .kicad_sch with zero sheet
refs + .kicad_pro top_level_sheets): both root analysis and peer-page
analysis now yield 98 components / 44 power symbols, matching the
hierarchical baseline.
Copilot's third point (extra peers with their own (sheet ...) children
not recursively merged) is real but unrelated to the Altium-flat target;
deferred as a follow-up.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: huangjianpeng <huangjianpeng@cvte.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Andrew Klofas <aklofas@gmail.com>1 parent 2a7dc41 commit b3505e0
1 file changed
Lines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8650 | 8650 | | |
8651 | 8651 | | |
8652 | 8652 | | |
| 8653 | + | |
| 8654 | + | |
| 8655 | + | |
| 8656 | + | |
| 8657 | + | |
| 8658 | + | |
| 8659 | + | |
| 8660 | + | |
| 8661 | + | |
| 8662 | + | |
| 8663 | + | |
| 8664 | + | |
| 8665 | + | |
| 8666 | + | |
| 8667 | + | |
| 8668 | + | |
| 8669 | + | |
| 8670 | + | |
| 8671 | + | |
| 8672 | + | |
| 8673 | + | |
| 8674 | + | |
| 8675 | + | |
| 8676 | + | |
| 8677 | + | |
| 8678 | + | |
| 8679 | + | |
| 8680 | + | |
| 8681 | + | |
| 8682 | + | |
| 8683 | + | |
| 8684 | + | |
| 8685 | + | |
| 8686 | + | |
| 8687 | + | |
| 8688 | + | |
| 8689 | + | |
| 8690 | + | |
| 8691 | + | |
| 8692 | + | |
| 8693 | + | |
| 8694 | + | |
| 8695 | + | |
| 8696 | + | |
| 8697 | + | |
| 8698 | + | |
| 8699 | + | |
| 8700 | + | |
| 8701 | + | |
| 8702 | + | |
| 8703 | + | |
| 8704 | + | |
| 8705 | + | |
| 8706 | + | |
| 8707 | + | |
| 8708 | + | |
| 8709 | + | |
| 8710 | + | |
| 8711 | + | |
| 8712 | + | |
| 8713 | + | |
| 8714 | + | |
| 8715 | + | |
| 8716 | + | |
| 8717 | + | |
| 8718 | + | |
| 8719 | + | |
| 8720 | + | |
| 8721 | + | |
| 8722 | + | |
| 8723 | + | |
| 8724 | + | |
| 8725 | + | |
| 8726 | + | |
| 8727 | + | |
| 8728 | + | |
| 8729 | + | |
| 8730 | + | |
| 8731 | + | |
| 8732 | + | |
8653 | 8733 | | |
8654 | 8734 | | |
8655 | 8735 | | |
| |||
0 commit comments