-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added conversion of legacy fp_arc
to modern fp_arc
#61
base: master
Are you sure you want to change the base?
Conversation
I remember running in such an issue too when migrating from KiCad 5 to KiCad 6 and using I guess supporting both versions determined by their tokens makes the most sense. The easiest fix would be to convert to the new format, as your PR suggests. No version token would be needed then. But this implicitly converts a KiCad 5 footprint to a KiCad 6+ footprint. Another approach would be to have an additional class member of some sort (e.g. But as i think that it only complicates things when we are fully supporting KiCad 5 style of footprints, i would rather see the converting approach. But i am happy to hear your thoughts about this.
I dont think that there are footprints that have legacy As in your issue #60:
Aren't footprints > As of right now, i think this is the only thing that really holds back parsing of KiCad 5 style footprints with We'd need some unittests for this as well. Do you want to provide some? E.g. A minimal example of an older style |
I think in terms of API there still is more pressing issues about how they decided to name If there would be an API change, I think having a KiUtil-only class, possibly called
This is true, but in terms of code that is how it would function. If a file had both
From what I understand, not necessarily. In KiCad source, if either I think KiUtils may benefit from a Context Object which stores version and generator and propagated to the children classes. This could help keep file formats consistent to a version, allow for version based checks, and also help users with converting between versions by just changing the context object. Curious to hear your thoughts on this. |
As of currently I am low on time and energy to build a thorough test case, hence my |
Going the inheritance route may be our the best bet here. I think of adding some base class (maybe
Absolutely no problem, i'm going to add this to the to-do list for now.
I'm currently reviewing the changes KiCad 7 brings and they added some breaking changes here and there, some of which i am not sure how to implement yet without breaking v6 support. So this may be an approach we have to implement to correctly support both new and older versions of KiCad without breaking |
Ah, my original idea was having the three parameters defining the geometry of the arc ( In context of the entire KiUtils project, I do wonder the best approach to structuring classes for version-dependent classes. For example if
That is what I believe too. When looking through KiCad's source for their parser, it is amazing how many conditionals there are based on version. I think breaking the API once to ensure cross-version support like KiCad would be best for the future to come. |
I guess we need some kind of base class that every But for the sake of now supporting both KiCad 5 and 6+7 it would be sufficient to implement your approach with the base class |
This PR address another half of the issue mentioned by issue #60. KiUtils currently parses
(module
files without question. Though,(module
files can have the legacy syntax forfp_arc
, which instead has tokensstart
,end
, andangle
. KiUtils does not fail when parsingfp_arc
s with this old syntax as is in an incomplete state. Instead of having KiUtils fail, I wrote these changes based off of KiCad source code (sources included in code) to upgrade that old syntax to modernfp_arc
. This PR then works towards fully supporting(module
related syntax.KiCad's file format page does not mention the legacy formatting of
fp_arc
(docs). Instead, I found the description in a 3rd party documentation from 2015 when footprint libraries started with(module
(legacy footprint documentation).As mentioned in the changes, the current approach assumes both legacy and modern
fp_arc
s are possible at the same time. KiCad switches parsing based on version number as mentioned in #60. Though, the only objects able to access version numbers are the container footprint/symbols. Therefore until the KiUtils API supports children objects having a version number, the hack there exists.Especially for the older
.kicad_mod
files I am working with, this change helps tremendously in preserving that information.