Ideally I wanted to search for all symbols that I had checked off the “Exclude from bill of materials” as I wasn’t sure if I had mistakenly done this on some parts of a large project. I didn’t see any way to search for them using the GUI, so I resorted to some python. Here is what I came up with. Maybe it will be useful to others, though it only works with footprints as I don’t know of a way to access a list of symbols using pcbnew
. If anyone knows of this, I’d be happy to revise.
# See https://gitlab.com/kicad/code/kicad/-/blob/master/pcbnew/footprint.h#L70 for enum definitions
import pcbnew
import sys
from enum import Enum
board = pcbnew.LoadBoard(sys.argv[1])
footprints = board.GetFootprints()
class FOOTPRINT_ATTR_T(Enum):
FP_THROUGH_HOLE = 0x0001
FP_SMD = 0x0002
FP_EXCLUDE_FROM_POS_FILES = 0x0004
FP_EXCLUDE_FROM_BOM = 0x0008
FP_BOARD_ONLY = 0x0010 # Footprint has no corresponding symbol
FP_JUST_ADDED = 0x0020 # Footprint just added by netlist update
FP_ALLOW_SOLDERMASK_BRIDGES = 0x0040
FP_ALLOW_MISSING_COURTYARD = 0x0080
FP_DNP = 0x0100
for footprint in footprints:
attr = footprint.GetAttributes()
if attr & FOOTPRINT_ATTR_T.FP_EXCLUDE_FROM_BOM.value:
print(footprint.GetReference() + " is excluded from BOM")
# This doesn't seem to match anything for some reason.
if attr & FOOTPRINT_ATTR_T.FP_DNP.value:
print(footprint.GetReference() + " is DNP")
Also not sure why none of my DNP parts are not printing here. Looking at a single footprint in the PCB Editor it looks like this isn’t even a footprint attribute but only saved to the symbol so maybe that is why? Ideally I’d like to be able to print a list of those as well.
Also curious if this Enum can be accessed from within the pcbnew or if my copy/paste from the cpp code was necessary.
Edit:
Adding KiCAD version info:
Application: KiCad PCB Editor x86_64 on x86_64
Version: 7.0.6-7.0.6~ubuntu22.04.1, release build
Libraries:
wxWidgets 3.2.1
FreeType 2.11.1
HarfBuzz 6.0.0
FontConfig 2.13.1
libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.14
Platform: Ubuntu 22.04.2 LTS, 64 bit, Little endian, wxGTK, ubuntu-xorg, x11
Build Info:
Date: Jul 7 2023 02:32:39
wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.74.0
OCC: 7.5.2
Curl: 7.88.1
ngspice: 38
Compiler: GCC 11.3.0 with C++ ABI 1016
Build settings:
KICAD_SPICE=ON