196 lines
9.7 KiB
Plaintext
196 lines
9.7 KiB
Plaintext
"""
|
|
IMU Pointer Enclosure — v11.7 (Slimmed Corners & Rounded USB-C)
|
|
"""
|
|
|
|
import FreeCAD as App
|
|
import FreeCADGui as Gui
|
|
import Part
|
|
from FreeCAD import Base
|
|
|
|
doc = App.newDocument("pointer_v11_7")
|
|
|
|
# ─── DIMENSIONS ───────────────────────────────────────────────────────────────
|
|
L, W, H = 115.0, 36.0, 22.0
|
|
WALL = 3.5
|
|
CR, CR_I = 8.0, 4.5
|
|
TOL = 0.25
|
|
EDGE_FILLET = 3.0
|
|
|
|
USBC_W, USBC_H, USBC_Z = 12.0, 7.0, 5.0
|
|
SPLIT_Z = USBC_Z + USBC_H + 2.5
|
|
|
|
# MICRO-DETENT Snap Logic
|
|
TONGUE_H, TONGUE_T = 2.5, 2.0
|
|
GROOVE_H, GROOVE_T = TONGUE_H + TOL, TONGUE_T + TOL
|
|
RIDGE_W = 12.0
|
|
RIDGE_H = 1.2
|
|
RIDGE_PROUD = 1.0 # Snap ridge protrusion
|
|
RIDGE_Z_OFF = (TONGUE_H - RIDGE_H) / 2.0
|
|
|
|
# ─── IMU BOARD (+1mm Spacing & Slim Corners) ──────────────────────────────────
|
|
PCB_T, BRD_L, BRD_W = 3.0, 22.6, 19.6
|
|
BRD_X, BRD_Y = WALL, (W - BRD_W) / 2.0
|
|
PLATFORM_H, MIC_EXTRA = 1.5, 2.0
|
|
MIC_PCB_T = 2.5 # Thicker PCB section (MEMS mic), rounded up from 2.2
|
|
BUMP_PROUD = 0.3 # Press-fit nub protrusion into board cavity
|
|
BUMP_R = 0.6 # Nub radius (half-sphere)
|
|
BRD_Z = WALL + PLATFORM_H
|
|
|
|
# ─── BUTTON & BATTERY ─────────────────────────────────────────────────────────
|
|
BAT_L, BAT_W, BAT_H = 50.0, 12.0, 12.0
|
|
BAT_X, BAT_Y = BRD_X + BRD_L + 8.0 + 5.0, (W - BAT_W) / 2.0
|
|
BAT_CLIP_Y = 8.0
|
|
BTN_X, BTN_CY, BTN_HOLE_R = 28.0, W / 2.0, 10.0
|
|
CAP_SHAFT_R, CAP_SHAFT_H = 9.6, WALL + 1.0 # +1mm taller shaft so cap sits flush
|
|
CAP_RIM_R, CAP_RIM_H = 12.0, 1.5
|
|
CAP_CAVITY_R, CAP_CAVITY_H = 5.2, 2.5 # Hollow cavity replaces nubbin — clears button dome
|
|
BTN_DOME_R, BTN_DOME_SAG = 14.0, 0.6
|
|
|
|
PCB_BOT_Z = SPLIT_Z + 1.5
|
|
POST_H = BRD_Z + PCB_T + MIC_EXTRA + 3.0 - 4.0 # Lowered 4mm for button PCB + button thickness
|
|
POST_OFFS_X, POST_OFFS_Y = 4.0, 11.0
|
|
LH_R, LH_X, LH_Y_OFFS = 1.5, L - WALL - 3.0, 4.0
|
|
BPCB_L, BPCB_W = 16.0, 16.0
|
|
|
|
# ─── HELPERS ──────────────────────────────────────────────────────────────────
|
|
|
|
def box(lx, ly, lz, ox=0, oy=0, oz=0):
|
|
return Part.makeBox(lx, ly, lz, Base.Vector(ox, oy, oz))
|
|
|
|
def rbox(lx, ly, lz, ox=0, oy=0, oz=0, r=CR):
|
|
b = box(lx, ly, lz, ox, oy, oz)
|
|
try:
|
|
edges = [e for e in b.Edges if abs(e.Vertexes[0].X - e.Vertexes[1].X) < 1e-3 and abs(e.Vertexes[0].Y - e.Vertexes[1].Y) < 1e-3]
|
|
return b.makeFillet(r, edges) if edges else b
|
|
except: return b
|
|
|
|
def cyl(r, h, cx=0, cy=0, cz=0):
|
|
return Part.makeCylinder(r, h, Base.Vector(cx, cy, cz))
|
|
|
|
def fillet_horiz(solid, r, z_test):
|
|
try:
|
|
edges = [e for e in solid.Edges if abs(e.Vertexes[0].Z - e.Vertexes[1].Z) < 0.2 and abs((e.Vertexes[0].Z + e.Vertexes[1].Z)/2 - z_test) < 1.5]
|
|
return solid.makeFillet(r, edges) if edges else solid
|
|
except: return solid
|
|
|
|
def make_slim_corner(cx, cy, ix, iy):
|
|
pw = 0.8 # Much slimmer wall thickness (was 1.5/1.6)
|
|
sl = 4.0 # Slightly shorter side length
|
|
h = PLATFORM_H + PCB_T + 0.5
|
|
|
|
x0, y0 = (cx if ix>0 else cx-sl), (cy if iy>0 else cy-pw)
|
|
w1 = box(sl, pw, h, x0, y0, WALL)
|
|
|
|
x1, y1 = (cx if ix>0 else cx-pw), (cy if iy>0 else cy-sl)
|
|
w2 = box(pw, sl, h, x1, y1, WALL)
|
|
|
|
px, py = (cx if ix>0 else cx-sl), (cy if iy>0 else cy-sl)
|
|
plat = box(sl, sl, PLATFORM_H, px, py, WALL)
|
|
|
|
return plat.fuse(w1).fuse(w2)
|
|
|
|
# ═════════════════════════════════════════════════════════════════════════════
|
|
# CONSTRUCTION
|
|
# ═════════════════════════════════════════════════════════════════════════════
|
|
|
|
# BOTTOM SHELL
|
|
bot_shell = fillet_horiz(rbox(L, W, SPLIT_Z + TONGUE_H), EDGE_FILLET, 0.0)
|
|
bot_shell = bot_shell.cut(rbox(L-WALL*2, W-WALL*2, SPLIT_Z, WALL, WALL, WALL, r=CR_I))
|
|
bot_shell = bot_shell.cut(rbox(L-TONGUE_T*2, W-TONGUE_T*2, TONGUE_H+2, TONGUE_T, TONGUE_T, SPLIT_Z, r=CR-TONGUE_T))
|
|
|
|
# Internal Fusions (Using Slim L-bracket style for MCU)
|
|
for cx, cy, ix, iy in [(BRD_X, BRD_Y, 1, 1), (BRD_X+BRD_L, BRD_Y, -1, 1), (BRD_X, BRD_Y+BRD_W, 1, -1), (BRD_X+BRD_L, BRD_Y+BRD_W, -1, -1)]:
|
|
bot_shell = bot_shell.fuse(make_slim_corner(cx, cy, ix, iy))
|
|
|
|
# Press-fit nubs — half-sphere on each L-bracket's inner Y-facing wall (w1)
|
|
bump_z = BRD_Z + 1.0 + BUMP_R # Bottom of nub sits 1mm above platform
|
|
pw = 0.8; sl = 4.0 # Must match make_slim_corner
|
|
for cx, cy, ix, iy in [(BRD_X, BRD_Y, 1, 1), (BRD_X+BRD_L, BRD_Y, -1, 1),
|
|
(BRD_X, BRD_Y+BRD_W, 1, -1), (BRD_X+BRD_L, BRD_Y+BRD_W, -1, -1)]:
|
|
# w1 wall centre X: midpoint of the sl-long wall extending from corner
|
|
mid_x = cx + ix * sl / 2.0
|
|
# w1 inner face Y: the face that looks toward the board centre
|
|
face_y = cy if iy > 0 else cy - pw # wall origin Y
|
|
inner_y = face_y + pw if iy > 0 else face_y # the side facing inward
|
|
# iy>0 → bump faces +Y (inward), iy<0 → bump faces -Y (inward)
|
|
# Actually: iy>0 means corner is at low-Y side, wall inner face = face_y+pw, bump goes +Y
|
|
# iy<0 means corner is at high-Y side, wall inner face = face_y, bump goes -Y
|
|
sph = Part.makeSphere(BUMP_R, Base.Vector(mid_x, inner_y, bump_z))
|
|
cs = BUMP_R + 0.5
|
|
# Clip: keep only the half protruding inward (toward board centre)
|
|
if iy > 0:
|
|
clip = box(cs*2, cs, cs*2, mid_x - cs, inner_y, bump_z - cs)
|
|
else:
|
|
clip = box(cs*2, cs, cs*2, mid_x - cs, inner_y - cs, bump_z - cs)
|
|
half_sph = sph.common(clip)
|
|
bot_shell = bot_shell.fuse(half_sph)
|
|
|
|
POST_R = 1.75
|
|
POST_TAPER_EXTRA = 0.3 # Extra radius at base
|
|
POST_TAPER_H = 6.0 # Height over which the taper blends to nominal radius
|
|
BACK_POST_SHIFT = POST_R # Shift back posts by half a post diameter
|
|
for ox in [-POST_OFFS_X, POST_OFFS_X]:
|
|
for oy in [-POST_OFFS_Y, POST_OFFS_Y]:
|
|
px = BTN_X + ox + (BACK_POST_SHIFT if ox > 0 else 0)
|
|
py = BTN_CY + oy
|
|
post = cyl(POST_R, POST_H, px, py, WALL)
|
|
# Tapered cone base: wider at bottom, blends to post radius at POST_TAPER_H
|
|
taper = Part.makeCone(POST_R + POST_TAPER_EXTRA, POST_R, POST_TAPER_H,
|
|
Base.Vector(px, py, WALL))
|
|
post = post.fuse(taper)
|
|
post = post.cut(cyl(0.5, POST_H + 1, px, py, WALL))
|
|
bot_shell = bot_shell.fuse(post)
|
|
|
|
# Rounded USB-C Cut (Pill Shape)
|
|
usbc_r = USBC_H / 2.0
|
|
usbc_box = box(WALL*4, USBC_W - 2*usbc_r, USBC_H, -1, W/2 - USBC_W/2 + usbc_r, USBC_Z)
|
|
usbc_cyl1 = Part.makeCylinder(usbc_r, WALL*4, Base.Vector(-1, W/2 - USBC_W/2 + usbc_r, USBC_Z + usbc_r), Base.Vector(1, 0, 0))
|
|
usbc_cyl2 = Part.makeCylinder(usbc_r, WALL*4, Base.Vector(-1, W/2 + USBC_W/2 - usbc_r, USBC_Z + usbc_r), Base.Vector(1, 0, 0))
|
|
usbc_rounded = usbc_box.fuse(usbc_cyl1).fuse(usbc_cyl2)
|
|
bot_shell = bot_shell.cut(usbc_rounded)
|
|
|
|
# Battery bay + retaining tabs
|
|
bot_shell = bot_shell.cut(box(BAT_L, BAT_W, 3.0, BAT_X, BAT_Y, WALL))
|
|
bat_clip_cy = BAT_Y + BAT_W / 2.0 - BAT_CLIP_Y / 2.0
|
|
bot_shell = bot_shell.fuse(box(2.0, BAT_CLIP_Y, BAT_H * 0.55, BAT_X - 2.0, bat_clip_cy, WALL))
|
|
bot_shell = bot_shell.fuse(box(2.0, BAT_CLIP_Y, BAT_H * 0.55, BAT_X + BAT_L, bat_clip_cy, WALL))
|
|
|
|
# MICRO-DETENT RIDGES: Buried deep, barely protruding
|
|
rx0, rz0 = L/2 - RIDGE_W/2, SPLIT_Z + RIDGE_Z_OFF
|
|
ridge_bury = 1.5
|
|
ridge_total_t = ridge_bury + RIDGE_PROUD
|
|
bot_shell = bot_shell.fuse(box(RIDGE_W, ridge_total_t, RIDGE_H, rx0, TONGUE_T - ridge_bury, rz0))
|
|
bot_shell = bot_shell.fuse(box(RIDGE_W, ridge_total_t, RIDGE_H, rx0, W - TONGUE_T - RIDGE_PROUD, rz0))
|
|
|
|
# TOP SHELL
|
|
top_shell = fillet_horiz(rbox(L, W, H-SPLIT_Z, 0, 0, SPLIT_Z), EDGE_FILLET, H)
|
|
top_shell = top_shell.cut(rbox(L-WALL*2, W-WALL*2, H-SPLIT_Z-WALL, WALL, WALL, SPLIT_Z, r=CR_I))
|
|
|
|
# Groove and Matching Recesses
|
|
g_band = rbox(L, W, GROOVE_H, 0, 0, SPLIT_Z, r=CR).cut(rbox(L-GROOVE_T*2, W-GROOVE_T*2, GROOVE_H+2, GROOVE_T, GROOVE_T, SPLIT_Z-1, r=CR-GROOVE_T))
|
|
top_shell = top_shell.cut(g_band)
|
|
|
|
# Recesses in groove wall — bottom ridges click into these
|
|
rec_w = RIDGE_W + TOL*2
|
|
rec_d = RIDGE_PROUD + TOL # Slightly deeper than ridge protrusion
|
|
top_shell = top_shell.cut(box(rec_w, rec_d, RIDGE_H+TOL, L/2-rec_w/2, GROOVE_T, rz0-TOL/2))
|
|
top_shell = top_shell.cut(box(rec_w, rec_d, RIDGE_H+TOL, L/2-rec_w/2, W-GROOVE_T-rec_d, rz0-TOL/2))
|
|
|
|
# Button & Cap
|
|
top_shell = top_shell.cut(cyl(BTN_HOLE_R, H, BTN_X, BTN_CY, SPLIT_Z))
|
|
top_shell = top_shell.cut(Part.makeSphere(BTN_DOME_R, Base.Vector(BTN_X, BTN_CY, H - WALL - BTN_DOME_R + BTN_DOME_SAG)))
|
|
cap = cyl(CAP_SHAFT_R, CAP_SHAFT_H).fuse(cyl(CAP_RIM_R, CAP_RIM_H, 0, 0, -CAP_RIM_H))
|
|
# Hollow cavity in bottom of shaft — button dome nests inside instead of a protruding nubbin
|
|
cap = cap.cut(cyl(CAP_CAVITY_R, CAP_CAVITY_H, 0, 0, -CAP_RIM_H))
|
|
cap_placed = cap.copy(); cap_placed.translate(Base.Vector(BTN_X, BTN_CY, H - CAP_SHAFT_H))
|
|
|
|
# ─── REGISTER ────────────────────────────────────────────────────────────────
|
|
for name, shape, color in [("Shell_Bottom", bot_shell, (0.15, 0.15, 0.18)),
|
|
("Shell_Top", top_shell, (0.25, 0.25, 0.32)),
|
|
("Button_Cap", cap_placed, (0.7, 0.7, 0.7))]:
|
|
obj = doc.addObject("Part::Feature", name)
|
|
obj.Shape = shape
|
|
obj.ViewObject.ShapeColor = color
|
|
|
|
doc.recompute()
|
|
Gui.SendMsgToActiveView("ViewFit") |