1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# Model check
`tools/model_check.py` checks a footprint's 3D model placement against its pads, without opening KiCad.
``` sh
tools/router/.venv/bin/python tools/model_check.py libraries/footprints/HW.pretty/<name>.kicad_mod [-D HW_LIB=...]
```
- **Transform:** it reads the footprint's `(model …)` offset, scale and rotation, loads the STEP file's vertices and applies KiCad's transform: scale, then rotate X, Y, Z (KiCad negates the angles), then offset. 3D Y points up, footprint Y points down.
- **Output:** the model's extent and height, and for every drilled pad (THT, NPTH) the distance to the nearest model feature below the board surface (pin tips, pegs, shell legs).
- Good: every hole within about 0.1 mm, body bottom at z ≈ 0.
- "Nothing below the board surface" means the model is upside down or floating.
- **When to run it:** on every new footprint with a model, especially ones converted with easyeda2kicad. Their offsets and rotations are often wrong; seen on a MagJack (2.2 mm off in y) and a USB-C receptacle (rotated 180° about X, standing on its mating face).
- **SMD-only parts:** it cannot match holes. Check those with `kicad-cli pcb render` ([KiCad notes](kicad.md)).
- **Assemblies** (manufacturer STEP files with coloured sub-parts, [3D models](../topics/3d-models.md)) are refused. Flatten a copy with FreeCAD, point a scratch copy of the footprint at it and check that. Keep the original in the library. freecadcmd treats arguments as files to open, so pass paths through the environment:
``` sh
STEPFILE=in.stp OUT=flat.step freecadcmd -c "import os, Part; s=Part.read(os.environ['STEPFILE']); Part.Compound(s.Solids).exportStep(os.environ['OUT'])"
```
Related: [KiCad notes](kicad.md).
|