Symbol attributes in BOM scripts

Hello,
i know that the plan is to move away from the BOM generation scripts in the future, but i’m trying to solve a problem for the today :slight_smile: .

In my custom script that generate the BOM i’d like to extract the attributes of the symbols:

image

can someone point me in the right direction?

There can be handful’s of Attributes in a Symbol and they depend on what the creator of that symbol did. That applies to both Stock and User-created symbols.

Building a custom code/script is the easy part; knowing what ‘Atrtributes’ to list will depend on what the Attribute was named.

You can gain some insight by opening a variety of stock Symbols (.kicad_sym) in a Text-Editor and identifying Attributes of interest to you…

I’m in particular interested in how to evaluate in python the ‘Do not populate’ checkbox.

my library parts currently include a DNP filed that i use in my python script:

...
writerow( out, [index+1,'1',c.getRef(),c.getValue(),c.getField('IITCode')+' '+c.getDescription(),'',c.getField('DNP')])
...

But i’d like to start using the values attribute checkboxes since i suppose is the intended way to
include/exclude stuff to the BOM.

The reason of using a python script instead of the new ‘Generate bill of material’ function is because
i have to generate a BOM in a peculiar format that uses multiple field separators (tabs and spaces in certain places) to feed a custom made PLM (over which i have no control).

Here’s the scenario, as I see it (do it…)

• Open the Symbol-Editor and Select a Symbol
• Place that Symbol on the Schematic
• Set the Check-Boxes
• Save Schematic
(the schematic [.kicad_sch] will now have that Symbol with the Checkbox Attributes as User sets them)

Open the .kicad_sch in a Text-Editor and Find the Symbol.

So, at that point, User will know the Attributes to have Code/Script search for and list/print…

Example:
I did the above for an AD1955. Below shows the .kicad_sch opened in Text-Editor and, as seen, the 'in_bom no, ‘on- oard no’ and ‘dnp yes’ are clearly listed.

Curiosity is the Engineer’s best friend…

1 Like

thank you BC,
that is a nice starting point that will keep me busy for a while :slight_smile: .

To give an end to the topic, in case it could be useful to other users,
the flags values can be evaluated like this:

components = net.getInterestingComponents()

for index, c in enumerate(components):
    print(c.getExcludeFromBOM())
    print(c.getExcludeFromBoard())
    print(c.getDNP())
1 Like