from koko.lib.shapes import * from cad_shapes import * import numpy cad.mm_per_unit = 25.4 # inch units e = 1.0 # half of the edge width d = 0.25 # column width (per edge) e2 = e/2.0 # half of the edge width of the inner cube d2 = d # column width (per edge) of the inner cube g = 0.625*d # diagonal connector width factor (additive on something) pedestal_delta = 0.25 # extra amount for pedestal lip # based on current design, the outer (face) # width is 2*(e+ pedestal_delta). # need to check z depth! # Render boundaries B = 1*(e+pedestal_delta) # remove the 2 cad.xmin = -B cad.xmax = B cad.ymin = -B cad.ymax = B cad.zmin = -B cad.zmax = B def cube_edge(e, d): c = cube(-e, e, -e, e, -e, e) c = subtract(c, cube(-e+d, e-d, -e+d, e-d, -e, e)) c = subtract(c, cube(-e, e, -e+d, e-d, -e+d, e-d)) c = subtract(c, cube(-e+d, e-d, -e, e, -e+d, e-d)) return c onehole = triangle(1.5*(-e+d+g), 1.5*(-e+d), 0, 0-g, 1.5*(e-d-g), 1.5*(-e+d)) #onehole = add(onehole, rectangle(-e+d+g,e-d-g,-e-d-g-1,-e+d)) hole = add(onehole, rotate_z(onehole, 90)) hole = add(hole, rotate_z(onehole, 180)) hole = add(hole, rotate_z(onehole, 270)) cols = cube(-e-d,e+d,-e-d,e+d,-e-d,e+d) cols = subtract(cols, hole) cols = subtract(cols, rotate_x(hole, 90)) cols = subtract(cols, rotate_y(hole, 90)) # was: cols = intersect(cols, cube(-e+d, e-d, -e+d, e-d, -e+d, e-d)) cols = intersect(cols, cube(-e, e, -e, e, -e, e)) c = add(cols, cube_edge(e, d)) c = add(c, cube_edge(e2, e2)) # second cube # copied code alert: remove the inner stuff from the second cube c = subtract(c, cube(-e2+d2, e2-d2, -e2+d2, e2-d2, -e2, e2)) c = subtract(c, cube(-e2, e2, -e2+d2, e2-d2, -e2+d2, e2-d2)) c = subtract(c, cube(-e2+d2, e2-d2, -e2, e2, -e2+d2, e2-d2)) # now we process it to make the mold shell pattern tmp = e pyra = pyramid(-tmp, tmp, -tmp, tmp, -tmp, 0) boundingcube = cube(-tmp, tmp, -tmp, tmp, -tmp, tmp) c = intersect(c, pyra) # this is now the per-face positive c = subtract(pyra, c) # this is the per-face negative, this is what the silicone will look like (without the pedestal) # make the mold pedestal: delta = 0.05 # gap before registration block pedestal = extrusion(rectangle(-e-pedestal_delta, e+pedestal_delta, -e-pedestal_delta, e+pedestal_delta), -e-pedestal_delta, -e) pedestal = intersect(pedestal, pyramid(-e-pedestal_delta, e+pedestal_delta, -e-pedestal_delta, e+pedestal_delta, -e-pedestal_delta, 0 # -e-pedestal_delta + numpy.sqrt(2.0)*(e+pedestal_delta) )) zmin = -e-pedestal_delta zmax = -e pedestal = subtract(pedestal, extrusion(rectangle(-pedestal_delta/2, pedestal_delta/2, -e-pedestal_delta,-e-delta),zmin,zmax)) pedestal = add(pedestal, extrusion(rectangle(-pedestal_delta/2, pedestal_delta/2, e+delta, e+pedestal_delta),zmin,zmax)) pedestal = subtract(pedestal, extrusion(rectangle(-e-pedestal_delta,-e-delta, -pedestal_delta/2, pedestal_delta/2),zmin,zmax)) pedestal = add(pedestal, extrusion(rectangle(e+delta, e+pedestal_delta, -pedestal_delta/2, pedestal_delta/2),zmin,zmax)) c = add(c, pedestal) # this is what the complete silicone mold will look like tmp = e+pedestal_delta c = subtract(cube(-tmp,tmp,-tmp,tmp,-tmp,tmp), c) # this is the upside-down positive c = rotate_y(c, 180) # need vent and sprue holes! # combine molds to check for overlap? #c1 = rotate_y(c, 90) #c2 = rotate_y(c, 180) #c3 = rotate_y(c, 270) #c = add(add(add(c, c1), c2), c3) # c = subtract(boundingcube, c) # rotate a bit for better visualization? #c = rotate_x(c, 45) #c = rotate_y(c, 45) #c = rotate_z(c, 45) cad.function = c