How can I script a custom PCB shape based on the positions of specific components in KiCad?
Scripting a custom PCB shape based on the positions of specific components can be achieved in KiCad using Python. The script provided includes a method to create a custom outline around designated components:

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

def add_line(start, end, layer=pcbnew.Edge_Cuts):
    board = pcbnew.GetBoard()
    segment = pcbnew.PCB_SHAPE(board)
    segment.SetShape(pcbnew.SHAPE_T_SEGMENT)
    segment.SetStart(start)
    segment.SetEnd(end)
    segment.SetLayer(layer)
    segment.SetWidth(int(0.1 * pcbnew.IU_PER_MM))
    board.Add(segment)

# Calculate start and end points for custom PCB shape
# ... (rest of the script)
add_line(start, end)

pcbnew.Refresh()
```

This method is particularly useful for creating PCBs with tailored shapes to accommodate specific layout requirements or mechanical constraints.