pcb_auto_place_force_directed
Optimize PCB component placement with a force-directed spring-embedder algorithm based on net connectivity. Get computed X/Y positions to apply as placement suggestions.
Instructions
Run a force-directed spring-embedder placement algorithm on a set of components.
This tool computes optimised X/Y positions for components based on their net connectivity without requiring KiCad to be open. Use it to get a placement suggestion, then apply the result with pcb_move_footprint for each component.
Args: component_positions: List of component dicts with keys: ref (str), x (float, mm), y (float, mm), w (float, mm, optional default 2), h (float, mm, optional default 2), fixed (bool, optional default false). nets: List of net dicts with keys: name (str), refs (list[str]), weight (float, optional default 1.0). board_width_mm: Soft boundary width in mm (default 100). board_height_mm: Soft boundary height in mm (default 80). iterations: Number of spring-embedder iterations (default 300). k_spring: Spring attraction coefficient (default 0.4). k_repel: Coulomb repulsion coefficient (default 80.0).
Returns: JSON string with optimised positions for each component.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nets | Yes | ||
| k_repel | No | ||
| k_spring | No | ||
| iterations | No | ||
| board_width_mm | No | ||
| board_height_mm | No | ||
| component_positions | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |