How do I programmatically add vias next to component pads in KiCad using Python?
To programmatically add vias next to component pads in KiCad using Python, you can use a script that locates a specific pad and places a via at a determined offset. The provided script demonstrates adding a via next to pad #2 of 'R2':

```python
import pcbnew
from pcbnew import wxPoint, wxPointMM

board = pcbnew.GetBoard()
pad = board.FindFootprintByReference('R2').FindPadByNumber('2').GetCenter()
via_location = wxPoint(pad.x + 1 * pcbnew.IU_PER_MM, pad.y)
add_track(pad, via_location)
via = pcbnew.PCB_VIA(board)
via.SetPosition(via_location)
via.SetDrill(int(0.4 * 1e6))
via.SetWidth(int(0.8 * 1e6))
board.Add(via)

pcbnew.Refresh()
```

This script is useful for adding vias near specific components, a common practice in PCB design for electrical connection or thermal management.