Skip to content

Commit

Permalink
Support fp shapes in pad
Browse files Browse the repository at this point in the history
Fixes #42
@easyw
  • Loading branch information
realthunder committed Sep 24, 2021
1 parent cedb6b8 commit 14e9bf5
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions kicad.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,9 @@ def _makeEdgeCuts(self, sexp, ctx, wires, non_closed, at=None):
_,layer = self.findLayer(44)
except Exception:
raise RuntimeError('No Edge.Cuts layer found')
return self._makeShape(sexp, ctx, wires, non_closed, layer, at)

def _makeShape(self, sexp, ctx, wires, non_closed=None, layer=None, at=None):
edges = []

if at:
Expand All @@ -981,7 +983,10 @@ def _makeEdgeCuts(self, sexp, ctx, wires, non_closed, at=None):
self._log('making {} {}s',len(primitives), tp)
make_shape = globals()['make_gr_{}'.format(tp)]
for l in primitives:
if l.layer != layer:
if not layer:
if self.filterNets(l) or self.filterLayer(l):
continue
elif l.layer != layer:
continue
shape = make_shape(l)
if angle:
Expand All @@ -1001,7 +1006,8 @@ def _makeEdgeCuts(self, sexp, ctx, wires, non_closed, at=None):

for info in edges:
w,e = info
e.fixTolerance(w)
if w > 1e-7:
e.fixTolerance(w)
info += [e.firstVertex().Point,e.lastVertex().Point]

while edges:
Expand All @@ -1012,21 +1018,21 @@ def _makeEdgeCuts(self, sexp, ctx, wires, non_closed, at=None):
i = 0
while i < len(edges):
w,e,ps,pe = edges[i]
if pstart.distanceToPoint(ps) < (wstart+w)/2:
if pstart.distanceToPoint(ps) <= (wstart+w)/2:
e.reverse()
pstart = pe
wstart = w
elist.insert(0,(w,e))
elif pstart.distanceToPoint(pe) < (wstart+w)/2:
elif pstart.distanceToPoint(pe) <= (wstart+w)/2:
pstart = ps
wstart = w
elist.insert(0,(w,e))
elif pend.distanceToPoint(ps) < (wend+w)/2:
elif pend.distanceToPoint(ps) <= (wend+w)/2:
e.reverse()
pend = pe
wend = w
elist.append((w,e))
elif pend.distanceToPoint(pe) < (wend+w)/2:
elif pend.distanceToPoint(pe) <= (wend+w)/2:
pend = ps
wend = w
elist.append((w,e))
Expand All @@ -1035,7 +1041,7 @@ def _makeEdgeCuts(self, sexp, ctx, wires, non_closed, at=None):
continue
edges.pop(i)
i = 0
if pstart.distanceToPoint(pend) < (wstart+wend)/2:
if pstart.distanceToPoint(pend) <= (wstart+wend)/2:
closed = True
break

Expand All @@ -1056,9 +1062,15 @@ def _makeEdgeCuts(self, sexp, ctx, wires, non_closed, at=None):

if wire and closed:
wires.append(wire)
elif non_closed is not None:
for w,e in elist:
if w > 5e-7:
non_closed[w].append(e)
else:
for w,e in elist:
non_closed[w].append(e)
if w > 5e-7:
wires.append(self._makeWires(
e, name=None, offset=w*0.5, thicken=True))

def makeBoard(self,shape_type='solid',thickness=None,fit_arcs=True,
holes=True, minHoleSize=0,ovalHole=True,prefix=''):
Expand Down Expand Up @@ -1097,7 +1109,7 @@ def _wire():
objs.append(self._makeWires(wires,'board'))

for width,edges in non_closed.items():
objs.append(self._makeWires(edges,'board',label=width))
objs.append(self._makeWires(edges,'board',label=width,offset=width*0.5))

return self._makeCompound(_addHoles(objs),'board')

Expand Down Expand Up @@ -1466,6 +1478,8 @@ def _face(obj,name,label=None):
else:
pads.append(w)

self._makeShape(m, 'fp', pads)

if not pads:
continue

Expand Down

0 comments on commit 14e9bf5

Please sign in to comment.