diff options
Diffstat (limited to 'gerbonara/aperture_macros')
-rw-r--r-- | gerbonara/aperture_macros/parse.py | 11 | ||||
-rw-r--r-- | gerbonara/aperture_macros/primitive.py | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/gerbonara/aperture_macros/parse.py b/gerbonara/aperture_macros/parse.py index f0ff8d6..868f7ae 100644 --- a/gerbonara/aperture_macros/parse.py +++ b/gerbonara/aperture_macros/parse.py @@ -178,6 +178,17 @@ class GenericMacros: ap.Circle('mm', [1, var(3)*2, -(var(1)/2-var(3)), -(var(2)/2-var(3)), 0]), *_generic_hole(4)]) + # params: width, height, length difference between narrow side (top) and wide side (bottom), *hole, rotation + isosceles_trapezoid = ApertureMacro('GTR', [ + ap.Outline('mm', [1, 4, + var(1)/-2, var(2)/-2, + var(1)/-2+var(3)/2, var(2)/2, + var(1)/2-var(3)/2, var(2)/2, + var(1)/2, var(2)/-2, + var(1)/-2, var(2)/-2, + var(6) * -deg_per_rad]), + *_generic_hole(4)]) + # w must be larger than h obround = ApertureMacro('GNO', [ ap.CenterLine('mm', [1, var(1), var(2), 0, 0, var(5) * -deg_per_rad]), diff --git a/gerbonara/aperture_macros/primitive.py b/gerbonara/aperture_macros/primitive.py index f9b5a78..5b93971 100644 --- a/gerbonara/aperture_macros/primitive.py +++ b/gerbonara/aperture_macros/primitive.py @@ -11,6 +11,7 @@ import math from .expression import Expression, UnitExpression, ConstantExpression, expr from .. import graphic_primitives as gp +from .. import graphic_objects as go def point_distance(a, b): @@ -18,8 +19,13 @@ def point_distance(a, b): x2, y2 = b return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) + def deg_to_rad(a): - return (a / 180) * math.pi + return a * (math.pi / 180) + +def rad_to_deg(a): + return a * (180 / math.pi) + class Primitive: def __init__(self, unit, args): @@ -240,7 +246,7 @@ class Outline(Primitive): self.exposure = args.pop(0) # length arg must not contain variables (that would not make sense) - length_arg = args.pop(0).calculate() + length_arg = (args.pop(0) * ConstantExpression(1)).calculate() if length_arg != len(args)//2-1: raise ValueError(f'Invalid aperture macro outline primitive, given size {length_arg} does not match length of coordinate list({len(args)//2-1}).') @@ -290,6 +296,7 @@ class Comment: def scale(self, scale): pass + PRIMITIVE_CLASSES = { **{cls.code: cls for cls in [ Comment, |