from cad_shapes import * mm_inch = 25.4 scale_factor = 1.0 def inchn(x): return mm_inch * x def inch(x): return scale_factor * mm_inch * x def wslot(x, y, width, height, angle = 0, chamfer = 0.2): slot = rectangle(-width/2, width/2, -height, 0) inset = triangle(width/2, 0, width/2 + width * chamfer, 0, width/2, -chamfer*width) inset = add(inset, reflect_x(inset)) slot = add(slot, inset) slot = rotate(slot, angle) slot = move(slot, x, y) return MString(slot) def mslot(x, y, width, height): slot = rectangle(-width/2, width/2, -height, 0) slot = move(slot, x, y) return MString(slot) # Render boundaries cwidth = inchn(18) cheight = inchn(12) cad.xmin = inchn(-18) cad.xmax = inchn(18) cad.ymin = inchn(-12) cad.ymax = inchn(12) #cad.mm_per_unit = 25.4 # inch units cad.mm_per_unit = 1.0 # Overall variables width = height = inch(18) lip = inch(1.5) th = 4.0 # Shelf variables shelf_width = inch(11.5) shelf_height = inch(6) shelf_offset = -height/6 wall_offset = th # Slot variables delta = width/2 - shelf_width/2 chamfer = 0.3 slot_depth = height/3 ################################### # Main panel panel = rectangle( -width/2, width/2, -height/2, height/2) # Shelf shelf = rectangle( -shelf_width/2, shelf_width/2, shelf_offset-shelf_height/2, shelf_offset + shelf_height/2) #panel = subtract(panel, shelf) # Slots slot_inc = width/7.0 x0 = -width/2 + slot_inc for step in range(0,6): # perp panel slot x = x0 + step*slot_inc cutout = reflect_y(wslot(x, 0, th, 2*slot_depth, 0, chamfer), 0) cutout = move(cutout, 0, -height/2, 0) panel = subtract(panel, cutout) cad.function = panel