execute_kipy
Execute arbitrary Python in a live KiCad session for full control over PCB and schematic edits when dedicated tools fall short.
Instructions
Run arbitrary Python against the live KiCad session (FULL-CONTROL escape hatch).
Use this for anything not covered by a dedicated tool. The code runs in-process with these names pre-bound:
kicad: connected kipy.KiCad instance
board: the open Board, or None if no PCB is open
schematic: the open Schematic, or None
kipy, board_types, geometry, commit
Vector2, Angle, BoardLayer, KiCadObjectType
Conventions:
Internal units are nanometres; build points with Vector2.from_xy_mm(x, y).
Group board edits in a single undo step: with commit(board, "my change"): board.create_items(item)
Assign a variable named
resultto return structured data; anything printed to stdout is also captured.
Args: code: Python source to execute. autosave: If True and a board is open, save it after the code runs.
Example: code = ''' from kipy.board_types import Track from kipy.geometry import Vector2 t = Track() t.start = Vector2.from_xy_mm(10, 10) t.end = Vector2.from_xy_mm(20, 10) t.width = 250000 # 0.25 mm in nm t.layer = BoardLayer.BL_F_Cu with commit(board, "api track"): created = board.create_items(t) result = [c.id.value for c in created] '''
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| autosave | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||