devbisme / KiPart

Python package for generating multi-unit schematic symbols for KiCad from a CSV file.
MIT License
174 stars 46 forks source link

update for kicad version 6 #68

Open putyn opened 2 years ago

putyn commented 2 years ago

First of thank you for this piece of software! creating symbols has never been easier;

Is your feature request related to a problem? Please describe. with Kicad version 6 the transition to S-Expressions has finished (now symbols/libraries are shaved as S expressions). This is not really an issue (or at least for me) for the normal functionality of kipart because importing an older symbol (.lib) still works as expected. However if you want to use kilib2csv to convert a symbol back to a csv file, conversion doesn't fail but the resulting csv is empty.

Describe the solution you'd like Ideally kipart (kilb2csv) should be updated to also handle the newer format.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

devbisme commented 2 years ago

I updated kilib2csv so it can handle KiCad V6 symbol libraries. You can install it like this:

pip install git+https://github.com/devbisme/KiPart@v6

Unfortunately, this version of KiPart only works with Python versions 3.10 and higher because of restrictions with the kiutils library that I used. I'll probably have to find a different solution, but you can try this for now.

devbisme commented 2 years ago

I updated the v6 branch to remove the dependency on kiutils. Now it should work with any version of Python.

putyn commented 2 years ago

sweet! thanks for taking a look into this; I will try this in the next couple of days! I have noticed that for kinparse you have used pyparsing to parse the s-expression and I have actually started to write a parser based on your work for the kicad library format, any reason why you didn't take the same approach here?

devbisme commented 2 years ago

In my limited experience with PyParsing, I've found it really slow. Also, the parsing statements can have some non-obvious interactions and can be really hard to follow after you haven't looked at them for a while. And when an input file has a parse error, PyParsing aborts but often doesn't point out the exact location where the parsing failed. (These drawbacks may be the result of the way I'm using PyParsing. It's hard to tell if the fault is with PyParsing or me.)

The symbol data I needed from the .kicad_sym file was relatively easy to extract from the nested lists generated by sexpdata. And sexpdata processes files quickly, hasn't been modified in almost a decade, and is compatible with every version of Python 2 & 3 (PyParsing needs version 3.6 or newer).

mvnmgrx commented 2 years ago

Hello, kiutils author here, FYI: Support for Python versions from 3.7 to 3.10 was added in version v1.1.4 today. But if your requirements demand support for older versions as far as Python2, this will unfortunately be outside the scope of kituils ...

devbisme commented 2 years ago

Thanks for the update!

putyn commented 2 years ago

had a look at the V6 branch, I had an issue where the symbol name was not the same as the part as the filed Value and the assertion error was thrown, after fixing the naming issue I could generate the CSV file. Another thing I noticed is the other fields (package, footprint, description) are not exported to the CSV file