summaryrefslogtreecommitdiff
path: root/gerbonara
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2024-07-19 19:21:24 +0200
committerjaseg <git@jaseg.de>2024-07-19 19:21:24 +0200
commit5f5bbccd050414afaf01dd578198d19b4d26ef87 (patch)
tree54fe5628753b0f46f9937a227f841ba0b76fbeb5 /gerbonara
parentea2664219d108e0426c22434bb3262cb1e53579c (diff)
downloadgerbonara-5f5bbccd050414afaf01dd578198d19b4d26ef87.tar.gz
gerbonara-5f5bbccd050414afaf01dd578198d19b4d26ef87.tar.bz2
gerbonara-5f5bbccd050414afaf01dd578198d19b4d26ef87.zip
kicad: Add copy_placement method to footprints
Moving footprints around is ugly because of kicad's really weird way of specifying sub-object coordinates and rotations. This commit adds a helper method to deal with that.
Diffstat (limited to 'gerbonara')
-rw-r--r--gerbonara/cad/kicad/footprints.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/gerbonara/cad/kicad/footprints.py b/gerbonara/cad/kicad/footprints.py
index 43230ce..da2c61e 100644
--- a/gerbonara/cad/kicad/footprints.py
+++ b/gerbonara/cad/kicad/footprints.py
@@ -733,6 +733,14 @@ class Footprint:
def offset(self, x=0, y=0):
self.at = self.at.with_offset(x, y)
+ def copy_placement(self, template):
+ # Fix up rotation of pads - KiCad saves each pad's rotation in *absolute* coordinates, not relative to the
+ # footprint. Because we overwrite the footprint's rotation below, we have to first fix all pads to match the
+ # new rotation.
+ self.rotate(math.radians(template.at.rotation - self.at.rotation))
+ self.at = copy.copy(template.at)
+ self.side = template.side
+
@property
def version(self):
return self._version