#!/usr/bin/env -S uv run --script # /// script # dependencies = [ # "gerbonara", # "click" # ] # /// import math from gerbonara.cad.kicad.pcb import Board from gerbonara.cad.kicad.graphical_primitives import Arc, Line, XYCoord, Stroke import click __version__ = '1.0' @click.command() def cli(): board = Board() board.properties = {} board.nets = {} board.setup = None d2 = 76 #d1 = 52 d1 = 55 #d1 = 60 a = 55 def radial_xy(d, a): return XYCoord(d/2 * math.sin(math.radians(a)), d/2 * math.cos(math.radians(a))) class Drawer: def __init__(self, board): self.board = board self.last_point = None self.first_point = None def move(self, d, a): self.first_point = self.last_point = radial_xy(d, a) def line(self, d, a): assert self.last_point next_point = radial_xy(d, a) self.board.lines.append(Line( start=self.last_point, end=next_point, layer='Edge.Cuts', stroke=Stroke(width=0.2))) self.last_point = next_point def arc(self, d, a, center=(0, 0)): assert self.last_point next_point = radial_xy(d, a) self.board.arcs.append(Arc( start=self.last_point, end=next_point, center=XYCoord(*center), layer='Edge.Cuts', stroke=Stroke(width=0.2))) self.last_point = next_point def close_line(self): self.board.lines.append(Line( start=self.last_point, end=self.first_point, layer='Edge.Cuts', stroke=Stroke(width=0.2))) self.last_point = None d = Drawer(board) d.move(d2, a) d.arc(d2, -a) d.line(d1, -a) d.arc(d1, -180 + a) d.line(d2, -180 + a) d.arc(d2, 180 - a) d.line(d1, 180-a) d.arc(d1, a) d.close_line() board.write('outline.kicad_pcb') if __name__ == '__main__': cli()