Merge pull request #87 from tnemrap/fix/create-schematic-path
fix: create_schematic now respects the path parameter
This commit is contained in:
@@ -13,7 +13,7 @@ class SchematicManager:
|
||||
"""Core schematic operations using kicad-skip"""
|
||||
|
||||
@staticmethod
|
||||
def create_schematic(name: str, metadata: Optional[Any] = None) -> Any:
|
||||
def create_schematic(name: str, metadata: Optional[Any] = None, *, path: Optional[str] = None) -> Any:
|
||||
"""Create a new empty schematic from template"""
|
||||
try:
|
||||
# Determine template path (use template_with_symbols for component cloning support)
|
||||
@@ -25,7 +25,8 @@ class SchematicManager:
|
||||
)
|
||||
|
||||
# Determine output path
|
||||
output_path = name if name.endswith(".kicad_sch") else f"{name}.kicad_sch"
|
||||
base_name = name if name.endswith(".kicad_sch") else f"{name}.kicad_sch"
|
||||
output_path = os.path.join(path, base_name) if path else base_name
|
||||
|
||||
if os.path.exists(template_path):
|
||||
# Copy template to target location
|
||||
|
||||
@@ -622,8 +622,11 @@ class KiCADInterface:
|
||||
"message": "Schematic name is required. Provide 'name', 'projectName', or 'filename' parameter.",
|
||||
}
|
||||
|
||||
schematic = SchematicManager.create_schematic(project_name, metadata)
|
||||
file_path = f"{path}/{project_name}.kicad_sch"
|
||||
sch_path = path if path and path != "." else None
|
||||
schematic = SchematicManager.create_schematic(project_name, path=sch_path, metadata=metadata)
|
||||
base_name = project_name if project_name.endswith(".kicad_sch") else f"{project_name}.kicad_sch"
|
||||
normalized_path = path or "."
|
||||
file_path = os.path.join(normalized_path, base_name)
|
||||
success = SchematicManager.save_schematic(schematic, file_path)
|
||||
|
||||
return {"success": success, "file_path": file_path}
|
||||
|
||||
Reference in New Issue
Block a user