I’m currently using TinyCAD for schematics and Pcbnew for layout. I’ve been using these for 13+ years. I’m thinking of switching to EESchema, but I want to convert all my schematics and symbol libraries.
I’m not a software developer at all, so doing this in C/C++ is not an option. I will be doing this in python. I will convert to the V6 file format.
Is there any API or any other kind of recommendations of doing this “the correct way”? Or should I simply go by the file format specification and do this from scratch? I will of course release my source so that anyone can take advantage of it. But I don’t anticipate this being an official importer in EESchema, I’m simply not experienced enough to push code to the official source repo.
Thank you eelik!
I’m guessing that you’re refering to “Importing into KiCad from CADSTAR” and “Reverse-Engineering of (binary) File-Formats”? Unfortunately the video from “Importing into KiCad from CADSTAR” doesn’t seem to be available (yet?). I’ll sure have look at the reverse-engineering talk and at least the slides from the CADSTAR talk is available.
If you will be doing this in Python and not C++, there is no API – as far as I know, nobody has developed any Python libraries for parsing / working with sexpr schematic files yet.
I suggest to at least try an C++ importer. Python is nice, but using Kicad itself means you don’t have to implement the whole file writing stuff, and other people can use it as well inside KiCad ;). We can help you with this of course.
If TinyCAD uses a binary file format you can start with Kaitai to map the structure. This would be independent of the implementation language later. Please ask any questions you come around here.
@craftyjon Thank you for the input! Do you know if it’s decided yet if (or when) EEschema gets support for Action Plugins? That would be awesome!
@pointhi I see your point! I had a look at the source code for the different EEschema importers and I do see the benefits. Although it’s more than a bit daunting for me… Well, I don’t have the time to start this project right now anyway, so I can give this some more thought.
TinyCAD files are XML based and TInyCAD is Open Source so the actual parsing shouldn’t be to much of a problem. Also, the symbols are embedded in the file, just as in the new V6 files.
Before I wrote the CADSTAR importer my c++ knowledge was limited, I had never used CMake before and I had never used git version control. However none of these things were a barrier. If anything, having a project made learning c++ a lot more interesting
I really would recommend that you give C++ a try because it will make your importer useful for a much wider audience as well as you will learn a new skill.
Also I would suggest that you have a look at the merge requests for the Altium and CADSTAR importers to get an idea of which files you will need to modify.
Any questions, feel free to ask: we are happy to help!
@albin The video of the talk is now available on the FOSDEM website.
Note that in the video I mainly talk about the PCB importer and a class called PLUGIN. However for a schematic importer you’ll need to use a class called SCH_PLUGIN instead. Maybe have a look at the merge request for the CADSTAR Schematic Archive importer to get an idea: https://gitlab.com/kicad/code/kicad/-/merge_requests/410
After doing the above you should be able to do File -> Import Non-KiCad Schematic… and your the file extension for TinyCAD should be displayed in the drop down list of the file browser. Feel free to ask any questions if you are stuck or don’t understand something.
Thank you for all the tips and recommendations! I will definitely watch your FOSDEM talk and dig through your code a bit more. Adding an importer seems easy enough, I’m more worried if my skills are high enough to write the actual XML parser and getting it to creating actual schematics using the SCH_PLUGIN class. I guess that I can mimic the TinyCAD code (written in Visual Studio 2019) a bit for the parser. I do have some experience with C++ since I’ve coded quite a lot of Qt5. But my code is not pretty, and I haven’t ever given any thought to memory leaks, performance or coding by any sort of standard really. Coding for me is mainly just a means to an end.
I had a look at the TinyCAD source and it seems like I can get a lot of help from there. File parsing seems be handled by CTinyCadMultiDoc::ReadFile(CStreamFile& file) in
I’ll give this a try when I get some more time on my hands. A few projects I’d like to finish off first, and three kids in the ages 2, 4 and 6 taking up most of my attention.
You don’t need to write a parser from scratch. As mentioned above, the Eagle file format is also XML based. It uses a class from wxWidgets called wxXmlDocument. Link here to the documentation: https://docs.wxwidgets.org/3.0/classwx_xml_document.html
What you might want to do is to read in the file into an “intermediate” structure that represents the file, keeping the “reading/parsing” separate from “loading”. This would make the code a lot easier to maintain in the future if KiCad’s internals change, for example.
Again, I’d recommend you look at the existing importers for hints as to how you can create the KiCad schematic objects. The CADSTAR schematic importer is a bit more complete than the EAGLE one (especially for hierarchical schematics).
My recommendation would be to initially write the minimum code required to just get the importer to “start”. Then you can open a “Work in Progress” merge request in gitlab and we can provide you with detailed help when you get stuck.
The EAGLE plugin however is a really bad example of a “good approach”
It’s going to get some TLC to get it inline with the Altium and CADSTAR importers by Wayne or me, whoever gets irked by it first I guess.