From 69c34d62e9f428166c72a2ee4d98af547446c634 Mon Sep 17 00:00:00 2001 From: Dharun Ashokkumar Date: Wed, 15 Jul 2026 10:49:35 +0530 Subject: [PATCH] Fixes issue #417 - Open .kicad_sch subcircuit schematics in Edit Subcircuit Edit Subcircuit always launched eeschema with a hardcoded .sch path. Subcircuits saved with KiCad 6 use the .kicad_sch extension, so eeschema was pointed at a file that does not exist and kept prompting to create a new schematic instead of opening the existing one. Pick the .kicad_sch file when it exists and fall back to the legacy .sch file otherwise, the same way Kicad.py opens the main project schematic. New subcircuits are now created as .kicad_sch directly, in line with the project schematics from newProject.py. --- src/subcircuit/newSub.py | 3 ++- src/subcircuit/openSub.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/subcircuit/newSub.py b/src/subcircuit/newSub.py index b452dafe3..6814fd2bc 100644 --- a/src/subcircuit/newSub.py +++ b/src/subcircuit/newSub.py @@ -54,7 +54,8 @@ def createSubcircuit(self, subName): os.mkdir(self.schematic_path) self.schematic = os.path.join( self.schematic_path, self.create_schematic) - self.cmd = "eeschema " + self.schematic + ".sch" + # New KiCad v6 file extension + self.cmd = "eeschema " + self.schematic + ".kicad_sch" self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() self.close() diff --git a/src/subcircuit/openSub.py b/src/subcircuit/openSub.py index 53c3cbf1f..03e0175d1 100644 --- a/src/subcircuit/openSub.py +++ b/src/subcircuit/openSub.py @@ -34,6 +34,12 @@ def body(self): self.schname = os.path.basename(self.editfile) self.editfile = os.path.join(self.editfile, self.schname) - self.cmd = "eeschema " + self.editfile + ".sch " + + schematic_file = self.editfile + ".kicad_sch" # kicad6 file + if not os.path.exists(schematic_file) and os.path.exists( + self.editfile + ".sch"): + schematic_file = self.editfile + ".sch" # kicad4 file + + self.cmd = "eeschema " + schematic_file self.obj_workThread = WorkerThread(self.cmd) self.obj_workThread.start()