Compare commits

..

2 Commits

View File

@ -36,33 +36,43 @@ else:
args.hole = float(args.hole) args.hole = float(args.hole)
assert(args.height != None) assert(args.height != None)
GRID = args.hole+args.padding args.kerf2 = args.kerf/2
RADIUS = args.hole/2 args.grid = args.hole+args.padding
DIMX = 2*(args.dimension+2)*GRID args.radius = args.hole/2
DIMY = (args.dimension+2)*GRID args.interior_edge = args.grid*args.dimension*0.5+args.outside_padding
args.exterior_edge = args.interior_edge+args.thickness
args.interior_leg = (args.interior_edge-args.horizontal_finger-args.kerf)/2
args.n_hor_fingers = int(args.exterior_edge/args.horizontal_finger/2)
args.exterior_leg = (args.exterior_edge-(2*args.n_hor_fingers-1)*args.horizontal_finger+args.kerf)/2
args.exterior_slot = (args.exterior_edge-args.horizontal_finger+args.kerf)/2
args.n_ver_fingers = int(args.height/args.vertical_finger/2)
args.vertical_finger = args.height/args.n_ver_fingers/2
DIMX = 2.9*args.grid*args.dimension
DIMY = 3.8*args.grid*args.dimension
PI3 = math.pi/3 PI3 = math.pi/3
def draw_grid(cx, cy): def draw_grid(cx, cy):
for row in range(-int(args.dimension/2), int((args.dimension+1)/2)): for row in range(-int(args.dimension/2), int((args.dimension+1)/2)):
cyr = cy+GRID*row*math.sin(PI3) cyr = cy+args.grid*row*math.sin(PI3)
num_col = args.dimension-abs(row) num_col = args.dimension-abs(row)
cxr = cx-.5*GRID*(num_col-1.0) cxr = cx-.5*args.grid*(num_col-1.0)
for col in range(num_col): for col in range(num_col):
print('<circle cx="%.2f" cy="%.2f" r="%.2f" stroke="black" fill="none"/>' % (cxr+col*GRID, cyr, RADIUS)) print('<circle cx="%.2f" cy="%.2f" r="%.2f" stroke="black" fill="none"/>' % (cxr+col*args.grid, cyr, args.radius))
def draw_plane(cx, cy, interior=False): def draw_plane(cx, cy, interior=False):
radius = GRID*args.dimension*0.5+args.outside_padding if interior:
if not interior: edge = args.interior_edge
radius += args.thickness else:
edge = args.exterior_edge
turtle = svgturtle.SvgTurtle(cx, cy) turtle = svgturtle.SvgTurtle(cx, cy)
turtle.penup() turtle.penup()
turtle.forward(radius) turtle.forward(edge)
turtle.right(120) turtle.right(120)
turtle.pendown() turtle.pendown()
if interior: if interior:
leg = (radius-args.horizontal_finger-args.kerf)/2
for side in range(6): for side in range(6):
turtle.forward(leg) turtle.forward(args.interior_leg)
turtle.left(90) turtle.left(90)
turtle.forward(args.thickness) turtle.forward(args.thickness)
turtle.right(90) turtle.right(90)
@ -70,16 +80,76 @@ def draw_plane(cx, cy, interior=False):
turtle.right(90) turtle.right(90)
turtle.forward(args.thickness) turtle.forward(args.thickness)
turtle.left(90) turtle.left(90)
turtle.forward(leg) turtle.forward(args.interior_leg)
turtle.right(60) turtle.right(60)
else: else:
for side in range(6): for side in range(6):
turtle.forward(radius) for finger in range(args.n_hor_fingers):
turtle.forward(args.exterior_leg if finger == 0 else args.horizontal_finger+args.kerf)
turtle.right(90)
turtle.forward(args.thickness)
turtle.left(90)
turtle.forward(args.horizontal_finger-args.kerf)
turtle.left(90)
turtle.forward(args.thickness)
turtle.right(90)
turtle.forward(args.exterior_leg)
turtle.right(60) turtle.right(60)
print('<path d="%s" fill="none" stroke="black"/>' % turtle.to_s()) print('<path d="%s" fill="none" stroke="black"/>' % turtle.to_s())
def draw_side(x0, y0, h, slots):
turtle = svgturtle.SvgTurtle(x0, y0+args.thickness)
for finger in range(args.n_hor_fingers):
turtle.forward(args.exterior_leg-args.kerf if finger == 0 else args.horizontal_finger-args.kerf)
turtle.left(90)
turtle.forward(args.thickness)
turtle.right(90)
turtle.forward(args.horizontal_finger+args.kerf)
turtle.right(90)
turtle.forward(args.thickness)
turtle.left(90)
turtle.forward(args.exterior_leg-args.kerf-args.thickness)
turtle.right(90)
for finger in range(args.n_ver_fingers):
turtle.forward(args.vertical_finger-(args.kerf/2 if finger==0 else args.kerf))
turtle.left(90)
turtle.forward(args.thickness)
turtle.right(90)
turtle.forward(args.vertical_finger+args.kerf)
turtle.right(90)
if finger < args.n_ver_fingers-1:
turtle.forward(args.thickness)
turtle.left(90)
turtle.forward(args.exterior_edge-args.thickness)
turtle.right(90)
for finger in range(args.n_ver_fingers):
turtle.forward(args.vertical_finger-(args.kerf/2 if finger==0 else args.kerf))
turtle.left(90)
turtle.forward(args.thickness)
turtle.right(90)
turtle.forward(args.vertical_finger+args.kerf)
turtle.right(90)
if finger < args.n_ver_fingers-1:
turtle.forward(args.thickness)
turtle.left(90)
print('<path d="%s" fill="none" stroke="black"/>' % turtle.to_s())
for slot in slots:
x = x0+args.exterior_slot
y = y0+slot
w = args.horizontal_finger-args.kerf
h = args.thickness-args.kerf
print('<rect x="%.2f" y="%.2f" width="%.2f" height="%.2f" fill="none" stroke="black"/>' % (x, y, w, h))
print('<svg viewBox="0 0 %.2f %.2f" width="%.2fmm" height="%.2fmm" stroke-width="0.1" xmlns="http://www.w3.org/2000/svg">' % (DIMX, DIMY, DIMX, DIMY)) print('<svg viewBox="0 0 %.2f %.2f" width="%.2fmm" height="%.2fmm" stroke-width="0.1" xmlns="http://www.w3.org/2000/svg">' % (DIMX, DIMY, DIMX, DIMY))
draw_grid(GRID*(0.5*args.dimension+1), GRID*(0.5*args.dimension+1)) draw_grid(0.65*args.grid*args.dimension, 0.60*args.grid*args.dimension)
draw_plane(GRID*(0.5*args.dimension+1), GRID*(0.5*args.dimension+1), True) draw_plane(0.65*args.grid*args.dimension, 0.60*args.grid*args.dimension, True)
draw_plane(GRID*(1.5*args.dimension+3), GRID*(0.5*args.dimension+1)) draw_grid(1.90*args.grid*args.dimension, 0.60*args.grid*args.dimension)
draw_plane(1.90*args.grid*args.dimension, 0.60*args.grid*args.dimension, True)
draw_plane(0.65*args.grid*args.dimension, 1.90*args.grid*args.dimension)
draw_side(0.05*args.grid*args.dimension, 2.50*args.grid*args.dimension, args.height, [args.height*.3, args.height*.7])
draw_side(0.75*args.grid*args.dimension, 2.50*args.grid*args.dimension, args.height, [args.height*.3, args.height*.7])
draw_side(1.45*args.grid*args.dimension, 2.50*args.grid*args.dimension, args.height, [args.height*.3, args.height*.7])
draw_side(2.15*args.grid*args.dimension, 2.50*args.grid*args.dimension, args.height, [args.height*.3, args.height*.7])
draw_side(1.35*args.grid*args.dimension, 1.25*args.grid*args.dimension, args.height, [args.height*.3, args.height*.7])
draw_side(2.05*args.grid*args.dimension, 1.25*args.grid*args.dimension, args.height, [args.height*.3, args.height*.7])
print('</svg>') print('</svg>')