Dice Tower
Drop dice in the top and they tumble down baffles leaning 45 degrees, alternately from the back wall and the front wall, over a 45 degree ramp and out through an arched opening into a tray at the front. The baffle length is set from the largest die you use, so the zigzag path is always wide enough, and the file checks that the baffles do not overlap in height. The default takes dice up to 18 mm and measures 66 x 101 x 160 mm. Every overhang is 45 degrees, so it prints standing on its base with no supports. Adjustable parameters: inner width, height, wall thickness, number of baffles, largest die, tray depth and tray wall height.
# Dice Tower - drop dice in the top, they tumble down alternating 45 deg baffles into a tray
#
# A square tower with baffles leaning 45 deg, alternately from the back wall and the front
# wall, a 45 deg ramp at the bottom and an arched exit into a tray at the front. Every
# overhang is 45 deg, so it prints standing on its base with no supports. The baffle
# length is set from the largest die so the zigzag path is always wide enough.
@param 30..60 step:2 group:"Size" desc:"Inner width and depth of the tower (mm)"
$inner = 42
@param 120..220 step:10 group:"Size" desc:"Tower height (mm)"
$height = 160
@param 1.6..3 step:0.2 group:"Size" desc:"Wall thickness (mm)"
$wall = 2
@param 2..4 step:1 group:"Baffles" desc:"Number of baffles"
$baffles = 3
@param 12..24 step:1 group:"Baffles" desc:"Largest die the path must pass (mm)"
$die = 18
@param 30..80 step:5 group:"Tray" desc:"Tray depth in front of the tower (mm)"
$tray_d = 55
@param 6..15 step:1 group:"Tray" desc:"Tray wall height (mm)"
$tray_h = 10
$floor_t = 2
$outer = $inner + 2 * $wall
$gap = $die * 1.25 # free passage beside each baffle tip
$blen = ($inner - $gap) / cos(45) # baffle length along its slope
assert $blen > 8
$ramp_h = 18 # the bottom ramp rises this much at the back
$exit_w = $inner - 8
$exit_h = $die * 1.4 + $ramp_h / 2
# --- Tower shell, open top ---
$shell = (box $outer $outer $height center:(true, true, false))
- (box $inner $inner $height center:(true, true, false) | translate 0 0 $floor_t)
# --- Bottom ramp: 45 deg wedge from the back wall down toward the exit ---
$ramp = polyline [(-$inner / 2 + 1, $floor_t - 0.01), ($inner / 2 + 1, $floor_t - 0.01), ($inner / 2 + 1, $floor_t + $ramp_h), ($inner / 2 - $ramp_h, $floor_t - 0.01)]
| extrude ($inner + 2) | rotate 90 0 90 | translate (-$inner / 2 - 1) 0 0 # profile (y, z): rises toward +Y (back)
# --- Baffles: plates sloping down 45 deg from the wall toward the middle, alternately
# --- from the front (-Y) and the back (+Y) wall; dice roll off the tip into the gap ---
$drop = $blen * sin(45) # vertical extent of a baffle
$z0 = $floor_t + $ramp_h + $die + $drop # first baffle tip clears the ramp by one die
$pitch = ($height - $z0 - 10) / $baffles
assert $pitch > $drop + 4 # baffles do not overlap in height
def baffle($k) = box ($inner + 2) $blen $wall center:(true, false, false)
| rotate (if $k % 2 == 0 then -45 else -135) 0 0
| translate 0 (if $k % 2 == 0 then -$inner / 2 else $inner / 2) ($z0 + $k * $pitch)
| inter (box $inner $inner $height center:(true, true, false) | translate 0 0 $floor_t)
$baffle_set = union [baffle($k) for $k in range($baffles)]
# --- Exit: arched opening in the front wall (45 deg roof), and the tray ---
$exit = (box $exit_w ($wall + 2) $exit_h center:(true, true, false))
+ (polyline [(-$exit_w / 2, $exit_h - 0.01), ($exit_w / 2, $exit_h - 0.01), (0, $exit_h + $exit_w / 2)] | extrude ($wall + 2) | rotate 90 0 0 | translate 0 ($wall / 2 + 1) 0)
| translate 0 (-$inner / 2 - $wall / 2) $floor_t
$tray = (box ($outer + 20) ($tray_d + $wall) ($tray_h + $floor_t) center:(true, false, false) | translate 0 (-$outer / 2 - $tray_d) 0 | edges =Z | fillet 4)
- (box ($outer + 20 - 2 * $wall) $tray_d $tray_h center:(true, false, false) | translate 0 (-$outer / 2 - $tray_d) $floor_t)
$tower = ($shell + $ramp + $baffle_set + $tray) - $exit
assert $tower.solids == 1
assert $tower.bbox.x ~ ($outer + 20)
assert $tower.bbox.y ~ ($outer + $tray_d)
assert $tower.bbox.z ~ $height
assert $baffle_set.solids == $baffles
assert $exit_w >= $die + 4
assert $exit_h >= $die + 4
print "tower" $tower.bbox
print "passage beside each baffle (mm)" $gap
$tower