How can I customize track width and layer when adding tracks in KiCad using Python?
Customizing track width and layer when adding tracks in KiCad can be done using Python scripting. The provided script includes a function `add_track` that allows specifying the track width and layer:

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

def add_track(start, end, layer=pcbnew.F_Cu):
    board = pcbnew.GetBoard()
    track = pcbnew.PCB_TRACK(board)
    track.SetStart(start)
    track.SetEnd(end)
    track.SetWidth(int(0.25 * 1e6))  # Custom track width
    track.SetLayer(layer)            # Custom layer
    board.Add(track)

# Example usage
board = pcbnew.GetBoard()
start = board.FindFootprintByReference('R1').FindPadByNumber('1').GetCenter()
end = board.FindFootprintByReference('D1').FindPadByNumber('1').GetCenter()
add_track(start, end, layer=pcbnew.F_Cu)

pcbnew.Refresh()
```

This script allows for detailed control over track properties, which is essential for addressing specific electrical and mechanical constraints in PCB design.