Hardware
KiCAD
What is KiCAD?
KiCad is a free and open-source software suite used for electronic design automation (EDA). It allows users to create schematic diagrams and printed circuit board (PCB) layouts. It is widely used by hobbyists, engineers, and professionals for designing circuits and manufacturing PCBs.
Symbol Library
Footprint Library
Project
Schematic
PCB
Gerber
KiCad API
Checkout latest KiCad API documentation here and there
$ conda create -n kicad python=3.9
$ pip install kicad-python
Examples
Connect to KiCad
Make sure you have KiCad open and the API is enabled in the settings.
from kipy import KiCad
if __name__=='__main__':
try:
kicad = KiCad()
print(f"Connected to KiCad {kicad.get_version()}")
except BaseException as e:
print(f"Not connected to KiCad: {e}")
Draw a Zone
from kipy import KiCad
from kipy.board_types import (
BoardLayer,
Zone
)
from kipy.common_types import PolygonWithHoles
from kipy.geometry import PolyLine, PolyLineNode
from kipy.util import from_mm
if __name__=='__main__':
kicad = KiCad()
board = kicad.get_board()
outline = PolyLine()
outline.append(PolyLineNode.from_xy(from_mm(100), from_mm(100)))
outline.append(PolyLineNode.from_xy(from_mm(110), from_mm(100)))
outline.append(PolyLineNode.from_xy(from_mm(110), from_mm(110)))
outline.append(PolyLineNode.from_xy(from_mm(100), from_mm(110)))
outline.append(PolyLineNode.from_xy(from_mm(100), from_mm(100)))
polygon = PolygonWithHoles()
polygon.outline = outline
zone = Zone()
zone.layers = [BoardLayer.BL_F_Cu, BoardLayer.BL_B_Cu]
zone.outline = polygon
board.create_items(zone)