From a374483998baff2fab4c43027c83f8bf97e5fdf5 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 19 Feb 2023 23:42:17 +0100 Subject: cli: First draft of most of the CLI --- gerbonara/apertures.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'gerbonara/apertures.py') diff --git a/gerbonara/apertures.py b/gerbonara/apertures.py index a30cf13..4f41941 100644 --- a/gerbonara/apertures.py +++ b/gerbonara/apertures.py @@ -254,8 +254,8 @@ class CircleAperture(Aperture): def scaled(self, scale): return replace(self, diameter=self.diameter*scale, - hold_dia=None if self.hole_dia is None else self.hole_dia*scale, - hold_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale) + hole_dia=None if self.hole_dia is None else self.hole_dia*scale, + hole_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale) def to_macro(self): return ApertureMacroInstance(GenericMacros.circle, self._params(unit=MM)) @@ -310,8 +310,8 @@ class RectangleAperture(Aperture): return replace(self, w=self.w*scale, h=self.h*scale, - hold_dia=None if self.hole_dia is None else self.hole_dia*scale, - hold_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale) + hole_dia=None if self.hole_dia is None else self.hole_dia*scale, + hole_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale) def to_macro(self): return ApertureMacroInstance(GenericMacros.rect, @@ -375,15 +375,18 @@ class ObroundAperture(Aperture): return replace(self, w=self.w*scale, h=self.h*scale, - hold_dia=None if self.hole_dia is None else self.hole_dia*scale, - hold_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale) + hole_dia=None if self.hole_dia is None else self.hole_dia*scale, + hole_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale) def to_macro(self): # generic macro only supports w > h so flip x/y if h > w - inst = self if self.w > self.h else replace(self, w=self.h, h=self.w, **_rotate_hole_90(self), rotation=self.rotation-90) + if self.w > self.h: + inst = self + else: + inst = replace(self, w=self.h, h=self.w, **self._rotate_hole_90(), rotation=self.rotation-90) return ApertureMacroInstance(GenericMacros.obround, [MM(inst.w, self.unit), - MM(ints.h, self.unit), + MM(inst.h, self.unit), MM(inst.hole_dia, self.unit), MM(inst.hole_rect_h, self.unit), inst.rotation]) @@ -434,7 +437,7 @@ class PolygonAperture(Aperture): def scaled(self, scale): return replace(self, diameter=self.diameter*scale, - hold_dia=None if self.hole_dia is None else self.hole_dia*scale) + hole_dia=None if self.hole_dia is None else self.hole_dia*scale) def to_macro(self): return ApertureMacroInstance(GenericMacros.polygon, self._params(MM)) -- cgit