how to get footprint type (smd, through hole)
Summary
I found this code in kicad source https://gitlab.com/kicad/code/kicad/-/blob/master/api/proto/board/board_types.proto#L774
enum FootprintMountingStyle
{
FMS_UNKNOWN = 0;
FMS_THROUGH_HOLE = 1;
FMS_SMD = 2;
FMS_UNSPECIFIED = 3;
}
message FootprintAttributes
{
string description = 1;
string keywords = 2;
bool not_in_schematic = 3;
bool exclude_from_position_files = 4;
bool exclude_from_bill_of_materials = 5;
bool exempt_from_courtyard_requirement = 6;
bool do_not_populate = 7;
FootprintMountingStyle mounting_style = 8;
}
but, I don't see any function for get mounting_style in KiCad API Python Bindings
Reproduction steps
and i try to use this code
#!/usr/bin/env python
import kipy
kicad = kipy.KiCad()
board = kicad.get_board()
footprints = board.get_footprints()
for footprint in footprints:
print(f"Reference {footprint.reference_field.text.value}:")
print(f" Mounting Style: {footprint.attributes._proto.mounting_style}")
and all return 0 (FMS_UNKNOWN = 0), not FMS_SMD or FMS_THROUGH_HOLE:
Reference B10:
Mounting Style: 0
Reference C128:
Mounting Style: 0
Reference C84:
Mounting Style: 0
Reference C96:
Mounting Style: 0
Reference U8:
Mounting Style: 0
Reference C147:
Mounting Style: 0
Reference R115:
Mounting Style: 0
Reference R112:
Mounting Style: 0
Reference L7:
Mounting Style: 0
Version Info
Please include all the requested information below. If you do not, your issue may be closed.
- Python version: Python 3.10.12 (main, Jan 17 2025, 14:35:34) [GCC 11.4.0] on linux
-
kicad-pythonversion: 0.2.0
KiCad full version info:
Insert the output of kicad-cli version --format about, or the full KiCad version text found in
the KiCad About dialog, between the sets of triple backticks below
Application: KiCad PCB Editor x86_64 on x86_64
Version: 9.0.0-rc3-5ca7abf2c1~182~ubuntu22.04.1, release build
Libraries:
wxWidgets 3.2.1
FreeType 2.11.1
HarfBuzz 2.7.4
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.18
Platform: Ubuntu 22.04.5 LTS, 64 bit, Little endian, wxGTK, X11, ubuntu, x11
OpenGL: AMD, RAPHAEL_MENDOCINO (raphael_mendocino, LLVM 15.0.7, DRM 3.57, 6.8.0-52-generic), 4.6 (Compatibility Profile) Mesa 23.2.1-1ubuntu3.1~22.04.3
Build Info:
Date: Feb 19 2025 14:51:02
wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.74.0
OCC: 7.6.3
Curl: 7.81.0
ngspice: 43
Compiler: GCC 11.4.0 with C++ ABI 1016
KICAD_IPC_API=ON
Locale:
Lang: en_US
Enc: UTF-8
Num: 1,234.5
Encoded кΩ丈: D0BACEA9E4B888 (sys), D0BACEA9E4B888 (utf8)