diff options
| author | Louis Burda <quent.burda@gmail.com> | 2024-08-14 01:33:05 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2024-08-14 01:33:05 +0200 |
| commit | 67b90d330bab091e40a93855b2874377dcf272d6 (patch) | |
| tree | 374b9d572a4c24cf519cf468abefcd512f34d19f | |
| parent | c989833a371e07f285c6bb169fefb335696afad6 (diff) | |
| download | desk-andon-67b90d330bab091e40a93855b2874377dcf272d6.tar.gz desk-andon-67b90d330bab091e40a93855b2874377dcf272d6.zip | |
Revise design with usbc board, oled and antenna
| -rw-r--r-- | model/main.py | 149 |
1 files changed, 126 insertions, 23 deletions
diff --git a/model/main.py b/model/main.py index ca1e437..35ee36a 100644 --- a/model/main.py +++ b/model/main.py @@ -1,5 +1,6 @@ from types import SimpleNamespace from cadquery import Workplane +from math import sin, cos, pi if "show_object" not in globals(): show_object = lambda v: () @@ -46,7 +47,7 @@ def cylinder(r, h): def build_usbc(width, height, depth, tol): def shape(width, height, depth): - radius = (height + 2 * tol) / 2 + radius = height / 2 - nothing offset = width / 2 - radius part = box(width - radius * 2, height, depth) part = part.union(cylinder(radius, depth).translate((-offset, 0, 0))) @@ -62,6 +63,23 @@ def build_usbc(width, height, depth, tol): bounds = gen(tol).translate((0, -height / 2, 0)).rotate(origin, (1, 0, 0), -90) return Ext(part, bounds) +def build_usbc_board(board, usbc, tol, usbc_overhang, hole_radius, hole_offset, bolt_radius, bolt_depth): + def gen(tol): + part = box(*(board + V3(tol, tol, tol) * 2).xyz()).translate((0, 0, -tol)) + part_usbc = build_usbc(**usbc.__dict__) + if tol != 0: + part_usbc = part_usbc.bounds + part = part.union(part_usbc.rotate(origin, (0, 0, 1), 180).translate((0, board.y / 2 + usbc_overhang, board.z))) + for x in (-1, 1): + if tol != 0: + part = part.union(cylinder(bolt_radius, board.z + 2 * tol + bolt_depth) + .translate((x * (board.x / 2 - hole_offset), board.y / 2 - hole_offset, -tol-bolt_depth))) + else: + part = part.cut(cylinder(hole_radius, board.z) + .translate((x * (board.x / 2 - hole_offset), board.y / 2 - hole_offset, 0))) + return part.translate((0, -board.y/2, 0)) + return Ext(gen(0), gen(tol)) + def build_bolt(bolt, shaft, tol): height = shaft + bolt.head_height @@ -84,16 +102,65 @@ def build_rod(rod, tol): return Ext(part, bounds) -def build_base(base, rod, rod_shaft, usbc, bolt, wall, tol, lid): +def build_oled(outer, screen, tol, hole, pins, pinlen): + def gen(tol): + slab = outer.z - screen.z + lower = V3(outer.x + 2 * tol, outer.y + 2 * tol, slab + 2 * tol) + upper = screen + V3(tol, tol, (10 if tol != 0 else 0)) * 2 + part2 = box(*upper.xyz()).translate((0, 0, lower.z)) + part = box(*lower.xyz()).union(part2).translate((0, 0, -tol)) + for y in range(-1, 2, 2): + for x in range(-1, 2, 2): + part = part.cut(cylinder(hole - tol, outer.z - tol) + .translate((x * 21 / 2, y * 22 / 2, 0))) + part = part.union(box(*pins.xyz()).translate((0, outer.y / 2 - pins.y / 2, slab))) + if tol == 0: + part = part.union(box(pins.x, pins.y, pinlen)\ + .translate((0, outer.y / 2 - pins.y / 2, slab - pinlen))) + return part + return Ext(gen(0), gen(tol)) + +def build_antenna(radius, height, top_offset, top_space, top_radius, tol, hex_height, hex_radius): + def gen(tol): + part = cylinder(radius + tol, height + 2 * tol).translate((0, 0, -tol)) + if tol != 0: + part = part.union(cylinder(top_radius + tol, top_space + tol).translate((0, 0, top_offset))) + part = part.union(cylinder(top_radius + tol + 4, height + tol - top_offset - top_space) \ + .translate((0, 0, top_offset + top_space))) + part = part.union(XY.polygon(6, hex_radius + tol * 1.4) \ + .extrude(10).translate((0, 0, -10 + hex_height))) + else: + part = part.union(cylinder(top_radius, height - top_offset).translate((0, 0, top_offset))) + part = part.union(XY.polygon(6, hex_radius).extrude(hex_height)) + return part + return Ext(gen(0), gen(tol)) + +def build_base(base, rod, rod_shaft, usbc_board, bolt, wall, tol, lid): outer = base inner = outer - V3(2 * wall.x, 2 * wall.y, wall.z) + V21(tol) + tower_radius = bolt.radius + wall.x + 1 + tower_height = inner.z + floor = wall.z - tol part = box(*base.xyz()) part = part.cut(box(*inner.xyz()).translate((0, 0, floor))) - tower_radius = bolt.radius + wall.x + 1 - tower_height = inner.z + antenna_wall_radius = lid.antenna.radius + 4 + antenna_rod = cylinder(antenna_wall_radius+wall.x, tower_height) \ + .cut(cylinder(antenna_wall_radius, tower_height)) + part = part.union(antenna_rod.translate((lid.antenna_offset + V3(0, -outer.y / 2, floor)).xyz())) + part = part.union(antenna_rod.translate((lid.antenna_offset + V3(0, -outer.y / 2, floor) - V3(2 * lid.antenna_offset.x, 0, 0)).xyz())) + part = part.union(box(abs(lid.antenna_offset.x)*2-2*nothing, (antenna_wall_radius+wall.x)*2, tower_height)\ + .translate((0, lid.antenna_offset.y - outer.y / 2, floor))) + + part = part.union(box(wall.x, inner.y, tower_height).translate((-20, 0, floor))) + part = part.union(box(wall.x, inner.y, tower_height).translate((20, 0, floor))) + + part = part.cut(box(40 - wall.x, inner.y, tower_height).translate((0, 0, floor))) + part = part.cut(box(abs(lid.antenna_offset.x)*2, antenna_wall_radius*2, tower_height)\ + .translate((0, lid.antenna_offset.y - outer.y / 2, floor))) + for y in range(-1, 2, 2): for x in range(-1, 2, 2): pos = V3(x * lid.hole_spacing.x / 2, y * lid.hole_spacing.y / 2, floor) @@ -105,24 +172,24 @@ def build_base(base, rod, rod_shaft, usbc, bolt, wall, tol, lid): .translate((pos + V3(x*(offset_x-(offset_x+tower_radius)/2), offset_y*y/2, 0)).xyz())) part = part.union(cylinder(tower_radius, tower_height).translate(pos.xyz())) - part = part.union(box(wall.x, inner.y, tower_height).translate((-20, 0, floor))) - part = part.union(box(wall.x, inner.y, tower_height).translate((20, 0, floor))) - # rod cut-out rod_pos = (rod_shaft.pos + V3(0, 0, floor)).xyz() base_rod_outer = rod.outer + 6 part = part.union(cylinder(base_rod_outer, tower_height).translate(rod_pos)) + fill_y = inner.y / 2 - rod_shaft.pos.y - part = part.union(box(40, fill_y, tower_height).translate(rod_pos)\ - .translate((0, -rod_shaft.pos.y+inner.y/2-fill_y/2, 0))) - part = part.cut(cylinder(rod.outer + tol, tower_height).translate(rod_pos)) + part = part.union(box(40, 2 * base_rod_outer - 4, tower_height).translate(rod_pos).translate((0, 1, 0))) + part_rod = cylinder(rod.outer + tol, tower_height).translate(rod_pos) + part = part.cut(part_rod) part = part.union(box(40, fill_y, 3).translate(rod_pos)\ - .translate((0, -rod_shaft.pos.y+inner.y/2-fill_y/2, 0))) + .translate((0, -rod_shaft.pos.y+inner.y/2-fill_y/2, 0)) \ + .intersect(part_rod)) part = part.cut(box(20, 25, 8).translate(rod_pos).translate((0, -rod.outer - wall.x/2))) + part = part.cut(box(8, 40, 5).translate(rod_pos).translate((0, 10))) part = part.cut(build_lid(**lid.__dict__).bounds.translate((0, 0, base.z - lid.base.z))) - board_hole = V(outer = 3, inner = 2.9 / 2 + tol, height = 2) + board_hole = V(outer = 3, inner = 2.9 / 2 + tol, height = 4) board_space = V3(40 - wall.x, 60, 0) print("Board Space", board_space) board_space_inner = board_space - V3(2 * board_hole.outer, 2 * board_hole.outer, 0) @@ -135,12 +202,14 @@ def build_base(base, rod, rod_shaft, usbc, bolt, wall, tol, lid): part = part.union(box(board_hole.outer, board_hole.outer, board_hole.height-nothing).translate(pos2.xyz())) part = part.cut(cylinder(board_hole.inner, board_hole.height).translate(pos.xyz())) - part_usbc = build_usbc(**usbc.__dict__, tol=tol) - part = part.cut(part_usbc.bounds.translate((board_center + V3(0, -board_space.y / 2 - 1.5, 4)).xyz())) + part_usbc = build_usbc_board(**usbc_board.__dict__) + part = part.union(box(usbc_board.board.x, usbc_board.board.y, 4).translate((0, inner.y / 2 - usbc_board.board.y / 2, floor))) + part = part.cut(part_usbc.bounds.translate((0, inner.y / 2, floor + 4))) return part -def build_lid(base, rod, rod_shaft, wall, bolt, bolt_depth, tol, hole_spacing): +def build_lid(base, rod, rod_shaft, wall, bolt, bolt_depth, tol, hole_spacing, + oled, oled_offset, antenna, antenna_offset, debug=False): outer = base inner = base - V21(wall + tol) rod_wall = V(outer = rod.outer + tol + wall, inner = rod.outer + tol, z = rod_shaft.height) @@ -169,6 +238,21 @@ def build_lid(base, rod, rod_shaft, wall, bolt, bolt_depth, tol, hole_spacing): part = part.union(part_bolt.bounds.translate((pos + V3(0, 0, -bolt_depth - bolt.head_height)).xyz())) else: part = part.cut(part_bolt.bounds.translate((pos + V3(0, 0, -bolt_depth - bolt.head_height)).xyz())) + + oled_pos = (oled_offset + V3(0, -outer_padded.y / 2, outer_padded.z - oled.outer.z)).xyz() + part_oled = build_oled(**oled.__dict__) + part = part.union(box(*oled.outer.xyz()).translate(oled_pos)) + part = part.cut(part_oled.bounds.translate(oled_pos)) + if debug: + part = part.union(part_oled.translate(oled_pos)) + + antenna_pos = (antenna_offset + V3(0, -outer_padded.y / 2, outer_padded.z - antenna.top_offset - antenna.top_space)).xyz() + part_antenna = build_antenna(**antenna.__dict__) + part = part.union(cylinder(antenna.top_radius + 2, antenna.height).translate(antenna_pos)) + part = part.cut(part_antenna.bounds.translate(antenna_pos)) + if debug: + part = part.union(part_antenna.translate(antenna_pos)) + return part part = gen(0) @@ -193,34 +277,53 @@ def main(): rod_shaft = V(pos = V3(0, 0, 0), height = 20) base = V3(120, 120, 30) - rod_shaft = V(pos = V3(0, 30, 0), height = 35) + rod_shaft = V(pos = V3(0, 23, 0), height = 35) + tol = 0.05 rod = V(outer = 25.3 / 2, inner = 21 / 2, len = 500) thin_wall = 2.4 thick_wall = 4 bolt = V(radius = 3 / 2, head_radius = 5.4 / 2, head_height = 3, cut_radius = 2.9 / 2) + oled = V(outer = V3(25.5, 26, 4), screen = V3(24.9, 16.5, 1.4), + tol = tol * 2, hole = 1, pins = V3(4 * 2.54, 2.54, 0.5), + pinlen = 8) + + antenna = V(radius = 6.1/2, height = 13, top_offset = 5.5 + 0.5, + top_radius = 7.6/2, top_space = 2, tol = tol * 2, + hex_height = 2, hex_radius = 8) + lid = V3(base.x, base.y, 10) lid_hole_spacing = V3(lid.x - 15, lid.y - 15, 0) insert = V(radius=5 / 2, height=5) base_wall = V3(thick_wall, thick_wall, thin_wall) - bolt_depth = base.z - bolt.head_height # - base_wall.z # let bolt go through + bolt_depth = base.z - bolt.head_height - base_wall.z # let bolt go through - usbc = V(width = 9, height = 3, depth = 7.3) + usbc = V(width = 9, height = 3, depth = 7.3, tol = tol) + usbc_board = V(usbc = usbc, board = V3(22, 13, 2), usbc_overhang = 1, + hole_radius = 3.2/2, hole_offset = 2.8, tol = tol, + bolt_radius = 3/2, bolt_depth = 4) #show_object(build_rod(rod).translate((0, 0, 10))) sheath_ctx = V(rod=rod, rod_shaft=rod_shaft, tol=tol, wall=thin_wall) - show_object(build_sheath(**sheath_ctx.__dict__).translate((-100, 0, 0))) + #show_object(build_sheath(**sheath_ctx.__dict__).translate((-100, 0, 0))) lid_ctx = V(base=lid, rod=rod, rod_shaft=rod_shaft, wall=thin_wall, bolt=bolt, bolt_depth=bolt_depth, tol=tol, - hole_spacing=lid_hole_spacing) - show_object(build_lid(**lid_ctx.__dict__).translate((150, 0, 0))) + hole_spacing=lid_hole_spacing, oled=oled, oled_offset=V3(0, 20, 0), + antenna=antenna, antenna_offset=V3(-30, 20, 0)) + show_object(build_lid(**lid_ctx.__dict__).translate((0, 0, 50))) base_ctx = V(base=base, rod=rod, rod_shaft=rod_shaft, bolt=bolt, - wall=base_wall, tol=tol, usbc=usbc) - show_object(build_base(**base_ctx.__dict__, lid=lid_ctx)) + wall=base_wall, tol=tol, usbc_board=usbc_board) + #show_object(build_base(**base_ctx.__dict__, lid=lid_ctx)) + + #show_object(build_oled(**oled.__dict__)) + + #show_object(build_antenna(**antenna.__dict__).bounds) + + #show_object(build_usbc_board(**usbc_board.__dict__).bounds) main() |
