summaryrefslogtreecommitdiff
path: root/gerbonara/cad/kicad/primitives.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-07-06 22:42:39 +0200
committerjaseg <git@jaseg.de>2023-07-06 22:42:39 +0200
commit572486aa25711a432ff08ff8fad8ad91670661b7 (patch)
tree75dc09f1ea2def4185618fccaf7c07c50f8a0959 /gerbonara/cad/kicad/primitives.py
parent0799cc55adc096b488820ebac46fbb4c54b24e45 (diff)
downloadgerbonara-572486aa25711a432ff08ff8fad8ad91670661b7.tar.gz
gerbonara-572486aa25711a432ff08ff8fad8ad91670661b7.tar.bz2
gerbonara-572486aa25711a432ff08ff8fad8ad91670661b7.zip
kicad: Fix layers attribute handling and improve rotation API
Diffstat (limited to 'gerbonara/cad/kicad/primitives.py')
-rw-r--r--gerbonara/cad/kicad/primitives.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/gerbonara/cad/kicad/primitives.py b/gerbonara/cad/kicad/primitives.py
index 40cb22c..6e9f41d 100644
--- a/gerbonara/cad/kicad/primitives.py
+++ b/gerbonara/cad/kicad/primitives.py
@@ -1,10 +1,24 @@
import enum
+import re
from .sexp import *
from .base_types import *
+def unfuck_layers(layers):
+ if layers and layers[0] == 'F&B.Cu':
+ return ['F.Cu', 'B.Cu', *layers[1:]]
+ else:
+ return layers
+
+def fuck_layers(layers):
+ if layers and 'F.Cu' in layers and 'B.Cu' in layers and not any(re.match(r'^In[0-9]+\.Cu$', l) for l in layers):
+ return ['F&B.Cu', *(l for l in layers if l not in ('F.Cu', 'B.Cu'))]
+ else:
+ return layers
+
+
@sexp_type('hatch')
class Hatch:
style: AtomChoice(Atom.none, Atom.edge, Atom.full) = Atom.edge
@@ -81,12 +95,23 @@ class Zone:
connect_pads: PadConnection = field(default_factory=PadConnection)
min_thickness: Named(float) = 0.254
filled_areas_thickness: Named(YesNoAtom()) = True
- keepout: ZoneKeepout = field(default_factory=ZoneKeepout)
+ keepout: ZoneKeepout = None
fill: ZoneFill = field(default_factory=ZoneFill)
polygon: ZonePolygon = field(default_factory=ZonePolygon)
fill_polygons: List(FillPolygon) = field(default_factory=list)
fill_segments: List(FillSegment) = field(default_factory=list)
+ def __after_parse__(self, parent=None):
+ self.layers = unfuck_layers(self.layers)
+
+ def __before_sexp__(self):
+ self.layers = fuck_layers(self.layers)
+
+ def unfill(self):
+ self.fill.yes = False
+ self.fill_polygons = []
+ self.fill_segments = []
+
@sexp_type('polygon')
class RenderCachePolygon: