Merge pull request #119 from thesamprice/fix/add-component-subsheet-project-path
fix: resolve project-local sym-lib-table for schematics in sub-folders
This commit is contained in:
@@ -727,9 +727,17 @@ class KiCADInterface:
|
|||||||
y = component.get("y", 0)
|
y = component.get("y", 0)
|
||||||
unit = component.get("unit", 1)
|
unit = component.get("unit", 1)
|
||||||
|
|
||||||
# Derive project path from schematic path for project-local library resolution
|
# Derive project path from schematic path for project-local library resolution.
|
||||||
|
# Walk up from the schematic file to find the directory that owns the project
|
||||||
|
# (contains sym-lib-table or a .kicad_pro file). Schematics stored in a
|
||||||
|
# sub-folder (e.g. sheets/) would otherwise resolve to the wrong directory and
|
||||||
|
# miss any project-local sym-lib-table entries.
|
||||||
schematic_file = Path(schematic_path)
|
schematic_file = Path(schematic_path)
|
||||||
derived_project_path = schematic_file.parent
|
derived_project_path = schematic_file.parent
|
||||||
|
for ancestor in schematic_file.parents:
|
||||||
|
if (ancestor / "sym-lib-table").exists() or list(ancestor.glob("*.kicad_pro")):
|
||||||
|
derived_project_path = ancestor
|
||||||
|
break
|
||||||
|
|
||||||
loader = DynamicSymbolLoader(project_path=derived_project_path)
|
loader = DynamicSymbolLoader(project_path=derived_project_path)
|
||||||
loader.add_component(
|
loader.add_component(
|
||||||
|
|||||||
Reference in New Issue
Block a user