fix: add_label falls back gracefully on sub-sheet schematics
In hierarchical KiCad designs, sub-sheets (.kicad_sch files referenced via (sheet ...) blocks) do not have a (sheet_instances) section — that only appears in the top-level schematic. WireManager.add_label was returning False with a logged error whenever no (sheet_instances) marker was found, making it impossible to add any net label (local, global, or hierarchical) to a sub-sheet. Fix: fall back to inserting before the final item of the s-expression list, which is equivalent to appending before the closing ')' of the outer (kicad_sch ...) block. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -316,8 +316,9 @@ class WireManager:
|
||||
break
|
||||
|
||||
if sheet_instances_index is None:
|
||||
logger.error("No sheet_instances section found in schematic")
|
||||
return False
|
||||
# Sub-sheets in hierarchical designs don't have (sheet_instances).
|
||||
# Fall back to appending before the final closing paren of (kicad_sch ...).
|
||||
sheet_instances_index = len(sch_data)
|
||||
|
||||
# Insert label
|
||||
sch_data.insert(sheet_instances_index, label_sexp)
|
||||
|
||||
Reference in New Issue
Block a user