[Solved] Convert the new .kicad_sch to the old .sch

Hey guys. I have some scripts that work on .sch files and not on the new format (yet).
So, I am wondering here if someone has a script, program, or any solution to convert the new .kicad_sch format to the old one (.sch). This is temporary to have the scripts working since I still want to have my project on Kicad 6

There are no scripts to downgrade from V6 to V5 and I doubt there will even be due to the number of formatting changes on V6

1 Like

Maybe officially there are none. But maybe someone has one. Or maybe someone has an idea on how to make one using parts of the Kicad’s code.

Let’s say using .kicad_sch parser from version 6. And then the save .sch schematic from version 5.

Is this possible? From my end I think it is not possible and I will be camping here to see if someone else has such solutions

Maybe it works for you to temporarily change pluginType from 1 to 0

For those who want to try it on Windows (backup files first, and then run as admin or change permissions of folder bin):

cd …/KiCad
git apply …/kicad-6.0.2-x86_64-sch.diff
# open and save the schematic, and rename it from *.kicad_sch to *.sch
git apply -R …/kicad-6.0.2-x86_64-sch.diff

Edit: Same for KiCad 6.0.3 on Windows 64-bit:
kicad-6.0.3-x86_64-sch.diff (276 Bytes)

Edit: Same for KiCad 6.0.4 on Windows 64-bit:
kicad-6.0.4-x86_64-sch.diff (276 Bytes)

Edit: Same for KiCad 6.0.6 on Windows 64-bit:
kicad-6.0.6-x86_64-sch.diff (266 Bytes)
kicad-6.0.6_1-x86_64-sch.diff (266 Bytes)

1 Like

Hey @mgyger thanks for this suggestion. I don’t use windows. Why do you mentioned it?

@leoheck: Well, because I’m using it … Or you could provide a link to your _eeschema.kiface

1 Like

Ah, so do you already have a .exe with this change to share? I can find a Windows machine to test this pretty quickly.

I still working to build Kicad for the first time on my Linux box. If you have this file, maybe others could test it pretty quick too.

So, my idea is to reduce Kicad to a subset of it (which is also simpler to compile), that does this conversion, allowing me to pass the .kicad_sch from the command line, and outputting the old-style .sch without manual intervention.

My use case is to have a way to export SVG from the schematics with plotgitsch (which works on .sch files only) while Kicad doesn’t have a python API for that.

Other users could have other use cases for that for sure.

Now, what is this _eeschema.kiface thing?

1 Like

Above for Windows x64 is a binary patch for 6.0.[2346] already (it simply does pluginType = 0 by changing 2 bytes using git). So if you send me your particular version of file …/KiCad/6.0/bin/_eeschema.kiface or /usr/bin/_eeschema.kiface (which is the actual binary/executable of eeschema) or point me to the correct package, I could take a look at it…

Edit: On 6.0.3 on Windows it’s called _eeschema.dll

1 Like

I am not sure if I am doing something wrong, but there is nothing on that link. Just the WeTransfer without any file to donwload.

Now, if I send you the binary of my _eeschema.kiface you are saying you can patch the binary directly? In this case, here it is Dropbox - _eeschema.kiface-orig.6.0.2.linux - Simplify your life

Alternatively, the package I am using is this one,
kicad - 6.0.2-0-202202110812+378541a8eb~116~ubuntu21.10.1

OK, let’s try… Assuming you saved
kicad_6.0.2-0-ubuntu21-sch.diff (266 Bytes)
(an ASCII file) in /tmp, try the following (maybe git needs sudo prepended):

cd /usr/bin
git apply /tmp/kicad_6.0.2-0-ubuntu21-sch.diff

Now hopefully the correct 2 bytes should be patched, and you can open and save (overwrite) a copy of a schematic, and then rename it from *.kicad_sch to *.sch, and it should be in the old format…

Revert with:

cd /usr/bin
git apply -R /tmp/kicad_6.0.2-0-ubuntu21-sch.diff

Alright, you are saying that I can patch it myself the binary itsefl. Why dont you mention it before. Cool, I am testing here.

I copied the binary to a folder to patch it. And then I am getting this.
Is it possible to test this on a copy of it or it has to be the original file?

➜  eeschema ls
_eeschema.kiface  kicad_6.0.2-0-ubuntu21-sch.diff  patch.sh
➜  eeschema ./patch.sh
error: the patch applies to '_eeschema.kiface' (1008ed7985ca10dee7e122164e90e9d2b7deb11e), which does not match the current contents.
error: _eeschema.kiface: patch does not apply

Ah, should I be inside a git repo?

You need to use the command

git apply kicad_6.0.2-0-ubuntu21-sch.diff

in the same directory where _eeschema.kiface is.

No, just use git apply with the diff file anywhere.

Fixed my comment here to avoid any misunderstanding.

I have these 2 in the same folder

_eeschema.kiface
kicad_6.0.2-0-ubuntu21-sch.diff

Being inside of this folder, I am applying it with

➜  eeschema git apply kicad_6.0.2-0-ubuntu21-sch.diff

warning: _eeschema.kiface has type 100755, expected 100644

Without -R (this is to revert the patch).

1 Like

Of course, sorry. It workd. Let me test

With

cmp -l _eeschema.kiface.orig _eeschema.kiface

you can see that only 2 bytes have been changed.