summaryrefslogtreecommitdiff
path: root/gerbonara/cad/kicad/footprints.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/footprints.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/footprints.py')
-rw-r--r--gerbonara/cad/kicad/footprints.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/gerbonara/cad/kicad/footprints.py b/gerbonara/cad/kicad/footprints.py
index 9772b55..aedf9b8 100644
--- a/gerbonara/cad/kicad/footprints.py
+++ b/gerbonara/cad/kicad/footprints.py
@@ -389,6 +389,12 @@ class Pad:
_: SEXP_END = None
footprint: object = None
+ def __after_parse__(self, parent=None):
+ self.layers = unfuck_layers(self.layers)
+
+ def __before_sexp__(self):
+ self.layers = fuck_layers(self.layers)
+
def find_connected(self, **filters):
""" Find footprints connected to the same net as this pad """
return self.footprint.board.find_footprints(net=self.net.name, **filters)
@@ -677,12 +683,19 @@ class Footprint:
x, y = self.at.x-cx, self.at.y-cy
self.at.x = math.cos(angle)*x - math.sin(angle)*y + cx
self.at.y = math.sin(angle)*x + math.cos(angle)*y + cy
-
- self.at.rotation -= math.degrees(angle)
+ self.at.rotation -= math.degrees(angle)
for pad in self.pads:
pad.at.rotation -= math.degrees(angle)
+ def set_rotation(self, angle):
+ old_deg = self.at.rotation
+ new_deg = self.at.rotation = -math.degrees(angle)
+ delta = new_deg - old_deg
+
+ for pad in self.pads:
+ pad.at.rotation += delta
+
def objects(self, text=False, pads=True):
return chain(
(self.texts if text else []),