2 # Copyright 2020 by Bdale Garbee <bdale@gag.com>. GPLv3
4 # Python library to assist in generating lihata format footprints for pcb-rnd
10 class footprint(object):
17 self.dist_license = "GPLv3"
18 self.use_license = "Unlimited"
19 self.author = "Bdale Garbee <bdale@gag.com>"
23 # (proposed argument lists taken from pcb land_patterns doc)
24 # -- can probably collapse sflags+nflags->flags?
26 # the basic plan is that each primitive function puts the object
27 # definition in the relevant dictionary .. when we go to emit the
28 # part, we'll do things like work out the minimum set of padstack
29 # prototypes by iterating over the dictionaries... then output the
30 # working set of required objects
34 # x1, y1, x2, y2, thickness, clearance, mask, name, number, sflags, nflags
36 # x, y, thickness, clearance, mask, drill, name, number, sflags, nflags
41 # x1, y1, x2, y2, thickness
43 # x, y, width, height, startangle, deltaangle, thickness
45 def writeln(self, stuff):
46 self.output.write(stuff + "\n")
48 def emit_padstack_prototypes(self):
49 self.writeln("prototypes will go here")
51 def emit_padstacks(self):
52 self.writeln("padstacks will go here")
54 def emit_top_silk(self):
55 self.writeln("top_silk will go here")
57 def emit_line(self, role, id, x1, y1, x2, y2, unit):
58 self.writeln(" ha:line.%u {" % id)
59 self.writeln(" clearance = 0")
60 self.writeln(" thickness = 0")
61 self.writeln(" ha:attributes {")
62 self.writeln(" subc-role = %s" % role)
64 self.writeln(" x1 = %u%s" % (x1, unit))
65 self.writeln(" y1 = %u%s" % (y1, unit))
66 self.writeln(" x2 = %u%s" % (x2, unit))
67 self.writeln(" y2 = %u%s" % (y2, unit))
69 self.cnt = self.cnt + 1
73 self.writeln(" ha:subc-aux {")
74 self.writeln(" lid = 1")
75 self.writeln(" ha:type {")
76 self.writeln(" top = 1")
77 self.writeln(" misc = 1")
78 self.writeln(" virtual = 1")
80 self.writeln(" 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 self.writeln("li:pcb-rnd-subcircuit-v4 {")
92 self.writeln(" ha:subc.0 {")
93 self.writeln(" ha:attributes {")
94 self.writeln(" description = %s" % self.description)
95 self.writeln(" dist_license = %s" % self.dist_license)
96 self.writeln(" use_license = %s" % self.use_license)
97 self.writeln(" author = %s" % self.author)
99 self.writeln(" uid = %s" % self.create_uuid())
100 self.writeln(" ha:data {")
101 self.emit_padstack_prototypes()
102 self.writeln(" li:objects {")
103 self.emit_padstacks()
105 self.writeln(" li:layers {")