Hex Key Holder
A block that stands a set of L-shaped hex keys upright in size order, with each size engraved on the top face in front of its pocket. The pockets are hexagonal, so a key cannot turn and only drops into its own size or a bigger one, which makes the right key obvious at a glance. Choose the metric set (1.5 to 10 mm, nine keys) or the inch set (1/16 to 3/8 inch, twelve keys). The metric holder measures 139 x 30 x 22 mm and the inch holder 184 x 30 x 22 mm; both print flat on the base with no supports. Adjustable parameters: key set, pocket play, pocket depth, pocket pitch and the wall margin.
# Hex Key Holder - a block that stands a set of L-shaped hex keys upright, sizes engraved
#
# One hexagonal pocket per key, in size order, with the size engraved on the top face in
# front of it. Put the short leg of each key in its pocket so the long legs stand up in a
# row. The pockets are hexagonal so a key cannot turn and the right size is obvious at a
# glance: a key only drops into its own pocket or a bigger one. Metric or inch set by
# `standard`. Prints flat on its base with no supports.
@param choices:["metric", "inch"] desc:"Key set"
$standard = "metric"
@param 0.2..0.6 step:0.05 desc:"Play added to each pocket (mm, across flats)"
$play = 0.35
@param 10..30 step:1 desc:"Pocket depth (mm)"
$depth = 18
@param 12..20 step:1 desc:"Pocket pitch (mm)"
$pitch = 15
@param 2..4 step:0.5 desc:"Wall in front of and behind the pockets (mm)"
$margin = 3
# --- Size tables (mm across flats) ---------------------------------------------
$metric = [1.5, 2, 2.5, 3, 4, 5, 6, 8, 10]
$metric_lbl = ["1.5", "2", "2.5", "3", "4", "5", "6", "8", "10"]
$inch = [1.5875, 1.9844, 2.3813, 2.7781, 3.175, 3.5719, 3.9688, 4.7625, 5.5563, 6.35, 7.9375, 9.525]
$inch_lbl = ["1/16", "5/64", "3/32", "7/64", "1/8", "9/64", "5/32", "3/16", "7/32", "1/4", "5/16", "3/8"]
$sizes = if $standard == "metric" then $metric else $inch
$labels = if $standard == "metric" then $metric_lbl else $inch_lbl
$n = len($sizes)
$big = $sizes[$n - 1]
# --- Block -------------------------------------------------------------------
$len = $n * $pitch + 4
$wid = $big + 2 * $margin + 14 # room for the label in front of the pockets
$h = $depth + 4
$y_hole = $wid - $margin - $big / 2 - 1 # pockets along the back
$y_lbl = 6
$block = box $len $wid $h center:(false, false, false) | edges =Z | fillet 3 | edges >Z | chamfer 1
$pockets = union [polygon 6 (($sizes[$i] + $play) / sqrt(3)) at:(4 + $pitch * ($i + 0.5), $y_hole) angle:30
| extrude ($depth + 1) | translate 0 0 ($h - $depth) for $i in range($n)]
$marks = union [text $labels[$i] 3.6 at:(4 + $pitch * ($i + 0.5), $y_lbl) | extrude 1.5 | translate 0 0 ($h - 0.6) for $i in range($n)]
$holder = $block - $pockets - $marks
assert $holder.solids == 1
assert $holder.bbox.x ~ $len
assert $holder.bbox.z ~ $h
assert $pitch - ($big + $play) * 2 / sqrt(3) >= 1.5 # wall between the two largest pockets
assert $holder.volume < $block.volume - $n * $depth * 1.5 # the pockets were cut
print "holder" $holder.bbox
print "keys" $n
$holder