How can I use Python to add a via to a specific location on my PCB in KiCad?
Adding a via to a specific location on a PCB in KiCad can be done using Python scripting. The script snippet provided demonstrates how to create a PCB via, set its position, diameter, drill size, and associated net code:

```python
import pcbnew

# Initialize PCB and via
board = pcbnew.GetBoard()
pcb_via = pcbnew.PCB_VIA(board)

# Set via properties
pcb_via.SetPosition(pcbnew.wxPointMM(x, y))
pcb_via.SetWidth(int(via_diameter * pcbnew.IU_PER_MM))
pcb_via.SetDrill(int(via_drill_diameter * pcbnew.IU_PER_MM))
pcb_via.SetNetCode(net.GetNetCode())

# Add via to the board
board.Add(pcb_via)
```

This approach is useful for precisely placing vias in a PCB layout, essential for electrical connectivity and routing.