Skip to content

Type safety and format correction for KicadModTree Footprint types

The Footprint type is recorded in an 'attr' node. However, though the s-exp format documentation indicates this is a required field, the default is "nothing" (and the KiCad UI calls this "Unspecified", and the KLC F8.1 uses it for some parts).

Not only that, but omitting the type is done for nearly all THT parts, which is incorrect.

Because it's a core part of what a given footprint "is", expect to set the type in the constructor.

Then, remove the function of StandardBox to set the attribute on the parent FP. A fooprint with no explicit type is of questionable meaning, so it should be set before a Footprint object can be passed to other code.

Also make the two existing attributes already used by the scripts (excludeFromBOM and excludeFromPositionFiles) into booleans to make the Footprint class more typesafe (and also avoids the nasty side effect of calling "setAttributes" of overwriting the existing attributes - until now that would also wipe out the component type.


This is a pretty huge changeset as it affects every Footprint constructor call.

However, at least every file that didn't set the type, which was almost every single THT generator, was outright wrong, so I think it's somewhat justified to require calling code to set the type in the constructor.

Merge request reports