mvnmgrx / kiutils

Simple and SCM-friendly KiCad file parser based on Python dataclasses for KiCad 6.0 and up.
GNU General Public License v3.0
81 stars 27 forks source link

Footprint with `fp_arc` versioning issue #60

Open zardini123 opened 1 year ago

zardini123 commented 1 year ago

I found exporting a footprint with a fp_arc from KiUtils, KiCad fails to import it due to a syntax error in the fp_arc. From further investigation, I found that without specifying a footprint version number, KiCad imports the file using legacy syntax. Specifically, the version number evaluates to <= LEGACY_ARC_FORMATTING (fp_arc parsing source), where LEGACY_ARC_FORMATTING is of date 20210925 (date source). In the source of KiCad I found that they consider both (modules and (footprint as .kicad_mod files as modern due to first versions of .kicad_mod being (modules. Therefore the main differentiation is the version number provided in the footprint header.

The goal is to have footprint library files freshly exported from KiUtils be importable by KiCad. Currently this is not possible in whole due to files with fp_arc and the default version of None not importing in KiCad under the version KiUtils expects.

After exploring KiUtil's source for a couple days, I find fixing this issue might be a bit more loaded than I hoped. Footprints can be embedded in board files, but when as a standalone footprint library includes the version and generator token (footprint library documentation). Therefore attempting to set the default date in KiUtils to 20210926 (day after LEGACY_ARC_FORMATTING) would result in embedded footprints in boards with version numbers, which is against what the documentation suggests. My suggested "quick fix" is this: