diff options
author | jaseg <git@jaseg.de> | 2024-07-08 16:29:57 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2024-07-08 16:29:57 +0200 |
commit | 66811af9663d0171effbddd69b7cdde60954ccb2 (patch) | |
tree | bb3366f90de18d1d2213fe7b2d71baef904a187d /gerbonara/cad/kicad | |
parent | ec85d6c169620fd0968693b19b6109fb0184aa36 (diff) | |
download | gerbonara-66811af9663d0171effbddd69b7cdde60954ccb2.tar.gz gerbonara-66811af9663d0171effbddd69b7cdde60954ccb2.tar.bz2 gerbonara-66811af9663d0171effbddd69b7cdde60954ccb2.zip |
kicad: Bring file format up to current 8.99 nightly
Diffstat (limited to 'gerbonara/cad/kicad')
-rw-r--r-- | gerbonara/cad/kicad/__init__.py | 1 | ||||
-rw-r--r-- | gerbonara/cad/kicad/base_types.py | 49 | ||||
-rw-r--r-- | gerbonara/cad/kicad/footprints.py | 24 | ||||
-rw-r--r-- | gerbonara/cad/kicad/pcb.py | 2 | ||||
-rw-r--r-- | gerbonara/cad/kicad/primitives.py | 1 | ||||
-rw-r--r-- | gerbonara/cad/kicad/symbols.py | 5 |
6 files changed, 52 insertions, 30 deletions
diff --git a/gerbonara/cad/kicad/__init__.py b/gerbonara/cad/kicad/__init__.py index e69de29..8b13789 100644 --- a/gerbonara/cad/kicad/__init__.py +++ b/gerbonara/cad/kicad/__init__.py @@ -0,0 +1 @@ + diff --git a/gerbonara/cad/kicad/base_types.py b/gerbonara/cad/kicad/base_types.py index 59a727d..a4eba70 100644 --- a/gerbonara/cad/kicad/base_types.py +++ b/gerbonara/cad/kicad/base_types.py @@ -37,11 +37,29 @@ LAYER_MAP_K2G = { LAYER_MAP_G2K = {v: k for k, v in LAYER_MAP_K2G.items()} +@sexp_type('uuid') +class UUID: + value: str = field(default_factory=uuid.uuid4) + + def __deepcopy__(self, memo): + return UUID() + + def __after_parse__(self, parent): + self.value = str(self.value) + + def before_sexp(self): + self.value = str(self.value) + + def bump(self): + self.value = uuid.uuid4() + + @sexp_type('group') class Group: name: str = "" - id: Named(str) = "" - members: Named(List(str)) = field(default_factory=list) + id: Named(str) = None + uuid: UUID = field(default_factory=UUID) + members: Named(Array(str)) = field(default_factory=list) @sexp_type('color') @@ -298,8 +316,8 @@ class FontSpec: face: Named(str) = None size: Rename(XYCoord) = field(default_factory=lambda: XYCoord(1.27, 1.27)) thickness: Named(float) = None - bold: Flag() = False - italic: Flag() = False + bold: OmitDefault(Named(YesNoAtom())) = False + italic: OmitDefault(Named(YesNoAtom())) = False line_spacing: Named(float) = None @@ -327,7 +345,7 @@ class Justify: @sexp_type('effects') class TextEffect: font: FontSpec = field(default_factory=FontSpec) - hide: Flag() = False + hide: OmitDefault(Named(YesNoAtom())) = False justify: OmitDefault(Justify) = field(default_factory=Justify) @@ -469,23 +487,6 @@ class Timestamp: self.value = uuid.uuid4() -@sexp_type('uuid') -class UUID: - value: str = field(default_factory=uuid.uuid4) - - def __deepcopy__(self, memo): - return UUID() - - 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) @@ -523,8 +524,10 @@ class DrawnProperty(TextMixin): value: str = None id: Named(int) = None at: AtPos = field(default_factory=AtPos) + unlocked: Named(YesNoAtom()) = True layer: Named(str) = None - hide: Flag() = False + hide: Named(YesNoAtom()) = False + uuid: UUID = field(default_factory=UUID) tstamp: Timestamp = None effects: TextEffect = field(default_factory=TextEffect) _ : SEXP_END = None diff --git a/gerbonara/cad/kicad/footprints.py b/gerbonara/cad/kicad/footprints.py index 31a5f33..cb7b69d 100644 --- a/gerbonara/cad/kicad/footprints.py +++ b/gerbonara/cad/kicad/footprints.py @@ -21,6 +21,7 @@ from . import graphical_primitives as gr from ..primitives import Positioned +from ... import __version__ from ... import graphic_primitives as gp from ... import graphic_objects as go from ... import apertures as ap @@ -56,6 +57,7 @@ class Text: at: AtPos = field(default_factory=AtPos) unlocked: Flag() = False layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) hide: Flag() = False effects: TextEffect = field(default_factory=TextEffect) tstamp: Timestamp = None @@ -72,12 +74,14 @@ class TextBox: locked: Flag() = False text: str = None start: Rename(XYCoord) = None - end: Named(XYCoord) = None + end: Rename(XYCoord) = None pts: PointList = None angle: Named(float) = 0.0 layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) tstamp: Timestamp = None effects: TextEffect = field(default_factory=TextEffect) + border: Named(YesNoAtom()) = False stroke: Stroke = field(default_factory=Stroke) render_cache: RenderCache = None @@ -90,6 +94,7 @@ class Line: start: Rename(XYCoord) = None end: Rename(XYCoord) = None layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) width: Named(float) = None stroke: Stroke = None locked: Flag() = False @@ -113,6 +118,7 @@ class Rectangle: start: Rename(XYCoord) = None end: Rename(XYCoord) = None layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) width: Named(float) = None stroke: Stroke = None fill: Named(AtomChoice(Atom.solid, Atom.none)) = None @@ -146,6 +152,7 @@ class Circle: center: Rename(XYCoord) = None end: Rename(XYCoord) = None layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) width: Named(float) = None stroke: Stroke = None fill: Named(AtomChoice(Atom.solid, Atom.none)) = None @@ -184,6 +191,7 @@ class Arc: width: Named(float) = None stroke: Stroke = None layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) locked: Flag() = False tstamp: Timestamp = None @@ -237,6 +245,7 @@ class Arc: class Polygon: pts: PointList = field(default_factory=PointList) layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) width: Named(float) = None stroke: Stroke = None fill: Named(AtomChoice(Atom.solid, Atom.none)) = None @@ -266,6 +275,7 @@ class Polygon: class Curve: pts: PointList = field(default_factory=PointList) layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) width: Named(float) = None stroke: Stroke = None locked: Flag() = False @@ -302,6 +312,7 @@ class Dimension: locked: Flag() = False type: AtomChoice(Atom.aligned, Atom.leader, Atom.center, Atom.orthogonal, Atom.radial) = None layer: Named(str) = None + uuid: UUID = field(default_factory=UUID) tstamp: Timestamp = None pts: PointList = field(default_factory=PointList) height: Named(float) = None @@ -375,8 +386,9 @@ class Pad: drill: Drill = None layers: Named(Array(str)) = field(default_factory=list) properties: List(Property) = field(default_factory=list) - remove_unused_layers: Wrap(Flag()) = False - keep_end_layers: Wrap(Flag()) = False + remove_unused_layers: Named(YesNoAtom()) = False + keep_end_layers: Named(YesNoAtom()) = False + uuid: UUID = field(default_factory=UUID) rect_delta: Rename(XYCoord) = None roundrect_rratio: Named(float) = None thermal_bridge_angle: Named(int) = 45 @@ -595,6 +607,7 @@ class Pad: @sexp_type('model') class Model: name: str = '' + hide: Flag() = False at: Named(XYZCoord) = field(default_factory=XYZCoord) offset: Named(XYZCoord) = field(default_factory=XYZCoord) scale: Named(XYZCoord) = field(default_factory=XYZCoord) @@ -606,7 +619,8 @@ SUPPORTED_FILE_FORMAT_VERSIONS = [20210108, 20211014, 20221018, 20230517] class Footprint: name: str = None _version: Named(int, name='version') = 20221018 - generator: Named(Atom) = Atom.gerbonara + generator: Named(str) = Atom.gerbonara + generator_version: Named(str) = __version__ locked: Flag() = False placed: Flag() = False layer: Named(str) = 'F.Cu' @@ -902,7 +916,7 @@ class Footprint: y += self.at.y rotation += math.radians(self.at.rotation) - for obj in self.objects(pads=False, text=text, zones=False): + for obj in self.objects(pads=False, text=text, zones=False, groups=False): if not (layer := layer_map.get(obj.layer)): continue diff --git a/gerbonara/cad/kicad/pcb.py b/gerbonara/cad/kicad/pcb.py index c5b2bd3..767b763 100644 --- a/gerbonara/cad/kicad/pcb.py +++ b/gerbonara/cad/kicad/pcb.py @@ -248,7 +248,7 @@ class Via: layers: Named(Array(str)) = field(default_factory=lambda: ['F.Cu', 'B.Cu']) remove_unused_layers: Flag() = False keep_end_layers: Flag() = False - free: Wrap(Flag()) = False + free: Named(YesNoAtom()) = False net: Named(int) = 0 tstamp: Timestamp = field(default_factory=Timestamp) diff --git a/gerbonara/cad/kicad/primitives.py b/gerbonara/cad/kicad/primitives.py index 65e83ac..65566d0 100644 --- a/gerbonara/cad/kicad/primitives.py +++ b/gerbonara/cad/kicad/primitives.py @@ -153,6 +153,7 @@ class Zone: net_name: Named(str) = "" layer: Named(str) = None layers: Named(Array(str)) = None + uuid: UUID = field(default_factory=UUID) tstamp: Timestamp = None name: Named(str) = None hatch: Hatch = None diff --git a/gerbonara/cad/kicad/symbols.py b/gerbonara/cad/kicad/symbols.py index 3c6fab2..5e460be 100644 --- a/gerbonara/cad/kicad/symbols.py +++ b/gerbonara/cad/kicad/symbols.py @@ -18,6 +18,7 @@ from .sexp import * from .sexp_mapper import * from .base_types import * from ...utils import rotate_point, Tag, arc_bounds +from ... import __version__ from ...newstroke import Newstroke from .schematic_colors import * from .primitives import kicad_mid_to_center_arc @@ -481,6 +482,7 @@ class Symbol: pin_numbers: OmitDefault(PinNumberSpec) = field(default_factory=PinNumberSpec) pin_names: OmitDefault(PinNameSpec) = field(default_factory=PinNameSpec) exclude_from_sim: OmitDefault(Named(YesNoAtom())) = False + exclude_from_sim: Named(YesNoAtom()) = False in_bom: Named(YesNoAtom()) = True on_board: Named(YesNoAtom()) = True properties: List(Property) = field(default_factory=list) @@ -573,7 +575,8 @@ SUPPORTED_FILE_FORMAT_VERSIONS = [20211014, 20220914] @sexp_type('kicad_symbol_lib') class Library: _version: Named(int, name='version') = 20211014 - generator: Named(Atom) = Atom.gerbonara + generator: Named(str) = Atom.gerbonara + generator_version: Named(str) = __version__ symbols: List(Symbol) = field(default_factory=list) _ : SEXP_END = None original_filename: str = None |