2 # Copyright 2020 by Bdale Garbee <bdale@gag.com>. GPLv3
4 # Python library to assist in generating lihata format footprints for pcb-rnd
6 # Each footprint should have a parent Python script that initializes this
7 # library and provides a high-level description of the primitives required.
8 # The footprint is delivered to stdout, so the encapsulating Makefile and/or
9 # iterating wrapper script is responsible for redirecting to the desired
10 # <something>.lht file(s).
15 class footprint(object):
20 self.dist_license = "GPLv3"
21 self.use_license = "Unlimited"
22 self.author = "Bdale Garbee <bdale@gag.com>"
26 # (proposed argument lists taken from pcb land_patterns doc)
27 # -- can probably collapse sflags+nflags->flags?
29 # the basic plan is that each primitive function puts the object
30 # definition in the relevant dictionary .. when we go to emit the
31 # part, we'll do things like work out the minimum set of padstack
32 # prototypes by iterating over the dictionaries... then output the
33 # working set of required objects
37 # x1, y1, x2, y2, thickness, clearance, mask, name, number, sflags, nflags
39 # x, y, thickness, clearance, mask, drill, name, number, sflags, nflags
44 # x1, y1, x2, y2, thickness
46 # x, y, width, height, startangle, deltaangle, thickness
48 def emit_padstack_prototypes(self):
49 print("prototypes will go here")
51 def emit_padstacks(self):
52 print("padstacks will go here")
54 def emit_top_silk(self):
55 print("top_silk will go here")
57 def emit_line(self, role, id, x1, y1, x2, y2, unit):
58 print(" ha:line.%u {" % id)
59 print(" clearance = 0")
60 print(" thickness = 0")
61 print(" ha:attributes {")
62 print(" subc-role = %s" % role)
64 print(" x1 = %u%s" % (x1, unit))
65 print(" y1 = %u%s" % (y1, unit))
66 print(" x2 = %u%s" % (x2, unit))
67 print(" y2 = %u%s" % (y2, unit))
69 self.cnt = self.cnt + 1
73 print(" ha:subc-aux {")
80 print(" li:objects {")
81 self.emit_line("origin", self.cnt, 0, 0, 0, 0, "mm");
82 self.emit_line("x", self.cnt, 0, 0, 1, 0, "mm");
83 self.emit_line("y", self.cnt, 0, 0, 0, 1, "mm");
87 def create_uuid(self):
88 return hashlib.md5(self.name).hexdigest()
91 print("li:pcb-rnd-subcircuit-v4 {")
93 print(" ha:attributes {")
94 print(" description = %s" % self.description)
95 print(" dist_license = %s" % self.dist_license)
96 print(" use_license = %s" % self.use_license)
97 print(" author = %s" % self.author)
99 print(" uid = %s" % self.create_uuid())
101 self.emit_padstack_prototypes()
102 print(" li:objects {")
103 self.emit_padstacks()
105 print(" li:layers {")