Update 3D model

This commit is contained in:
2026-03-19 21:47:42 +01:00
parent 5f928d7c92
commit 87fc2a3574
+379 -239
View File
@@ -1,290 +1,430 @@
# IMU Pointer Enclosure """
IMU Pointer Enclosure — v6
============================
Fixes from v5 (diagnosed from rendered images):
1. BOTTOM HOLE:
v5 built the bottom shell from a full-height box (0→H) then trimmed
at SPLIT_Z. The taper wedge interacted badly with the split cut near
X=0 leaving a hole in the floor. Fix: build bottom outer solid only
to SPLIT_Z height — no trimming step needed, no interaction.
2. TOP SHELL WALLS PROTRUDING BELOW SPLIT:
v5 top_outer started at SPLIT_Z but the cavity inside started at
SPLIT_Z + WALL, leaving WALL=3.5mm of solid wall below the groove —
visually protruding past the bottom shell. Fix: the top shell outer
solid starts at SPLIT_Z. The groove is cut starting exactly at SPLIT_Z
so there is zero protrusion below the split line.
3. BUTTON CAP NOT FLUSH / SITTING PROUD:
Aperture cylinder had arithmetic-derived Z that could miss the top wall
faces after filleting. Fix: aperture runs from Z=SPLIT_Z (well inside
the cavity) all the way to Z=H+2 — brute-force punch, impossible to miss.
4. CAP RIM SITS UNDER OUTER FACE (not above it):
Cap is placed so shaft top = H (flush). Rim hangs BELOW the top face
inside the cavity — correct retention geometry. The cap shaft top is
exactly flush with H. No part of the cap protrudes above H.
Split joint design:
- Bottom shell has a TONGUE that projects UP from SPLIT_Z.
The tongue is a thin rectangular frame (inner perimeter of the walls).
- Top shell has a matching GROOVE cut into the inside of its lower edge,
starting exactly at SPLIT_Z (the bottom face of the top shell).
- Two flex notches cut through the tongue on the long sides allow snap fit.
"""
import FreeCAD as App import FreeCAD as App
import FreeCADGui as Gui import FreeCADGui as Gui
import Part import Part
import math
from FreeCAD import Base from FreeCAD import Base
doc = App.newDocument("pointer") doc = App.newDocument("pointer_v7")
# Global dimensions # ─────────────────────────────────────────────────────────────────────────────
L = 115.0 # DIMENSIONS
W = 36.0 # ─────────────────────────────────────────────────────────────────────────────
H = 20.0 L = 115.0 # length (X): front=0, back=L
WALL = 3.5 W = 36.0 # width (Y)
CR = 3.0 H = 22.0 # height (Z): bottom=0, top=H
TOL = 0.25 WALL = 4.5 # wall thickness (+1 mm vs v6 — closes taper floor gap)
CR = 5.0 # corner fillet radius (vertical edges)
TOL = 0.25 # fit tolerance
# Rail and lid # Taper: front of bottom shell is TAPER_RISE mm shorter than back.
RAIL_H = 4.5 # Applied only to the BOTTOM shell (it's where the ergonomic taper lives).
RAIL_D = 2.0 TAPER_RISE = 0.0 # no taper — removed per user request
LIP_H = 2.0 TAPER_LEN = 100.0 # unused but kept to avoid NameError
LIP_OVER = 1.5
LIP_EMBED = 0.2
LID_H = RAIL_H - LIP_H - TOL - 0.55 # Split plane
USBC_W = 11.0
USBC_H = 7.0
USBC_Z = 5.0
SPLIT_Z = USBC_Z + USBC_H + 2.5 # = 14.5 mm
# Board dimensions # Tongue/groove clip joint
PCB_T = 1.0 TONGUE_H = 2.5 # how far tongue projects above SPLIT_Z
BRD_L = 21.0 TONGUE_T = 1.2 # tongue wall thickness
BRD_W = 17.5 GROOVE_H = TONGUE_H + TOL
BRD_X = WALL GROOVE_T = TONGUE_T + TOL
BRD_Y = (W - BRD_W) / 2
# Flex notch through tongue (for snap release)
NOTCH_W = 8.0
NOTCH_H = TONGUE_H + 0.5
# ─────────────────────────────────────────────────────────────────────────────
# IMU BOARD
# ─────────────────────────────────────────────────────────────────────────────
PCB_T = 1.0
BRD_L = 21.0
BRD_W = 17.5
BRD_X = WALL
BRD_Y = (W - BRD_W) / 2.0
PLATFORM_H = 0.5 PLATFORM_H = 0.5
BRD_Z = WALL + PLATFORM_H BRD_Z = WALL + PLATFORM_H
ARM_LEN = 5.0
ARM_THICK = 1.6
ARM_H = BRD_Z + PCB_T + 0.8
CLIP_TOL = 0.35
# Clip arms # ─────────────────────────────────────────────────────────────────────────────
ARM_LEN = 5.0 # BATTERY BAY
ARM_THICK = 1.6 # ─────────────────────────────────────────────────────────────────────────────
ARM_H = BRD_Z + PCB_T + 0.8 BAT_L = 50.0
CLIP_TOL = 0.35 BAT_W = 12.0
BAT_H = 12.0
BAT_X = BRD_X + BRD_L + 8.0
BAT_Y = (W - BAT_W) / 2.0
BAT_CLIP_Y = 8.0
# USB-C cutout # ─────────────────────────────────────────────────────────────────────────────
USBC_W = 11.0 # BUTTON
USBC_H = 7.0 # ─────────────────────────────────────────────────────────────────────────────
USBC_Z = 4.5 BTN_X = 28.0
BTN_CY = W / 2.0
BTN_HOLE_R = 8.0
CAP_SHAFT_R = BTN_HOLE_R - 0.4 # 0.4 mm radial clearance in hole
CAP_SHAFT_H = WALL # shaft fills top wall → top face flush
CAP_RIM_R = BTN_HOLE_R + 2.0 # 2 mm wider than hole → retention
CAP_RIM_H = 1.5
NUBBIN_R = 1.8
NUBBIN_H = 2.0
# Battery section # Switch geometry (adjust to match your Omron)
BAT_L = 50.0 SWITCH_BODY_H = 5.0
BAT_W = 12.0 STEM_H = 2.5
BAT_H = 12.0 GAP = 0.5
BAT_X = BRD_X + BRD_L + 8.0
BAT_Y = (W - BAT_W) / 2
BAT_CLIP_Y = 8.0
# Circular notch # PCB position derived top-down
NOTCH_R = (USBC_W + TOL) / 2 PCB_TOP_Z = H - WALL - CAP_RIM_H - NUBBIN_H - GAP - SWITCH_BODY_H - STEM_H
NOTCH_DEPTH = WALL + 2.0 PCB_BOT_Z = PCB_TOP_Z - PCB_T
# Clamp: must be inside the top shell cavity
floor_top_shell = SPLIT_Z + WALL
if PCB_BOT_Z < floor_top_shell + 0.5:
PCB_BOT_Z = floor_top_shell + 0.5
PCB_TOP_Z = PCB_BOT_Z + PCB_T
POST_H = PCB_BOT_Z - floor_top_shell
POST_OD = 4.0; POST_R = POST_OD / 2.0
POST_ID = 1.9; POST_IR = POST_ID / 2.0
POST_SEP = 3.0
# Circular notch helper BPCB_L = 16.0
def circular_notch(face_x, cy, cz, r, depth): BPCB_W = 16.0
circle = Part.makeCircle(r, Base.Vector(face_x, cy, cz), Base.Vector(1, 0, 0)) SHELF_WALL = 2.0
face = Part.Face(Part.Wire(circle))
return face.extrude(Base.Vector(-depth, 0, 0))
# ─────────────────────────────────────────────────────────────────────────────
# HELPERS
# ─────────────────────────────────────────────────────────────────────────────
# Rounded box helper def box(lx, ly, lz, ox=0.0, oy=0.0, oz=0.0):
def rbox(lx, ly, lz, ox=0, oy=0, oz=0, r=CR):
b = Part.makeBox(lx, ly, lz, Base.Vector(ox, oy, oz))
try:
vert = [e for e in b.Edges
if abs(e.Vertexes[0].Z - e.Vertexes[1].Z) > lz * 0.9]
if vert:
b = b.makeFillet(r, vert)
except Exception:
pass
return b
# Simple box helper
def box(lx, ly, lz, ox=0, oy=0, oz=0):
return Part.makeBox(lx, ly, lz, Base.Vector(ox, oy, oz)) return Part.makeBox(lx, ly, lz, Base.Vector(ox, oy, oz))
def cyl(r, h, cx=0.0, cy=0.0, cz=0.0):
return Part.makeCylinder(r, h, Base.Vector(cx, cy, cz))
# Rounded slot helper def rounded_slot(depth, sw, sh, ox, oy, oz):
def rounded_slot(depth, w, h, ox, oy, oz, r=None): """Stadium slot extruded in +X."""
if r is None: r = min(sh / 2.0, sw / 2.0)
r = h / 2.0 cy = oy + sw / 2.0
cz = oz + sh / 2.0
hw = max(sw / 2.0 - r, 0.0)
if hw < 1e-6:
circ = Part.makeCircle(r, Base.Vector(ox, cy, cz), Base.Vector(1, 0, 0))
return Part.Face(Part.Wire(circ)).extrude(Base.Vector(depth, 0, 0))
l_s = Base.Vector(ox, cy - hw, cz - r)
l_m = Base.Vector(ox, cy - hw - r, cz)
l_e = Base.Vector(ox, cy - hw, cz + r)
r_s = Base.Vector(ox, cy + hw, cz + r)
r_m = Base.Vector(ox, cy + hw + r, cz)
r_e = Base.Vector(ox, cy + hw, cz - r)
wire = Part.Wire([Part.Arc(l_s, l_m, l_e).toShape(),
Part.makeLine(l_e, r_s),
Part.Arc(r_s, r_m, r_e).toShape(),
Part.makeLine(r_e, l_s)])
return Part.Face(wire).extrude(Base.Vector(depth, 0, 0))
r = min(r, h / 2.0, w / 2.0) def fillet_vert(solid, r, min_len=4.0):
"""Fillet edges that are primarily vertical (parallel to Z)."""
import math try:
edges = [e for e in solid.Edges
cy = oy + w / 2.0 if len(e.Vertexes) == 2
cz = oz + h / 2.0 and abs(e.Vertexes[0].X - e.Vertexes[1].X) < 1e-3
hw = w / 2.0 - r and abs(e.Vertexes[0].Y - e.Vertexes[1].Y) < 1e-3
and e.Length >= min_len]
def pt(cx, cy_v, cz_v, angle_deg, radius): if edges:
a = math.radians(angle_deg) return solid.makeFillet(r, edges)
return Base.Vector( except Exception as e:
cx, print(f" fillet_vert skipped: {e}")
cy_v + radius * math.cos(a), return solid
cz_v + radius * math.sin(a)
)
l_start = pt(ox, cy - hw, cz, 270, r)
l_mid = pt(ox, cy - hw, cz, 180, r)
l_end = pt(ox, cy - hw, cz, 90, r)
arc_left = Part.Arc(l_start, l_mid, l_end).toShape()
line_top = Part.makeLine(
l_end,
pt(ox, cy + hw, cz, 90, r)
)
r_start = pt(ox, cy + hw, cz, 90, r)
r_mid = pt(ox, cy + hw, cz, 0, r)
r_end = pt(ox, cy + hw, cz, 270, r)
arc_right = Part.Arc(r_start, r_mid, r_end).toShape()
line_bot = Part.makeLine(r_end, l_start)
wire = Part.Wire([arc_left, line_top, arc_right, line_bot])
face = Part.Face(wire)
return face.extrude(Base.Vector(depth, 0, 0))
# Board clip helper
def make_clip(corner_x, corner_y, inward_x, inward_y):
def make_clip(cx, cy, ix, iy):
plat_w = ARM_THICK + CLIP_TOL plat_w = ARM_THICK + CLIP_TOL
plat_x = cx if ix > 0 else cx - plat_w
plat_y = cy if iy > 0 else cy - plat_w
plat = box(plat_w, plat_w, PLATFORM_H + PCB_T, plat_x, plat_y, WALL)
ax_ox = cx if ix > 0 else cx - ARM_LEN
ax_oy = cy - ARM_THICK - CLIP_TOL if iy > 0 else cy + CLIP_TOL
arm_x = box(ARM_LEN, ARM_THICK, ARM_H, ax_ox, ax_oy, WALL)
ay_oy = cy if iy > 0 else cy - ARM_LEN
ay_ox = cx - ARM_THICK - CLIP_TOL if ix > 0 else cx + CLIP_TOL
arm_y = box(ARM_THICK, ARM_LEN, ARM_H, ay_ox, ay_oy, WALL)
cb_w = ARM_THICK + CLIP_TOL
cb_ox = cx - cb_w if ix > 0 else cx
cb_oy = cy - cb_w if iy > 0 else cy
cb = box(cb_w, cb_w, ARM_H, cb_ox, cb_oy, WALL)
return plat.fuse(arm_x.fuse(arm_y).fuse(cb))
plat_x = corner_x if inward_x > 0 else corner_x - plat_w # ═════════════════════════════════════════════════════════════════════════════
plat_y = corner_y if inward_y > 0 else corner_y - plat_w # BOTTOM SHELL (Z = 0 → SPLIT_Z, open on top)
# ═════════════════════════════════════════════════════════════════════════════
platform = box( # 1. Outer solid — built ONLY to SPLIT_Z height
plat_w, plat_w, bot_outer = box(L, W, SPLIT_Z)
PLATFORM_H + PCB_T, bot_outer = fillet_vert(bot_outer, CR, min_len=SPLIT_Z * 0.4)
plat_x, plat_y, WALL
)
ax_ox = corner_x if inward_x > 0 else corner_x - ARM_LEN # Fillet the long horizontal edges the user holds.
ax_oy = corner_y - ARM_THICK - CLIP_TOL if inward_y > 0 else corner_y + CLIP_TOL # These are the 4 edges running in X at Z≈0 and Z≈SPLIT_Z, on both long sides.
arm_x = box(ARM_LEN, ARM_THICK, ARM_H, ax_ox, ax_oy, WALL) # Same fillet applied to equivalent edges on the top shell later.
EDGE_FILLET = 2.5 # mm — soft and comfortable, visible but not decorative
try:
h_edges = []
for e in bot_outer.Edges:
if len(e.Vertexes) != 2:
continue
v0, v1 = e.Vertexes[0], e.Vertexes[1]
dx = abs(v0.X - v1.X)
dz = abs(v0.Z - v1.Z)
dy = abs(v0.Y - v1.Y)
# Long edge in X, horizontal, on a long side face —
# but ONLY at Z≈0 (bottom face). Exclude Z≈SPLIT_Z (the join edge).
z_mid = (v0.Z + v1.Z) / 2.0
if dx > L * 0.5 and dz < 0.5 and dy < 0.5 and z_mid < 1.0:
h_edges.append(e)
if h_edges:
bot_outer = bot_outer.makeFillet(EDGE_FILLET, h_edges)
print(f"Bottom shell: filleted {len(h_edges)} horizontal edge(s) R={EDGE_FILLET}")
else:
print("Bottom shell: no horizontal edges found — skipped")
except Exception as exc:
print(f"Bottom shell horizontal fillet skipped: {exc}")
ay_oy = corner_y if inward_y > 0 else corner_y - ARM_LEN # No taper wedge — removed per user request
ay_ox = corner_x - ARM_THICK - CLIP_TOL if inward_x > 0 else corner_x + CLIP_TOL
arm_y = box(ARM_THICK, ARM_LEN, ARM_H, ay_ox, ay_oy, WALL)
corner_block_w = ARM_THICK + CLIP_TOL # 3. Inner cavity — floor at WALL, ceiling at SPLIT_Z (open top, no ceiling)
cb_ox = corner_x - corner_block_w if inward_x > 0 else corner_x bot_cav_lx = L - WALL * 2
cb_oy = corner_y - corner_block_w if inward_y > 0 else corner_y bot_cav_ly = W - WALL * 2
bot_cav_lz = SPLIT_Z - WALL # floor(WALL) → SPLIT_Z
bot_inner = box(bot_cav_lx, bot_cav_ly, bot_cav_lz, WALL, WALL, WALL)
bot_shell = bot_outer.cut(bot_inner)
corner_block = box( # 4. Tongue (projects UP from SPLIT_Z, inner perimeter frame)
corner_block_w, corner_block_w, ARM_H, # Outer edge of tongue = inner face of outer wall = WALL from outside
cb_ox, cb_oy, WALL # Inner edge of tongue = WALL + TONGUE_T from outside
) t_slab = box(bot_cav_lx, bot_cav_ly, TONGUE_H,
WALL, WALL, SPLIT_Z)
t_cut = box(bot_cav_lx - TONGUE_T*2, bot_cav_ly - TONGUE_T*2, TONGUE_H + 1,
WALL + TONGUE_T, WALL + TONGUE_T, SPLIT_Z - 0.5)
tongue = t_slab.cut(t_cut)
return platform.fuse(arm_x.fuse(arm_y).fuse(corner_block)) # Flex notches on the two long sides (parallel to X)
nx0 = L / 2.0 - NOTCH_W / 2.0
for ny_start in [WALL, W - WALL - TONGUE_T]:
tongue = tongue.cut(
box(NOTCH_W, TONGUE_T + 0.5, NOTCH_H,
nx0, ny_start - 0.1, SPLIT_Z - 0.1))
bot_shell = bot_shell.fuse(tongue)
# 5. IMU clips
# Base outer body for cx, cy, ix, iy in [
base = rbox(L, W, H) (BRD_X, BRD_Y, +1, +1),
(BRD_X + BRD_L, BRD_Y, -1, +1),
# Inner cavity (BRD_X, BRD_Y + BRD_W, +1, -1),
base = base.cut(
box(L - WALL * 2, W - WALL * 2, H - WALL,
WALL, WALL, WALL)
)
rail_z = H - RAIL_H
groove_h = RAIL_H - LIP_H
# Rail grooves
base = base.cut(
box(L - WALL * 2, RAIL_D, groove_h,
WALL, WALL - RAIL_D, rail_z)
)
base = base.cut(
box(L - WALL * 2, RAIL_D, groove_h,
WALL, W - WALL, rail_z)
)
# Lid lips
lip_z = H - LIP_H
base = base.fuse(
box(L - WALL * 2, LIP_OVER, LIP_H,
WALL, WALL, lip_z)
)
base = base.fuse(
box(L - WALL * 2, LIP_OVER, LIP_H,
WALL, W - WALL - LIP_OVER, lip_z)
)
# Back slot
slot_y0 = WALL - RAIL_D
slot_yw = W - WALL * 2 + RAIL_D * 2
base = base.cut(
box(WALL + 1.0, slot_yw, RAIL_H,
L - WALL, slot_y0, rail_z)
)
# Entry bump
BUMP_H = 0.5
pad_raw = box(WALL, slot_yw, BUMP_H,
L - WALL, slot_y0, rail_z)
pad_trimmed = pad_raw.common(rbox(L, W, H))
base = base.fuse(pad_trimmed)
# Board clips
clip_corners = [
(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), (BRD_X + BRD_L, BRD_Y + BRD_W, -1, -1),
] ]:
bot_shell = bot_shell.fuse(make_clip(cx, cy, ix, iy))
for cx, cy, ix, iy in clip_corners: # 6. USB-C slot — starts at X = -WALL*3 so it punches through the rounded
base = base.fuse(make_clip(cx, cy, ix, iy)) # front face cleanly regardless of fillet radius
bot_shell = bot_shell.cut(
rounded_slot(WALL * 6, USBC_W, USBC_H,
-WALL * 3,
W / 2.0 - USBC_W / 2.0,
USBC_Z))
# USB-C opening # 7. Battery bay
base = base.cut( bot_shell = bot_shell.cut(box(BAT_L, BAT_W, 3.0, BAT_X, BAT_Y, WALL))
rounded_slot( cy0 = BAT_Y + BAT_W / 2.0 - BAT_CLIP_Y / 2.0
WALL * 3, bot_shell = bot_shell.fuse(box(2.0, BAT_CLIP_Y, BAT_H * 0.55, BAT_X - 2.0, cy0, WALL))
USBC_W, bot_shell = bot_shell.fuse(box(2.0, BAT_CLIP_Y, BAT_H * 0.55, BAT_X + BAT_L, cy0, WALL))
USBC_H,
-WALL,
W / 2 - USBC_W / 2,
USBC_Z
)
)
# Battery recess # ═════════════════════════════════════════════════════════════════════════════
base = base.cut( # TOP SHELL (Z = SPLIT_Z → H, open on bottom, closed ceiling at H)
box(BAT_L, BAT_W, 3.0, # ═════════════════════════════════════════════════════════════════════════════
BAT_X, BAT_Y, WALL) top_h = H - SPLIT_Z # = 7.5 mm
)
clip_y_start = BAT_Y + BAT_W / 2 - BAT_CLIP_Y / 2 # 1. Outer solid spans SPLIT_Z → H
top_outer = box(L, W, top_h, 0, 0, SPLIT_Z)
top_outer = fillet_vert(top_outer, CR, min_len=top_h * 0.4)
base = base.fuse( # Fillet the long horizontal edges of the top shell —
box(2.0, BAT_CLIP_Y, BAT_H * 0.55, # the top edges (Z≈H) are the ones selected in blue in the user's screenshot.
BAT_X - 2.0, clip_y_start, WALL) try:
) th_edges = []
for e in top_outer.Edges:
if len(e.Vertexes) != 2:
continue
v0, v1 = e.Vertexes[0], e.Vertexes[1]
dx = abs(v0.X - v1.X)
dz = abs(v0.Z - v1.Z)
dy = abs(v0.Y - v1.Y)
# Long edge in X, horizontal, on a long side face —
# ONLY at Z≈H (top face). Exclude Z≈SPLIT_Z (the join edge).
z_mid = (v0.Z + v1.Z) / 2.0
if dx > L * 0.5 and dz < 0.5 and dy < 0.5 and z_mid > H - 1.0:
th_edges.append(e)
if th_edges:
top_outer = top_outer.makeFillet(EDGE_FILLET, th_edges)
print(f"Top shell: filleted {len(th_edges)} horizontal edge(s) R={EDGE_FILLET}")
else:
print("Top shell: no horizontal edges found — skipped")
except Exception as exc:
print(f"Top shell horizontal fillet skipped: {exc}")
base = base.fuse( # 2. Inner cavity: side walls WALL thick, CEILING at H-WALL (WALL-thick roof),
box(2.0, BAT_CLIP_Y, BAT_H * 0.55, # FLOOR open (starts at SPLIT_Z — nothing blocks the bottom opening).
BAT_X + BAT_L, clip_y_start, WALL) # Cavity box: X from WALL→L-WALL, Y from WALL→W-WALL, Z from SPLIT_Z→H-WALL
) top_cav_lx = L - WALL * 2
top_cav_ly = W - WALL * 2
top_cav_lz = top_h - WALL # = 7.5 - 3.5 = 4.0 mm interior height
top_inner = box(top_cav_lx, top_cav_ly, top_cav_lz,
WALL, WALL, SPLIT_Z) # starts exactly at SPLIT_Z
top_shell = top_outer.cut(top_inner)
# Circular notch in back wall - centred on base # 3. Groove at the bottom of the top shell, starting at SPLIT_Z
notch_cz = rail_z + LID_H # The groove is a frame-shaped recess cut into the inner face of the walls.
base = base.cut(circular_notch(L, W / 2, notch_cz, NOTCH_R, NOTCH_DEPTH)) # It goes from Z=SPLIT_Z up to Z=SPLIT_Z+GROOVE_H.
# Width = GROOVE_T (slightly wider than tongue).
g_slab = box(top_cav_lx, top_cav_ly, GROOVE_H,
WALL, WALL, SPLIT_Z)
g_cut = box(top_cav_lx - GROOVE_T*2, top_cav_ly - GROOVE_T*2, GROOVE_H + 1,
WALL + GROOVE_T, WALL + GROOVE_T, SPLIT_Z - 0.5)
groove = g_slab.cut(g_cut)
top_shell = top_shell.cut(groove)
# Lid # 4. Button aperture — brute-force: run cylinder from Z=SPLIT_Z to Z=H+2.
TAB_W = RAIL_D - TOL + 0.5 # It will punch through the ceiling regardless of any topology.
LID_L = L - WALL * 2 - TOL top_shell = top_shell.cut(
LID_EXTRA_TOL = 0.5 cyl(BTN_HOLE_R, H - SPLIT_Z + 2, BTN_X, BTN_CY, SPLIT_Z))
LID_W = ( # 5. Button PCB shelf frame
W - WALL * 2 shelf_ox = BTN_X - BPCB_L / 2.0
- (TOL + LID_EXTRA_TOL) * 2 shelf_oy = BTN_CY - BPCB_W / 2.0
+ TAB_W * 2 shelf_h = 1.5
) shelf_slab = box(BPCB_L + SHELF_WALL*2, BPCB_W + SHELF_WALL*2, shelf_h,
shelf_ox - SHELF_WALL, shelf_oy - SHELF_WALL,
PCB_BOT_Z - shelf_h)
shelf_hole = box(BPCB_L, BPCB_W, shelf_h + 2.0,
shelf_ox, shelf_oy, PCB_BOT_Z - shelf_h - 1.0)
shelf = shelf_slab.cut(shelf_hole)
if floor_top_shell < PCB_BOT_Z < H - WALL:
top_shell = top_shell.fuse(shelf)
lid_y0 = WALL + TOL + LID_EXTRA_TOL - TAB_W # 6. Screw posts on top-shell floor
lid = box(LID_L, LID_W, LID_H, 0, lid_y0, 0) if POST_H > 0.5:
for py in [BTN_CY - POST_SEP/2.0, BTN_CY + POST_SEP/2.0]:
p = cyl(POST_R, POST_H, BTN_X, py, floor_top_shell)
ph = cyl(POST_IR, POST_H + 1.0, BTN_X, py, floor_top_shell)
top_shell = top_shell.fuse(p)
top_shell = top_shell.cut(ph)
lid.translate(Base.Vector(WALL + TOL, 0, rail_z)) # ═════════════════════════════════════════════════════════════════════════════
# BUTTON CAP (separate printed part)
#
# Geometry at origin:
# Shaft: Z = 0 (bottom/inner) → Z = CAP_SHAFT_H = WALL (top/flush)
# Rim: Z = -CAP_RIM_H → Z = 0 (hangs inside cavity)
# Nubbin: Z = -CAP_RIM_H-NUBBIN_H → Z = -CAP_RIM_H
#
# Placed so shaft top = H → flush with top face.
# Rim is entirely inside the cavity. No part protrudes above H.
# ═════════════════════════════════════════════════════════════════════════════
cap_shaft = cyl(CAP_SHAFT_R, CAP_SHAFT_H)
cap_rim = cyl(CAP_RIM_R, CAP_RIM_H, 0, 0, -CAP_RIM_H)
cap_nub = cyl(NUBBIN_R, NUBBIN_H, 0, 0, -CAP_RIM_H - NUBBIN_H)
cap_raw = cap_shaft.fuse(cap_rim).fuse(cap_nub)
# No fillet on cap top rim — cap sits flush inside aperture so a fillet
# would create a visible chamfer ring against the hole edge.
cap_placed = cap_raw.copy()
cap_placed.translate(Base.Vector(BTN_X, BTN_CY, H - CAP_SHAFT_H))
# Final objects # ═════════════════════════════════════════════════════════════════════════════
base_obj = doc.addObject("Part::Feature", "Pointer_Base") # REGISTER OBJECTS
base_obj.Shape = base # ═════════════════════════════════════════════════════════════════════════════
base_obj.ViewObject.ShapeColor = (0.12, 0.12, 0.14) bot_obj = doc.addObject("Part::Feature", "Shell_Bottom")
bot_obj.Shape = bot_shell
bot_obj.ViewObject.ShapeColor = (0.12, 0.12, 0.14)
bot_obj.ViewObject.Transparency = 0
lid_obj = doc.addObject("Part::Feature", "Pointer_Lid") top_obj = doc.addObject("Part::Feature", "Shell_Top")
lid_obj.Shape = lid top_obj.Shape = top_shell
lid_obj.ViewObject.ShapeColor = (0.28, 0.28, 0.34) top_obj.ViewObject.ShapeColor = (0.20, 0.20, 0.26)
lid_obj.ViewObject.Transparency = 25 top_obj.ViewObject.Transparency = 0
cap_obj = doc.addObject("Part::Feature", "Button_Cap")
cap_obj.Shape = cap_placed
cap_obj.ViewObject.ShapeColor = (0.80, 0.80, 0.86)
cap_obj.ViewObject.Transparency = 0
doc.recompute() doc.recompute()
Gui.activeDocument().activeView().viewIsometric() Gui.activeDocument().activeView().viewIsometric()
Gui.SendMsgToActiveView("ViewFit") Gui.SendMsgToActiveView("ViewFit")
# ═════════════════════════════════════════════════════════════════════════════
# SUMMARY
# ═════════════════════════════════════════════════════════════════════════════
print("=" * 62)
print("IMU Pointer v7")
print("=" * 62)
print(f"Body: {L:.0f} × {W:.0f} mm")
print(f"Height: {H:.0f} mm uniform (no taper)")
print(f"Wall: {WALL:.1f} mm CR = {CR:.1f} mm Edge fillet = {EDGE_FILLET:.1f} mm")
print(f"Split Z: {SPLIT_Z:.1f} mm "
f"(USB-C top = {USBC_Z + USBC_H:.1f} mm)")
print(f"Top shell interior height: {top_cav_lz:.1f} mm (Z {SPLIT_Z:.1f} → {H - WALL:.1f})")
print()
print(f"Tongue H/T: {TONGUE_H:.1f} / {TONGUE_T:.1f} mm")
print(f"Groove H/T: {GROOVE_H:.2f} / {GROOVE_T:.2f} mm")
print()
print(f"Button hole: ⌀{BTN_HOLE_R*2:.0f} mm X={BTN_X} Y={BTN_CY:.0f}")
print(f"Cap shaft: ⌀{CAP_SHAFT_R*2:.1f} mm × {CAP_SHAFT_H:.1f} mm (flush, Z {H-WALL:.1f}→{H:.1f})")
print(f"Cap rim: ⌀{CAP_RIM_R*2:.0f} mm × {CAP_RIM_H:.1f} mm (retention, below top face)")
print()
print(f"PCB top Z: {PCB_TOP_Z:.2f} mm (above split floor {floor_top_shell:.1f} mm)")
print(f"PCB bot Z: {PCB_BOT_Z:.2f} mm")
print(f"Post H: {POST_H:.2f} mm ⌀{POST_OD:.0f}/{POST_ID:.1f} mm sep={POST_SEP:.0f} mm c-to-c")
print()
print(f"Switch stack: body={SWITCH_BODY_H} + stem={STEM_H} + gap={GAP} mm")
print(" Adjust SWITCH_BODY_H / STEM_H if your Omron differs.")
print("=" * 62)