summaryrefslogtreecommitdiff
path: root/gerbonara/aperture_macros
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-04-18 12:26:03 +0200
committerjaseg <git@jaseg.de>2023-04-19 00:51:27 +0200
commit2c6c9a5cbc6d389a17c0cc15173c6e626fd5d5c6 (patch)
treedd588a4beff48425d5723f767a25e51d28e4500f /gerbonara/aperture_macros
parent263033c9bdecf8c82027f6475c863d818f499914 (diff)
downloadgerbonara-2c6c9a5cbc6d389a17c0cc15173c6e626fd5d5c6.tar.gz
gerbonara-2c6c9a5cbc6d389a17c0cc15173c6e626fd5d5c6.tar.bz2
gerbonara-2c6c9a5cbc6d389a17c0cc15173c6e626fd5d5c6.zip
Basic KiCad footprint rendering works
Diffstat (limited to 'gerbonara/aperture_macros')
-rw-r--r--gerbonara/aperture_macros/parse.py11
-rw-r--r--gerbonara/aperture_macros/primitive.py11
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,