From 35618179036409c71c87746c32a27238260a02a4 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 12 Jun 2023 18:39:33 +0200 Subject: Add basic KiCad PCB file format support --- gerbonara/cad/kicad/base_types.py | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'gerbonara/cad/kicad/base_types.py') diff --git a/gerbonara/cad/kicad/base_types.py b/gerbonara/cad/kicad/base_types.py index 8f3036c..6bb5912 100644 --- a/gerbonara/cad/kicad/base_types.py +++ b/gerbonara/cad/kicad/base_types.py @@ -9,6 +9,42 @@ from contextlib import contextmanager from itertools import cycle +LAYER_MAP_K2G = { + 'F.Cu': ('top', 'copper'), + 'B.Cu': ('bottom', 'copper'), + 'F.SilkS': ('top', 'silk'), + 'B.SilkS': ('bottom', 'silk'), + 'F.Paste': ('top', 'paste'), + 'B.Paste': ('bottom', 'paste'), + 'F.Mask': ('top', 'mask'), + 'B.Mask': ('bottom', 'mask'), + 'B.CrtYd': ('bottom', 'courtyard'), + 'F.CrtYd': ('top', 'courtyard'), + 'B.Fab': ('bottom', 'fabrication'), + 'F.Fab': ('top', 'fabrication'), + 'B.Adhes': ('bottom', 'adhesive'), + 'F.Adhes': ('top', 'adhesive'), + 'Dwgs.User': ('mechanical', 'drawings'), + 'Cmts.User': ('mechanical', 'comments'), + 'Edge.Cuts': ('mechanical', 'outline'), + } + +LAYER_MAP_G2K = {v: k for k, v in LAYER_MAP_K2G.items()} + + +@sexp_type('group') +class Group: + name: str = "" + id: Named(str) = "" + members: Named(List(str)) = field(default_factory=list) + + +@sexp_type('property') +class Property: + key: str = '' + value: str = '' + + @sexp_type('color') class Color: r: int = None @@ -186,6 +222,19 @@ class Timestamp: def bump(self): self.value = uuid.uuid4() +@sexp_type('uuid') +class UUID: + value: str = field(default_factory=uuid.uuid4) + + def __after_parse__(self, parent): + self.value = str(self.value) + + def before_sexp(self): + self.value = Atom(str(self.value)) + + def bump(self): + self.value = uuid.uuid4() + @sexp_type('tedit') class EditTime: value: str = field(default_factory=time.time) -- cgit