How to script for precise via and track placement in a PCB layout using Python in KiCad?
Scripting for precise via and track placement in a PCB layout can be achieved using Python in KiCad. The script provided shows how to place a via and a track at precise locations relative to a specific pad:

```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 ideal for creating structured, precise PCB layouts, where the exact positioning of vias and tracks is crucial for the design's functionality and integrity.