Cat Ball with Bell Cage
An openwork toy ball for cats, made of two halves that snap together around a jingle bell. One half carries a ring-shaped lip with a small bead that clicks into a groove in the rim of the other, so the ball opens again to change the bell. The wall is pierced by rings of round or hexagonal holes, with their latitudes and counts computed from the hole size and the bridge width, plus one hole at each pole. Every hole is smaller than the bell: the model asserts it, both as a rule on the parameters and by testing that a bell-sized sphere is stopped at the holes while it moves freely inside. The default ball is 50 mm across for a 15 mm bell, with 10 mm holes, and the print plate is 106 x 50 x 29.7 mm. Print both halves joint down, dome up, without supports. Ball diameter, wall, bell size, hole size, shape and ring count, bridge width and the snap dimensions can be changed.
# Cat Ball - openwork toy ball in two snap-together halves with room for a bell
#
# How it is used: drop a jingle bell into one half and press the other half on.
# The upper half carries a ring-shaped lip with a small bead around it; the lip
# goes into a counterbore in the rim of the lower half and the bead clicks into
# a groove there. The wall is pierced by rings of holes (and one at each pole)
# so the bell is heard and seen, and every hole is smaller than the bell: the
# model asserts that a bell-sized sphere is stopped at each of them.
#
# Print orientation: as laid out, both halves with the joint on the bed and the
# dome up. No supports at this size: the shoulder above the lip is a 45 deg cone
# and the only steep overhang is the inside of the dome around the pole hole.
@param choices:["plate", "assembled"] desc:"Print plate, or the two halves snapped together"
$view = "plate"
@param 35..80 step:1 group:"Ball" desc:"Ball diameter (mm)"
$ball_d = 50
@param 1.6..3 step:0.1 group:"Ball" desc:"Wall thickness (mm)"
$wall = 2
@param 6..30 step:0.5 group:"Bell" desc:"Diameter of the bell that goes inside (mm)"
$bell_d = 15
@param 4..20 step:0.5 group:"Holes" desc:"Hole diameter (mm), across corners for hex; must be smaller than the bell"
$hole_d = 10
@param choices:["round", "hex"] group:"Holes" desc:"Hole shape"
$hole_shape = "round"
@param 1..3 step:1 group:"Holes" desc:"Rings of holes in each half"
$rings = 2
@param 1.6..5 step:0.2 group:"Holes" desc:"Least bridge between neighbouring holes (mm)"
$web = 2
@param group:"Holes" desc:"One more hole at each pole"
$pole_hole = true
@param 2..5 step:0.5 group:"Joint" desc:"Height of the snap lip (mm)"
$lip_h = 3
@param 0.3..0.6 step:0.05 group:"Joint" desc:"Height of the snap bead on the lip (mm)"
$bead = 0.4
@param 0.1..0.4 step:0.05 group:"Joint" desc:"Radial clearance between lip and counterbore (mm)"
$clr = 0.2
# --- Derived (ball frame: centre at the origin, upper half at +Z) ----------------
$R = $ball_d / 2
$ri = $R - $wall # cavity radius
$rim_t = 2 # wall left outside the counterbore at the rim
$lip_t = 1.4 # lip thickness
$b = $R - $rim_t - $clr # lip outer radius
$a = $b - $lip_t # lip inner radius: the narrowest opening of the upper half
$z_s = -($R - $b) # the 45 deg shoulder runs from (R, 0) down to (b, z_s)
$z_l = $z_s - $lip_h # free end of the lip
$z_c = $z_l + 1 # height of the snap bead
$cham = 0.8 # 45 deg seat on the inner rim edge of the lower half
$seam = 0.1 # axial gap left at that seat
$z_f = $z_s + $cham + $clr - $seam # rim plane of the lower half
$z_floor = $z_l - 0.3 # counterbore floor, clear of the lip end
$groove = $bead + 0.15 # groove in the counterbore, a little larger than the bead
$z_t = 1 # the lip is carried up inside the upper half to here
$rm = ($R + $ri) / 2
$z_q = $z_t + $rm - $a # and merges into the wall at (rm, z_q)
$hr = $hole_d / 2
assert $hole_d <= $bell_d - 2 # the bell cannot get out through a hole
assert 2 * $a >= $bell_d + 2 # but it goes in through the open half
assert 2 * $ri >= 2 * $bell_d # and has room to roll and ring
assert $bead > $clr + 0.1 # the bead really catches
assert sqrt($rm * $rm + $z_q * $z_q) < $R - 0.3 # the lip carrier ends inside the wall
assert sqrt($rm * $rm + $z_q * $z_q) > $ri + 0.3
assert sqrt($R * $R - $z_floor * $z_floor) - ($b + $clr) >= 1.2 # wall outside the counterbore
assert sqrt($R * $R - $z_c * $z_c) - ($b + $clr + $groove) >= 0.8 # and behind the groove
# --- Hole pattern: latitudes and counts computed from hole size and bridge width --
$alpha = asin($hr / $ri) # angular radius of a hole, seen from the centre
$web_deg = degrees($web / $ri)
$z_lim = max($z_q, -$z_floor) + 1 # holes stay this far from the equator, clear of the joint
$lat_min = asin($z_lim / $ri) + $alpha
$lat_max = if $pole_hole then 90 - 2 * $alpha - $web_deg else 90 - $alpha - $web_deg - 6
$lat_step = if $rings > 1 then ($lat_max - $lat_min) / ($rings - 1) else 0
def lat($j) = if $rings > 1 then $lat_min + $j * $lat_step else ($lat_min + $lat_max) / 2
# holes in a ring: as many as fit round the circle of latitude with `web` between them
def ring_r($j) = $ri * cos(lat($j))
def count($j) = floor(360 / (2 * asin($hr / ring_r($j)) + degrees($web / ring_r($j))))
def turn($j) = if $j % 2 == 1 then 180 / count($j) else 0 # alternate rings turned half a step
assert $lat_max >= $lat_min # the rings fit between joint and pole
assert $rings == 1 or $lat_step >= 2 * $alpha + $web_deg # with a bridge between rings
assert ring_r($rings - 1) > $hr + 1
assert count($rings - 1) >= 2
$cut_len = $wall + 6
def prism($k) = if $hole_shape == "hex" then (polygon 6 $hr | extrude $cut_len | translate 0 0 (-$cut_len / 2)) else cylinder $hr $cut_len
$radial = prism(0) | rotate 0 90 0 | translate $rm 0 0 # one cutter through the wall, along +X
def ring_cut($j) = $radial | rotate 0 (-lat($j)) 0 | polar count($j) 0 orient:true | rotate 0 0 turn($j)
$pole_cut = prism(0) | translate 0 0 $rm
def pierce($s, $j) = if $j < 0 then $s else pierce($s - ring_cut($j), $j - 1)
def holes_up($s) = if $pole_hole then pierce($s, $rings - 1) - $pole_cut else pierce($s, $rings - 1)
def flip($s) = $s | mirror "Z"
# --- Upper half: dome, 45 deg shoulder, lip with bead ---------------------------
$shell = (sphere $R) - (sphere $ri)
$dome_up = $shell * (box (2 * $R + 2) (2 * $R + 2) ($R + 1) | floor)
$neck = workplane XZ | sketch [($a, $z_l), ($b, $z_l), ($b, $z_s), ($R, 0), ($rm, $z_q), ($a, $z_t)] | revolve Z
$bead_ring = workplane XZ | sketch [($b - 0.3, $z_c - $bead - 0.3), ($b + $bead, $z_c), ($b - 0.3, $z_c + $bead + 0.3)] | revolve Z
$upper_blank = ($dome_up + $neck) + $bead_ring
$upper = holes_up($upper_blank)
# --- Lower half: dome cut flat at the rim, counterbore with seat and groove ------
$dome_dn = $shell * (box (2 * $R + 2) (2 * $R + 2) ($R + 1) | floor | translate 0 0 ($z_f - $R - 1))
$bore = workplane XZ | sketch [(0, $z_floor), ($b + $clr, $z_floor), ($b + $clr, $z_f - $cham), ($b + $clr + $cham + 0.5, $z_f + 0.5), (0, $z_f + 0.5)] | revolve Z
$groove_ring = workplane XZ | sketch [($b + $clr - 0.3, $z_c - $groove - 0.3), ($b + $clr + $groove, $z_c), ($b + $clr - 0.3, $z_c + $groove + 0.3)] | revolve Z
$lower_blank = ($dome_dn - $bore) - $groove_ring
$lower_up = holes_up(flip($lower_blank)) # pierced with the same pattern, mirrored
$lower = flip($lower_up)
$n_holes = if $pole_hole then 1 else 0
def total($j) = if $j < 0 then $n_holes else count($j) + total($j - 1)
$hole_area = if $hole_shape == "hex" then 2.59 * $hr * $hr else pi * $hr * $hr
assert $upper.solids == 1
assert $lower.solids == 1
assert $upper.valid
assert $lower.valid
assert $upper.volume < $upper_blank.volume - 0.9 * total($rings - 1) * $hole_area * $wall # every hole is through
assert $lower.volume < $lower_blank.volume - 0.9 * total($rings - 1) * $hole_area * $wall
$hr_in = if $hole_shape == "hex" then $hr * cos(30) else $hr
$z_top = if $pole_hole then sqrt($R * $R - $hr_in * $hr_in) else $R # the pole hole takes the very top off
assert $upper.bbox.max[2] ~ $z_top tol:0.02
assert $upper.bbox.min[2] ~ $z_l tol:0.01
assert $lower.bbox.max[2] ~ $z_f tol:0.01
# --- Fit: the halves, checked against each other ------------------------------
assert clear($upper, $lower) # snapped together without interference
assert clear($upper | translate 0 0 1, $lower) == false # the bead holds: no pulling apart without a snap
assert clear($upper | translate 0 0 -0.3, $lower) == false # and the shoulder seats on the rim
assert clear($upper | translate 0.4 0 0, $lower) == false # the lip centres the halves
# --- The bell: free inside, stopped at every hole --------------------------------
def bell_at($lt, $az, $rad) = sphere ($bell_d / 2) | translate ($rad * cos($lt) * cos($az)) ($rad * cos($lt) * sin($az)) ($rad * sin($lt))
$bell = sphere ($bell_d / 2)
assert clear($bell, $upper)
assert clear($bell, $lower)
assert clear(bell_at(lat(0), 180 / count(0), $ri - $bell_d / 2 - 0.1), $upper) # it reaches the wall between two holes: the cavity is hollow
# a bell-sized sphere centred in the wall on the axis of a hole hits the wall there
def stopped($j) = if $j < 0 then true else (clear(bell_at(lat($j), turn($j), $rm), $upper) == false and clear(bell_at(-lat($j), turn($j), $rm), $lower) == false and stopped($j - 1))
assert stopped($rings - 1)
assert clear(bell_at(90, 0, $rm), $upper) == false
assert clear(bell_at(-90, 0, $rm), $lower) == false
# and the pattern is where the probes are: a pin on the axis of the first hole of each ring passes
def pin($lt, $az) = cylinder 1 ($wall + 4) | rotate 0 90 0 | translate $rm 0 0 | rotate 0 (-$lt) 0 | rotate 0 0 $az
def open_at($j) = if $j < 0 then true else (clear(pin(lat($j), turn($j)), $upper) and clear(pin(-lat($j), turn($j)), $lower) and open_at($j - 1))
assert open_at($rings - 1)
# --- Print plate: both halves joint down, side by side ---------------------------
$upper_print = $upper | translate (-$R - 3) 0 (-$z_l)
$lower_print = $lower | rotate 180 0 0 | translate ($R + 3) 0 $z_f
assert clear($upper_print, $lower_print)
$plate = $upper_print + $lower_print
assert $plate.solids == 2
assert $plate.bbox.min[2] ~ 0 tol:0.001
assert $lower_print.bbox.min[2] ~ 0 tol:0.001
$ball = $upper + $lower
assert $ball.solids == 2
print "plate" $plate.bbox "ball" $ball.bbox
print "holes per half" total($rings - 1) "hole (mm)" $hole_d "bell (mm)" $bell_d "cavity (mm)" (2 * $ri)
print "ring latitudes (deg)" [lat($j) for $j in range($rings)] "holes in each" [count($j) for $j in range($rings)]
print "snap overlap, radial (mm)" ($bead - $clr) "opening of the upper half (mm)" (2 * $a)
if $view == "plate" then $plate else $ball