2 # Python library to assist in generating lihata format footprints for pcb-rnd
3 # Copyright 2020 by Bdale Garbee <bdale@gag.com>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # Each footprint should have a parent Python script that initializes this
16 # library and provides a high-level description of the primitives required.
17 # The footprint is delivered to stdout, so the encapsulating Makefile and/or
18 # iterating wrapper script is responsible for redirecting to the desired
19 # <something>.lht file(s).
24 class footprint(object):
29 self.dist_license = "GPLv3"
30 self.use_license = "Unlimited"
31 self.author = "Bdale Garbee <bdale@gag.com>"
35 # (proposed argument lists taken from pcb land_patterns doc)
36 # -- can probably collapse sflags+nflags->flags?
38 # the basic plan is that each primitive function puts the object
39 # definition in the relevant dictionary .. when we go to emit the
40 # part, we'll do things like work out the minimum set of padstack
41 # prototypes by iterating over the dictionaries... then output the
42 # working set of required objects
46 # x1, y1, x2, y2, thickness, clearance, mask, name, number, sflags, nflags
48 # x, y, thickness, clearance, mask, drill, name, number, sflags, nflags
53 # x1, y1, x2, y2, thickness
55 # x, y, width, height, startangle, deltaangle, thickness
57 def emit_padstack_prototypes(self):
58 print("prototypes will go here")
60 def emit_padstacks(self):
61 print("padstacks will go here")
63 def emit_top_silk(self):
64 print("top_silk will go here")
66 def emit_line(self, role, id, x1, y1, x2, y2, unit):
67 print(" ha:line.%u {" % id)
68 print(" clearance = 0")
69 print(" thickness = 0")
70 print(" ha:attributes {")
71 print(" subc-role = %s" % role)
73 print(" x1 = %u%s" % (x1, unit))
74 print(" y1 = %u%s" % (y1, unit))
75 print(" x2 = %u%s" % (x2, unit))
76 print(" y2 = %u%s" % (y2, unit))
78 self.cnt = self.cnt + 1
82 print(" ha:subc-aux {")
89 print(" li:objects {")
90 self.emit_line("origin", self.cnt, 0, 0, 0, 0, "mm");
91 self.emit_line("x", self.cnt, 0, 0, 1, 0, "mm");
92 self.emit_line("y", self.cnt, 0, 0, 0, 1, "mm");
96 def create_uuid(self):
97 return hashlib.md5(self.name).hexdigest()
100 print("li:pcb-rnd-subcircuit-v4 {")
101 print(" ha:subc.0 {")
102 print(" ha:attributes {")
103 print(" description = %s" % self.description)
104 print(" dist_license = %s" % self.dist_license)
105 print(" use_license = %s" % self.use_license)
106 print(" author = %s" % self.author)
108 print(" uid = %s" % self.create_uuid())
110 self.emit_padstack_prototypes()
111 print(" li:objects {")
112 self.emit_padstacks()
114 print(" li:layers {")