How can I place and rotate footprints programmatically on a PCB in KiCad using Python?
To place and rotate footprints programmatically on a PCB in KiCad using Python, you can use the pcbnew module. The script provided demonstrates this by positioning and rotating specific components on the board:

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

# Get reference to footprint objects
board = pcbnew.GetBoard()
r1 = board.FindFootprintByReference('R1')
r2 = board.FindFootprintByReference('R2')
d1 = board.FindFootprintByReference('D1')
assert(r1 and r2 and d1)

# Place footprints
r1.SetPosition(wxPointMM(20, 20))    # (x, y) = (20, 20) in mm
r1.SetOrientation(90 * 10)           # rotate by 90 deg
r2.SetPosition(wxPointMM(25, 21))
d1.SetPosition(wxPointMM(23, 26))

# Update display
pcbnew.Refresh()
```

This script places and rotates the footprints 'R1', 'R2', and 'D1' on the PCB to specified locations and orientations.