Collapsible Cup
A travel cup made of nested conical rings that prints in place as a flat puck and pulls out into a cup. All rings share one taper; pulling a ring up closes the radial gap to the ring inside it until the two cones wedge together, and because the bottom of each ring is narrower than the top of the next one it cannot pull through. The gap is computed from the taper and the overlap you ask for, and the file checks for every pair of rings that they are clear when collapsed, still free just before the lock height and blocked just past it. With the defaults (5 rings, 75 mm mouth, 22 mm rings, 6 deg taper, 6 mm overlap) it is 78 x 78 x 22 mm collapsed and 86 mm tall extended, with a 1.7 mm gap between the rings on the bed. Print it as modelled, mouth up, no supports; the rings are free as soon as it leaves the bed. The taper joints hold dry goods well and seal liquids only as well as the print is smooth. Ring count, mouth diameter, ring height, taper, overlap, wall and floor thickness are parameters.
# Collapsible Cup - nested conical rings that pull out and lock on their taper, printed in place
#
# How it works: every ring is a thin cone shell with the same taper, wider at
# the top. Collapsed, the rings stand inside each other with a radial gap.
# Pulling a ring up moves its wall towards the ring inside it; after
# travel = gap / tan(taper) the two cones meet and wedge: the narrow bottom of
# the outer ring is smaller than the wide top of the inner one, so it cannot
# pull through. The gap is chosen so that the rings still overlap by
# `overlap` when they lock. The innermost ring carries the floor.
#
# Print orientation: as modelled (view = print), collapsed, all rings on the
# bed, mouth up, no supports. The rings are separate solids from the start;
# pull the outer ring up to open the cup, press down to collapse it. The
# taper joints hold dry goods and seal only as well as the print is smooth.
@param choices:["print", "extended"] group:"Output" desc:"Collapsed as printed, or pulled out and locked"
$view = "print"
@param 3..8 step:1 group:"Cup" desc:"Number of rings"
$rings = 5
@param 50..110 step:1 group:"Cup" desc:"Inner diameter of the mouth (mm)"
$mouth_d = 75
@param 12..40 step:1 group:"Cup" desc:"Height of one ring = collapsed height (mm)"
$ring_h = 22
@param 3..10 step:0.5 group:"Rings" desc:"Taper of the walls from vertical (deg)"
$taper = 6.0
@param 3..12 step:0.5 group:"Rings" desc:"Overlap of two rings when locked (mm)"
$overlap = 6.0
@param 1.2..3 step:0.1 group:"Rings" desc:"Wall thickness, measured horizontally (mm)"
$wall = 1.6
@param 1..3 step:0.2 group:"Rings" desc:"Floor thickness (mm)"
$floor_t = 1.6
# --- Taper and overlap -------------------------------------------------------
$n = $rings
$tt = tan($taper)
$travel = $ring_h - $overlap # a ring rises this far before it locks
$gap = $travel * $tt # radial gap between two collapsed rings
$step = $wall + $gap # radius step from ring to ring
$lean = $ring_h * $tt # a wall leans out this far over its height
$lock = $lean - $gap # top of the inner ring is this much wider (radius) than the bottom bore of the outer
assert $overlap < $ring_h
assert $gap >= 0.4 # printable in place
assert $lock ~ ($overlap * $tt) tol:0.001
assert $lock >= 0.3 # the cone cannot pull through
# ring j, counted from the outside: inner radius at the top and at the bottom
def r_top(j) = $mouth_d / 2 - j * $step
def r_bot(j) = r_top(j) - $lean
assert r_bot($n - 1) >= 12 # the floor ring stays a usable size
# top outer radius of ring j + 1 against the bottom bore of ring j
def no_pull(j) = if j >= $n - 1 then true else (r_top(j + 1) + $wall > r_bot(j) + 0.3 and no_pull(j + 1))
assert no_pull(0)
# --- Rings -------------------------------------------------------------------
def wall_ring(j) = polyline [(r_bot(j), 0), (r_bot(j) + $wall, 0), (r_top(j) + $wall, $ring_h), (r_top(j), $ring_h)] | revolve Y | rotate 90 0 0
$rf = r_bot($n - 1)
$cup_floor = polyline [(0, 0), ($rf + $wall, 0), (r_top($n - 1) + $wall, $ring_h), (r_top($n - 1), $ring_h), ($rf + $floor_t * $tt, $floor_t), (0, $floor_t)] | revolve Y | rotate 90 0 0
def ring(j) = if j == $n - 1 then $cup_floor else wall_ring(j)
def up(j, z) = ring(j) | translate 0 0 z
$r0 = ring(0)
assert $r0.solids == 1
assert $r0.bbox.x ~ ($mouth_d + 2 * $wall) tol:0.01
assert $r0.bbox.z ~ $ring_h tol:0.01
assert $r0.bbox.min[2] ~ 0 tol:0.001
assert $cup_floor.solids == 1
assert $cup_floor.bbox.x ~ (2 * (r_top($n - 1) + $wall)) tol:0.01
# --- Lock: every ring against the next one in ---------------------------------
# collapsed they are clear; the outer ring is still clear 0.3 mm before the
# lock height and collides 0.3 mm past it, so it cannot be pulled through.
def pair_ok(j) = if j >= $n - 1 then true else (clear(ring(j), ring(j + 1)) and clear(up(j, $travel - 0.3), ring(j + 1)) and clear(up(j, $travel + 0.3), ring(j + 1)) == false and pair_ok(j + 1))
assert pair_ok(0)
# --- Layout ------------------------------------------------------------------
$printed = union [ring(j) for j in range($n)]
# extended: every ring 0.2 mm short of its lock, so the rings stay separate solids
$rise = $travel - 0.2
$extended = union [up(j, ($n - 1 - j) * $rise) for j in range($n)]
assert $printed.solids == $n
assert $printed.bbox.z ~ $ring_h tol:0.01
assert if $view == "extended" then $extended.solids == $n else true
$full_h = $ring_h + ($n - 1) * $travel
print "gap" $gap "travel" $travel "lock (radius)" $lock "floor inner diameter" (2 * $rf)
print "collapsed height" $ring_h "extended height" $full_h "outer diameter" ($mouth_d + 2 * $wall)
if $view == "extended" then $extended else $printed