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…
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).
• 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.
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())