2010-08-05 20:58:16 +03:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2010-08-14 03:15:11 +03:00
|
|
|
import shape
|
|
|
|
|
|
|
|
|
2010-08-05 20:58:16 +03:00
|
|
|
#
|
|
|
|
# gnuplot the outline
|
|
|
|
#
|
|
|
|
|
2010-08-14 03:39:45 +03:00
|
|
|
def outline_gnuplot(sk, points):
|
2010-08-05 20:58:16 +03:00
|
|
|
while len(points):
|
|
|
|
print points.pop(0), points.pop(0)
|
2010-08-06 05:42:08 +03:00
|
|
|
print
|
2010-08-05 20:58:16 +03:00
|
|
|
|
|
|
|
|
2010-08-14 03:15:11 +03:00
|
|
|
def gnuplot_line(x0, y0, x1, y1):
|
|
|
|
print x0, y0
|
|
|
|
print x1, y1
|
|
|
|
print
|
|
|
|
|
|
|
|
|
2010-08-05 20:58:16 +03:00
|
|
|
#
|
|
|
|
# make a HeeksCAD sketch of the outline
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
def cad_line(sk, x0, y0, x1, y1):
|
|
|
|
cad.line(x0, y0, x1, y1)
|
|
|
|
cad.add(sk, cad.getlastobj())
|
|
|
|
|
|
|
|
|
2010-08-14 03:39:45 +03:00
|
|
|
def outline_cad(sk, points):
|
2010-08-06 05:42:08 +03:00
|
|
|
last_x = points.pop(0)
|
|
|
|
last_y = points.pop(0)
|
2010-08-05 20:58:16 +03:00
|
|
|
while len(points):
|
|
|
|
x = points.pop(0)
|
|
|
|
y = points.pop(0)
|
|
|
|
cad_line(sk, last_x, last_y, x, y)
|
|
|
|
last_x = x
|
|
|
|
last_y = y
|
|
|
|
|
|
|
|
cad.reorder(sk)
|
|
|
|
return sk
|
|
|
|
|
|
|
|
|
2010-08-14 03:39:45 +03:00
|
|
|
def closed_outline(sk, *args):
|
2010-08-06 05:42:08 +03:00
|
|
|
l = list(args)
|
|
|
|
l.append(args[0])
|
|
|
|
l.append(args[1])
|
2010-08-14 03:39:45 +03:00
|
|
|
do(sk, l)
|
2010-08-06 05:42:08 +03:00
|
|
|
|
|
|
|
|
2010-08-14 03:39:45 +03:00
|
|
|
def open_outline(sk, *args):
|
|
|
|
do(sk, list(args))
|
2010-08-05 20:58:16 +03:00
|
|
|
|
2010-08-14 03:15:11 +03:00
|
|
|
|
|
|
|
def line(*args):
|
|
|
|
do_line(*args)
|
|
|
|
|
|
|
|
|
2010-08-05 20:58:16 +03:00
|
|
|
#
|
|
|
|
# Make the cover sheet 2 mm larger than the counterweight on all sides. We need
|
|
|
|
# the following exceptions to avoid mechanical interference:
|
|
|
|
#
|
|
|
|
# - at the power connector, keep the ymin edge flush with the counterweight
|
|
|
|
# - follow the counterweight's J-shaped space for the reset button, with the
|
|
|
|
# border reduced from 2 mm to 0.5 mm
|
|
|
|
# - next to the long side of the battery, follow the counterweight's edge
|
|
|
|
# - also follow the counterweight's bay for the battery cover's tongue and
|
|
|
|
# make it even 0.5 mm larger, anticipating imperfect registration
|
|
|
|
#
|
|
|
|
# Also, as a simplification, we don't follow steps and recesses in these cases:
|
|
|
|
#
|
|
|
|
# - 1 mm steps on the left and right side. Just use the larger size.
|
|
|
|
# - the whole sponge area. Just put the cover on top of the sponge.
|
|
|
|
# - all recesses near the batter, except the one for the lid's central tongue
|
|
|
|
#
|
|
|
|
# The above simplifications are possible, because, being on top of the
|
|
|
|
# counterweight, we've already cleared the obstacles these steps and recesses
|
|
|
|
# are designed to avoid.
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Note: to visualize the shape defined below, plot the counterweight in 2D with
|
|
|
|
# gnuplot and follow the shape it the mouse.
|
|
|
|
#
|
|
|
|
# To visualize the result, do this:
|
|
|
|
#
|
|
|
|
# ./cw.py >cw.gnuplot
|
|
|
|
# ./cvr.py >cvr.gnuplot
|
|
|
|
# gnuplot
|
|
|
|
# gnuplot> set style data lines
|
|
|
|
# gnuplot> plot "cw.gnuplot", "cvr.gnuplot"
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2010-08-14 03:39:45 +03:00
|
|
|
def outline(sk):
|
|
|
|
closed_outline(sk,
|
2010-08-05 20:58:16 +03:00
|
|
|
# counterweight corners: (16, 46) and (15, 60)
|
|
|
|
13, 46,
|
|
|
|
# (15, 69.5)
|
|
|
|
13, 71.5,
|
|
|
|
# (82.5, 65), (82.5, 64), (89.5, 64), (89.5, 69)
|
|
|
|
83, 71.5,
|
|
|
|
83, 64.5, 89, 64.5, 89, 71,
|
|
|
|
# (100, 69)
|
|
|
|
102, 71,
|
|
|
|
# (99.5, 46)
|
|
|
|
102, 44,
|
|
|
|
# (88, 46)
|
|
|
|
86, 44,
|
|
|
|
# (88, 55), (82, 50)
|
|
|
|
86, 50,
|
|
|
|
# (59.5, 55), (59.5, 56.5), (52.5, 56.5), (52.5, 55)
|
|
|
|
60, 50,
|
|
|
|
60, 57, 52, 57, 52, 50,
|
|
|
|
# (24, 55)
|
|
|
|
26, 50,
|
|
|
|
# (24, 46)
|
|
|
|
26, 46)
|
|
|
|
|
|
|
|
|
2010-08-14 03:39:45 +03:00
|
|
|
def label(sk):
|
2010-08-14 03:15:11 +03:00
|
|
|
u = 2
|
|
|
|
x = 40
|
|
|
|
y = 66
|
2010-08-06 05:42:08 +03:00
|
|
|
# C
|
2010-08-14 03:39:45 +03:00
|
|
|
open_outline(sk,
|
2010-08-14 03:15:11 +03:00
|
|
|
x+u, y+2*u,
|
|
|
|
x, y+2*u,
|
|
|
|
x, y,
|
|
|
|
x+u, y)
|
|
|
|
|
|
|
|
x += u*1.6
|
2010-08-06 05:42:08 +03:00
|
|
|
# W
|
2010-08-14 03:39:45 +03:00
|
|
|
open_outline(sk,
|
2010-08-14 03:15:11 +03:00
|
|
|
x, y+2*u,
|
|
|
|
x, y,
|
|
|
|
x+0.5*u, y+u,
|
|
|
|
x+u, y,
|
|
|
|
x+u, y+2*u)
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Counterweight outline -------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
lines = []
|
|
|
|
|
|
|
|
|
|
|
|
def rect_outline(x0, y0, z0, x1, y1, z1):
|
|
|
|
global lines
|
|
|
|
|
|
|
|
lines.append((x0, y0, x0, y1))
|
|
|
|
lines.append((x1, y0, x1, y1))
|
|
|
|
lines.append((x0, y0, x1, y0))
|
|
|
|
lines.append((x0, y1, x1, y1))
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Main ------------------------------------------------------------------
|
2010-08-06 05:42:08 +03:00
|
|
|
|
|
|
|
|
2010-08-05 20:58:16 +03:00
|
|
|
if __name__ == "__main__":
|
|
|
|
do = outline_gnuplot
|
2010-08-14 03:39:45 +03:00
|
|
|
sk = None
|
2010-08-05 20:58:16 +03:00
|
|
|
else:
|
|
|
|
import HeeksPython as cad
|
2010-08-14 03:39:45 +03:00
|
|
|
|
2010-08-05 20:58:16 +03:00
|
|
|
do = outline_cad
|
2010-08-14 03:39:45 +03:00
|
|
|
cad.sketch()
|
|
|
|
sk = cad.getlastobj()
|
|
|
|
|
2010-08-05 20:58:16 +03:00
|
|
|
|
2010-08-14 03:39:45 +03:00
|
|
|
outline(sk)
|
|
|
|
label(sk)
|
2010-08-14 03:15:11 +03:00
|
|
|
|
|
|
|
shape.rect = rect_outline
|
|
|
|
shape.make_base()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
for e in lines:
|
|
|
|
gnuplot_line(*e)
|
|
|
|
else:
|
|
|
|
for e in lines:
|
|
|
|
cad_line(sk, *e)
|