KiCad

The KiCad class is the main entry point for connecting to a running Zeo instance.

Constructor

from kipy import KiCad

kicad = KiCad(
    socket_path=None,   # IPC socket path (auto-detected if None)
    client_name=None,   # Unique client identifier (random if None)
    kicad_token=None,   # Session token (from env if None)
    timeout_ms=2000     # Request timeout in milliseconds
)

Methods

get_version()

Returns the Zeo version.

version = kicad.get_version()
print(version)  # 10.0.0 (10.0.0-abc123)
print(version.major, version.minor, version.patch)  # 10 0 0

get_api_version()

Returns the API version this library was built against.

api_version = kicad.get_api_version()

check_version()

Checks if the connected Zeo version is compatible.

try:
    kicad.check_version()
except FutureVersionError:
    print("Zeo is newer than this library")

ping()

Tests the connection.

kicad.ping()  # Raises ConnectionError if not connected

get_schematic()

Returns a Schematic object for the open schematic.

sch = kicad.get_schematic()

get_board()

Returns a Board object for the open PCB.

board = kicad.get_board()

get_mbs_schematic()

Returns a Schematic object for the open multi-board schematic (.kicad_mbs). MBS-specific operations live under .multi_board.

mbs = kicad.get_mbs_schematic()
blocks = mbs.multi_board.get_blocks()

Raises ApiError if no MBSCH editor is open. See Multi-Board Overview.

get_schematic_by_project_path(abs_project_path)

In a multi-board project, several SCH editors may be open in peer windows (one per sub-project). Returns the Schematic whose .kicad_pro path matches.

info = mbs.multi_board.get_container_info()

for sub in info.sub_projects:
    sch = kicad.get_schematic_by_project_path(sub.absolute_path)
    # ... edit each sub-project's schematic independently

Use the absolute_path from get_container_info().sub_projects[] (or from check_status). Raises ApiError if no open editor matches.

get_board_by_project_path(abs_project_path)

Same as get_schematic_by_project_path, but for PCB editors.

board = kicad.get_board_by_project_path(sub.absolute_path)

get_project(document)

Returns a Project object for project-level operations.

docs = kicad.get_open_documents(DocumentType.DOCTYPE_PCB)
project = kicad.get_project(docs[0])

get_open_documents(doc_type)

Returns a list of open documents of the specified type.

from kipy.proto.common.types import DocumentType

# Get open PCBs
pcbs = kicad.get_open_documents(DocumentType.DOCTYPE_PCB)

# Get open schematics
schematics = kicad.get_open_documents(DocumentType.DOCTYPE_SCHEMATIC)

get_kicad_binary_path(binary_name)

Returns the full path to a Zeo binary.

cli_path = kicad.get_kicad_binary_path("kicad-cli")

get_plugin_settings_path(identifier)

Returns a writable path for plugin settings.

settings_path = kicad.get_plugin_settings_path("org.example.myplugin")

get_text_extents(text)

Returns the bounding box of a text object.

from kipy.common_types import Text

text = Text()
text.text = "Hello World"
bbox = kicad.get_text_extents(text)

get_text_as_shapes(texts)

Converts text to polygonal shapes.

shapes = kicad.get_text_as_shapes(text)

Example

from kipy import KiCad

# Connect to Zeo
kicad = KiCad()

# Print version info
print(f"Connected to Zeo {kicad.get_version()}")

# Get schematic and board
sch = kicad.get_schematic()
board = kicad.get_board()

# Work with them...
symbols = sch.crud.get_items()
footprints = board.crud.get_items()