bambu-printer-mcp 1.1.89 → 1.1.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +49 -1
  2. package/dist/cad/contracts.d.ts +84 -0
  3. package/dist/cad/contracts.js +50 -5
  4. package/dist/cad/examples.d.ts +22 -0
  5. package/dist/cad/examples.js +81 -0
  6. package/dist/cad/process.js +3 -0
  7. package/dist/cad-engine.d.ts +25 -0
  8. package/dist/cad-engine.js +197 -27
  9. package/dist/counterpart/flight-record.d.ts +155 -0
  10. package/dist/counterpart/flight-record.js +831 -0
  11. package/dist/counterpart/flight-tools.d.ts +213 -0
  12. package/dist/counterpart/flight-tools.js +232 -0
  13. package/dist/counterpart/fresh-frame.d.ts +16 -0
  14. package/dist/counterpart/fresh-frame.js +26 -0
  15. package/dist/counterpart/make-3mf.js +1 -4
  16. package/dist/counterpart/physical-evidence.d.ts +70 -0
  17. package/dist/counterpart/physical-evidence.js +103 -0
  18. package/dist/counterpart/print-geometry.d.ts +13 -0
  19. package/dist/counterpart/print-geometry.js +181 -0
  20. package/dist/counterpart/remote.js +4 -0
  21. package/dist/counterpart/schemas.d.ts +32 -0
  22. package/dist/counterpart/schemas.js +2 -0
  23. package/dist/counterpart/visual-evidence.d.ts +38 -0
  24. package/dist/counterpart/visual-evidence.js +155 -0
  25. package/dist/design-guidance.d.ts +22 -1
  26. package/dist/design-guidance.js +35 -2
  27. package/dist/index.js +35 -3
  28. package/dist/printers/bambu.d.ts +9 -2
  29. package/dist/printers/bambu.js +32 -6
  30. package/dist/safety/print-preview.d.ts +2 -0
  31. package/dist/safety/print-preview.js +1 -1
  32. package/dist/slicer/3mf-xml.d.ts +7 -0
  33. package/dist/slicer/3mf-xml.js +61 -0
  34. package/dist/stl/stl-manipulator.js +5 -2
  35. package/dist/tool-annotations.js +4 -0
  36. package/package.json +2 -1
  37. package/src/cad/contracts.ts +54 -5
  38. package/src/cad/examples/bag_clip.py +86 -0
  39. package/src/cad/examples/bistable_clicker.py +81 -0
  40. package/src/cad/examples/cable_clip.py +55 -0
  41. package/src/cad/examples/chainmail.py +45 -0
  42. package/src/cad/examples/hinged_box.py +101 -0
  43. package/src/cad/examples/knurled_knob.py +50 -0
  44. package/src/cad/examples/loft_handle.py +52 -0
  45. package/src/cad/examples/phone_stand.py +92 -0
  46. package/src/cad/examples/swept_hook.py +69 -0
  47. package/src/cad/examples/threaded_jar.py +62 -0
  48. package/src/cad/examples/trigger_capo.py +95 -0
  49. package/src/cad/examples/wall_hook.py +65 -0
  50. package/src/cad/examples.ts +77 -0
  51. package/src/cad/geometry.py +122 -4
  52. package/src/cad/process.ts +3 -0
  53. package/src/cad/worker.py +4 -0
  54. package/src/cad-engine.ts +221 -52
  55. package/src/counterpart/flight-record.ts +984 -0
  56. package/src/counterpart/flight-tools.ts +282 -0
  57. package/src/counterpart/fresh-frame.ts +45 -0
  58. package/src/counterpart/make-3mf.ts +1 -5
  59. package/src/counterpart/physical-evidence.ts +185 -0
  60. package/src/counterpart/print-geometry.ts +192 -0
  61. package/src/counterpart/remote.ts +4 -0
  62. package/src/counterpart/schemas.ts +3 -0
  63. package/src/counterpart/visual-evidence.ts +212 -0
  64. package/src/design-guidance.ts +35 -2
  65. package/src/index.ts +38 -4
  66. package/src/printers/bambu.ts +34 -5
  67. package/src/safety/print-preview.ts +1 -1
  68. package/src/slicer/3mf-xml.ts +52 -0
  69. package/src/stl/stl-manipulator.ts +4 -1
  70. package/src/tool-annotations.ts +4 -0
@@ -0,0 +1,86 @@
1
+ """Bag-sealing clip: two hinged bars, ridge into groove, snap latch, printed in place
2
+ Pattern: bar cross-section drawn in YZ and extruded along the bar; revolved waisted pin in a C-socket; ridge and its offset as the groove; modelled SHUT, then one bar swung open for printing
3
+ Modelled on: Linden Sweden Twixit! bag clip (https://www.webstaurantstore.com/linden-sweden-411-8-twixit-blue-4-1-4-pastry-bag-clips-pack/534411.8.html); mechanism as in the hinged-bar clip patent US 4656697, Naslund (https://patents.google.com/patent/US4656697)
4
+ Published sizes used: 108 mm (4 1/4 in) = overall length (retailer, https://www.webstaurantstore.com/linden-sweden-411-8-twixit-blue-4-1-4-pastry-bag-clips-pack/534411.8.html); nothing else is published, the other sizes are design choices
5
+ Concept: Closes an opened bag of coffee, crisps or frozen peas. Two bars are hinged at one end and latched at the other; a ridge along one bar pushes the bag film into a groove along the other, so the film is pinched on both flanks of the ridge for the whole length, which is what seals it (the bought clip does the same with two thin legs in a wedge channel). 2 bodies: bar A carries the ridge, the hinge pin on a neck, the yoke round the socket and the latch arm; bar B carries the groove and a C-shaped socket. The bag pushes the bars apart: at the hinge that load goes from the socket's closed side into the pin (the socket's opening faces backwards, away from the load), at the other end from B's back into the latch nose and down the arm. It is printed lying flat with the pin vertical and bar B swung 30 degrees open, because then the hinge is plain vertical walls with a 0.4 mm gap, the latch arm bends in the layer plane, and the 45 degree ridge, groove and pin waist need no support. The pin's V-waist stops B lifting off; the socket wraps 270 degrees of the pin so it cannot pull off sideways. The arm is 3 lines (1.26 mm) wide and 12.7 mm long: the 0.9 mm snap strains it about 1 percent. Push the round bead outward to open. PETG (PLA works, with a shorter life), 0.2 mm layers, no supports.
6
+ What makes this good: every working surface is either a vertical wall or a 45 degree flank, so the mechanism is exactly what the slicer prints, and the backs of the bars are bulged where the fingers squeeze.
7
+ """
8
+ from build123d import *
9
+ from math import cos, radians, sin, sqrt
10
+
11
+ P = {
12
+ "length": 108.0, # overall, shut (published: 4 1/4 in)
13
+ "height": 9.0, # height off the bed = the clip's width across the bag
14
+ "bar_w": 7.0, # each bar, sealing face to the crown of its back
15
+ "back_bulge": 1.2, # how far the back bows out at mid-height (30 degrees at the bed, prints clean)
16
+ "seal": 0.25, # film gap between the bars, and between ridge and groove, when latched
17
+ "ridge_h": 2.2, # ridge height; its flanks are 45 degrees
18
+ "ridge_tip": 0.6, # flat on the ridge tip so it does not cut the film
19
+ "gap": 0.4, # print-in-place clearance in the hinge
20
+ "pin_r": 3.5, # hinge pin radius
21
+ "waist": 1.5, # depth of the pin's V-waist: stops bar B sliding off the pin
22
+ "socket_wall": 2.0, # wall of bar B's C-socket
23
+ "yoke_t": 2.4, # bar A's yoke round the socket
24
+ "neck_w": 2.4, # neck joining the pin to the yoke through the socket's opening
25
+ "open_max": 40.0, # degrees bar B can swing before the socket meets the neck
26
+ "print_open": 30.0, # degrees it is printed open
27
+ "arm_t": 1.26, # latch arm: 3 lines of 0.42, bends in the layer plane
28
+ "arm_slot": 0.8, # slot between the end of bar A and the arm
29
+ "foot": 1.8, # strip joining the arm to the back of bar A
30
+ "catch": 0.9, # overlap of the latch nose on bar B's back (more than the hinge play)
31
+ "latch_clear": 0.25, # clearance from bar B to the arm and to the nose, latched
32
+ "grip_r": 2.2, # round bead on the arm that the thumb pushes
33
+ }
34
+
35
+ def rect(x0, x1, y0, y1):
36
+ return Pos((x0 + x1) / 2, (y0 + y1) / 2) * Rectangle(x1 - x0, y1 - y0)
37
+
38
+ def section(side): # bar cross-section in YZ: flat sealing face at y = side * seal / 2, back bowed out for the fingers
39
+ y0, h = P["seal"] / 2, P["height"]
40
+ y1 = y0 + P["bar_w"] - P["back_bulge"]
41
+ flat = Polyline((side * y1, 0), (side * y0, 0), (side * y0, h), (side * y1, h))
42
+ back = ThreePointArc((side * y1, h), (side * (y0 + P["bar_w"]), h / 2), (side * y1, 0))
43
+ return Plane.YZ * make_face(flat.edges() + back.edges())
44
+
45
+ def waisted(r, v): # vertical pin of radius r with a 45 degree V-waist v deep at mid-height (no overhang past 45)
46
+ h = P["height"]
47
+ half = Polygon((0, 0), (r, 0), (r, h / 2 - v), (r - v, h / 2), (r, h / 2 + v), (r, h), (0, h), align=None)
48
+ return revolve(Plane.XZ * half, Axis.Z)
49
+
50
+ def build():
51
+ h, s, w, gap, clear = P["height"], P["seal"], P["bar_w"], P["gap"], P["latch_clear"]
52
+ r_sock = P["pin_r"] + gap + P["socket_wall"] # socket outside
53
+ r_yoke = r_sock + gap # yoke inside
54
+ r_head = r_yoke + P["yoke_t"] # the hinge axis is the Z axis; bars run along +X, A at -Y, B at +Y
55
+ xi = P["length"] - r_head - 2 * P["grip_r"] # inner face of the latch arm
56
+ x_a, x_b = xi - P["arm_slot"], xi - clear # ends of bar A and bar B
57
+ y_a, y_c = -(s / 2 + w), s / 2 + w + clear # back of bar A; catch face of the nose over bar B's back
58
+
59
+ # bar A: bar, yoke under and behind the socket, neck and waisted pin
60
+ yoke = Circle(r_head) - Circle(r_yoke) - Polygon((0, -s / 2), (50, -s / 2), (50, 50), (-50, 22), align=None) # keep 155 to 360 degrees
61
+ neck = rect(-r_yoke - 1, -1, -P["neck_w"] / 2, P["neck_w"] / 2)
62
+ bar_a = extrude(section(-1), x_a) - Cylinder(r_yoke, 3 * h)
63
+ # latch: foot, arm standing past bar B, nose with a lead-in ramp, round bead to push
64
+ n = P["catch"] + clear
65
+ y_top = y_c + 0.5 + 1.5 * n
66
+ arm = rect(x_a - 2, xi + P["arm_t"], y_a, y_a + P["foot"]) + rect(xi, xi + P["arm_t"], y_a, y_top)
67
+ nose = Polygon((xi + 0.1, y_c), (xi + 0.1, y_top), (xi - n, y_c + 0.5), (xi - n, y_c), align=None) # anticlockwise, so it extrudes up
68
+ bead = Pos(xi + P["grip_r"], y_top) * Circle(P["grip_r"])
69
+ a = bar_a + extrude(yoke + neck + arm + nose + bead, h) + waisted(P["pin_r"], P["waist"])
70
+
71
+ # ridge on A, and the same profile grown by the film gap as the groove in B
72
+ zc, th, tip, x0 = h / 2, P["ridge_h"], P["ridge_tip"] / 2, r_head + 1
73
+ ridge = Polygon((-s / 2 - 0.5, zc - th - tip), (-s / 2, zc - th - tip), (-s / 2 + th, zc - tip),
74
+ (-s / 2 + th, zc + tip), (-s / 2, zc + th + tip), (-s / 2 - 0.5, zc + th + tip), align=None)
75
+ a += Pos(x0, 0, 0) * extrude(Plane.YZ * ridge, x_a - 2 - x0)
76
+ groove = Pos(x0 - 1, 0, 0) * extrude(Plane.YZ * offset(ridge, s, kind=Kind.INTERSECTION), x_a - x0)
77
+
78
+ # bar B: bar and C-socket. The opening is the neck's slot (neck + gap) swept through the swing, so it is no wider than it must be.
79
+ far, slot_w = 3 * r_sock, P["neck_w"] / 2 + gap
80
+ slot, turn = rect(-far, 0, -slot_w, slot_w), radians(180 - P["open_max"])
81
+ swept = slot + Rot(0, 0, -P["open_max"]) * slot + Polygon((0, 0), (far * cos(turn), far * sin(turn)), (-far, 0), align=None)
82
+ socket = Circle(r_sock) - swept
83
+ b = extrude(section(1), x_b) + extrude(socket, h)
84
+ b -= waisted(P["pin_r"] + gap, P["waist"] - gap * (sqrt(2) - 1)) + groove # pin shape grown by gap, measured square to the surface
85
+
86
+ return Compound([a, Rot(0, 0, P["print_open"]) * b])
@@ -0,0 +1,81 @@
1
+ """Pocket clicker: a bistable double curved beam in a closed frame
2
+ Pattern: a computed 2D curve (cosine beam from a formula) made into a face, extruded flat with a filleted frame round it
3
+ Modelled on: the double curved-beam bistable mechanism of Qiu, Lang and Slocum, "A curved-beam bistable mechanism", J. Microelectromechanical Systems 13(2), 2004, pp. 137-146 (https://manuscript.isc.ac/Inventory/49/950908.htm)
4
+ Published sizes used: bistability ratio rise / thickness must exceed about 2.31 for a cosine beam clamped at both ends with its twisting mode blocked (Qiu, Lang and Slocum 2004, URL above); here rise / thickness = 3.0. All other sizes are design choices.
5
+ Concept: A one-piece fidget that snaps between two rest positions with a click. Two parallel beams, each pre-curved as one cosine wave, are clamped in the end walls of a closed frame and joined at the centre by a shuttle, so the centre cannot rotate and the beams must snap straight through instead of rolling over. Pushing the thumb pad squeezes the beams along their length; the two rails carry that thrust in tension, so the frame must be a closed ring that does not spread: if it spreads, the snap is lost. Travel stops on the rails catch the shuttle at 1.65 x rise, short of where the beams would come to rest on their own (a little under 2 x rise), so they keep pressing on the stop. MODELLED AS PRINTED, flat on the bed, because the beams must bend in the layer plane; each beam is 3 lines of 0.42 mm wide. Peak bending strain is about 2 pi^2 x thickness x rise / span^2 = 1.5 %, so print it in PETG, not brittle PLA. No supports. 1 body (print-in-place gap 0.4 mm at the stop).
6
+ What makes this good: the beam is computed from the published bistability ratio, and the frame is a rounded pebble, not a sharp slab.
7
+ """
8
+ import math
9
+ from build123d import *
10
+
11
+ P = {
12
+ "line_w": 0.42, # one extrusion line
13
+ "beam_lines": 3, # beam thickness in whole lines (3 is the least for a spring)
14
+ "rise_ratio": 3.0, # rise / thickness; must be more than 2.31 to be bistable, more gives a harder click
15
+ "span": 80.0, # beam length between the end walls; longer is softer and strains the plastic less
16
+ "beam_h": 5.0, # beam height off the bed; taller is stiffer and resists the pad tipping
17
+ "beam_pitch": 12.0, # distance between the two beams; wide apart so the shuttle cannot twist
18
+ "travel_ratio": 1.65, # stop position as a multiple of the rise; keep it under about 1.8 so the beams still press on the stop
19
+ "stop_gap": 0.4, # print-in-place gap between the shuttle and the stop it is printed against
20
+ "stop_len": 2.0, # how far each travel stop stands out from its rail
21
+ "shuttle_w": 14.0, # shuttle and thumb pad width along the beams
22
+ "shuttle_lip": 1.0, # shuttle material beyond each beam so the beams are fully buried in it
23
+ "pad_h": 11.5, # top of the thumb pad above the bed (2.5 above the frame)
24
+ "frame_h": 9.0, # frame thickness
25
+ "rail_w": 7.0, # the two long rails that carry the beam thrust in tension
26
+ "wall_w": 8.0, # the two end walls the beams are clamped in
27
+ "corner_r": 16.0, # outside corner radius in plan, so it sits in a closed hand
28
+ "edge_round": 3.5, # fillet on the frame's top outside edge
29
+ "lanyard_d": 4.0, # keyring hole through one end wall
30
+ "bed_chamfer": 1.0, # chamfer on the bed side (a fillet touching the bed prints as a ragged overhang)
31
+ }
32
+
33
+
34
+ def cosine_beam(y0, span, rise, t):
35
+ """Face of one beam: centreline y = rise/2 * (1 + cos(2 pi x / span)), thickness t measured along the normal."""
36
+ def side(sign):
37
+ pts = []
38
+ for i in range(25):
39
+ x = span * (i / 24 - 0.5)
40
+ slope = -math.pi * rise / span * math.sin(2 * math.pi * x / span)
41
+ n = math.hypot(1, slope)
42
+ y = y0 + rise / 2 * (1 + math.cos(2 * math.pi * x / span))
43
+ pts.append((x - sign * t / 2 * slope / n, y + sign * t / 2 / n))
44
+ return Spline(*pts)
45
+ upper, lower, bury = side(1), side(-1), Vector(1, 0) # each end runs 1 mm into its wall so it fuses solidly
46
+ right = Polyline(upper @ 1, (upper @ 1) + bury, (lower @ 1) + bury, lower @ 1)
47
+ left = Polyline(lower @ 0, (lower @ 0) - bury, (upper @ 0) - bury, upper @ 0)
48
+ return make_face([upper, right, lower, left])
49
+
50
+
51
+ def build():
52
+ t = P["beam_lines"] * P["line_w"]
53
+ rise = P["rise_ratio"] * t # the bistability condition, computed, not typed in
54
+ travel = P["travel_ratio"] * rise
55
+ span, pitch, lip = P["span"], P["beam_pitch"], P["shuttle_lip"]
56
+
57
+ # Two beams (ends at y = 0 and y = pitch, bowed towards +Y as printed) and the shuttle that ties their centres.
58
+ beams = cosine_beam(0, span, rise, t) + cosine_beam(pitch, span, rise, t)
59
+ sh_lo, sh_hi = rise - t / 2 - lip, pitch + rise + t / 2 + lip
60
+ shuttle = Pos(0, (sh_lo + sh_hi) / 2) * RectangleRounded(P["shuttle_w"], sh_hi - sh_lo, 5)
61
+
62
+ # Window: room for the printed position, the stop gap, and the travel to the other stop.
63
+ win_lo, win_hi = sh_lo - travel - P["stop_len"], sh_hi + P["stop_gap"] + P["stop_len"]
64
+ win_mid, win_h = (win_lo + win_hi) / 2, win_hi - win_lo
65
+ window = Pos(0, win_mid) * RectangleRounded(span, win_h, 4)
66
+ stop = Rectangle(P["shuttle_w"], P["stop_len"] + 1) # 1 mm buried in the rail
67
+ stops = Pos(0, win_hi - P["stop_len"] / 2 + 0.5) * stop + Pos(0, win_lo + P["stop_len"] / 2 - 0.5) * stop
68
+
69
+ # Closed frame: round the outside like a pebble BEFORE cutting the window, so only outside edges are touched.
70
+ outline = RectangleRounded(span + 2 * P["wall_w"], win_h + 2 * P["rail_w"], P["corner_r"])
71
+ slab = extrude(Pos(0, win_mid) * outline, P["frame_h"])
72
+ slab = fillet(slab.edges().group_by(Axis.Z)[-1], P["edge_round"])
73
+ slab = chamfer(slab.edges().group_by(Axis.Z)[0], P["bed_chamfer"])
74
+ lanyard = Pos(-(span + P["wall_w"]) / 2, win_mid) * Circle(P["lanyard_d"] / 2)
75
+ frame = slab - extrude(window + lanyard, P["frame_h"]) + extrude(stops, P["beam_h"])
76
+
77
+ # Thumb pad: the shuttle carried up above the frame, with a domed top edge for the thumb.
78
+ pad = extrude(shuttle, P["pad_h"])
79
+ pad = fillet(pad.edges().group_by(Axis.Z)[-1], 3.0)
80
+ ribs = [Pos(0, (sh_lo + sh_hi) / 2 + dy, P["pad_h"]) * Box(P["shuttle_w"], 1.2, 1.2) for dy in (-4, 0, 4)]
81
+ return frame + extrude(beams, P["beam_h"]) + (pad - ribs) # ribs across the push direction for thumb grip
@@ -0,0 +1,55 @@
1
+ """Adhesive desk cable clip (single cable, snap-in C channel on a taped pad)
2
+ Pattern: sweep a rounded (slot) section along an arc for the C ring + loft the pad up into it, fillet the lip tips
3
+ Modelled on: 3M Command Clear Round Cord Clips 17017CLR (https://argo.webstaurantstore.com/3m-command-8482-7100027385-clear-round-cord-clips-pack/39917017CLRES.html)
4
+ Published sizes used: 13/16 in (20.6 mm) = clip width, 1/2 in (12.7 mm) = clip depth (retailer, URL above); cable diameter, mouth and wall are design choices
5
+ Concept: A stick-on clip that parks one charging cable at the desk edge. The cable is pushed down through a mouth narrower than itself; the two lips of the C ring spring apart and close over it, so it slides lengthways but cannot lift out. The pull of the cable goes round the ring, down the lofted neck and spreads over the whole pad, which is flat for a foam tape square. Prints as modelled, pad on the bed, no supports (the channel is a 5.6 mm bridge-free arch). The lips are 4 lines wide and the ring is one continuous sweep, so the perimeters run round the C; the flex still crosses layers at the ring's sides, so print PETG (or PLA for light cables) and do not shrink the mouth below about 70% of the cable.
6
+ What makes this good: one swept ring with fully rounded lips and a neck that flows into the pad, so it reads as a moulded clip rather than a bracket.
7
+ """
8
+ from math import asin, degrees
9
+
10
+ from build123d import *
11
+
12
+ P = {
13
+ "cable_d": 5.0, # cable it holds (design choice: a thick USB-C or power lead)
14
+ "channel_clear": 0.6, # channel is this much bigger than the cable so it slides
15
+ "mouth": 3.6, # gap between the lips; the cable squeezes through (72% of cable_d)
16
+ "lip_t": 1.68, # ring wall = 4 x 0.42 mm lines, thin enough to spring
17
+ "ring_w": 8.0, # ring length along the cable; wide so the jacket is not creased
18
+ "tip_r": 0.7, # rounding of the lip tips (finger and cable lead-in)
19
+ "pad_l": 20.6, # pad length across the cable (published clip width)
20
+ "pad_w": 12.7, # pad width along the cable (published clip depth)
21
+ "pad_t": 1.2, # pad edge thickness
22
+ "pad_corner_r": 4.0, # plan corner radius of the pad
23
+ "seat_h": 3.4, # underside of the cable above the taped face
24
+ "cradle": 0.5, # neck rises to this fraction of the channel radius below its centre
25
+ }
26
+
27
+
28
+ def build():
29
+ r_in = (P["cable_d"] + P["channel_clear"]) / 2
30
+ r_mid, r_out = r_in + P["lip_t"] / 2, r_in + P["lip_t"]
31
+ zc = P["seat_h"] + r_in # channel centre height
32
+
33
+ # C ring: one sweep round the cable axis (Y), open at the top by the mouth angle
34
+ half_mouth = degrees(asin(P["mouth"] / 2 / r_in))
35
+ arc = Plane.XZ * CenterArc((0, zc), r_mid, 90 + half_mouth, 360 - 2 * half_mouth)
36
+ section = Plane(arc @ 0, x_dir=(0, 1, 0), z_dir=arc % 0) * SlotOverall(P["ring_w"], P["lip_t"])
37
+ ring = sweep(section, path=arc)
38
+ # round the two lip tips: the only flat faces on the ring are its ends
39
+ tips = ring.faces().filter_by(GeomType.PLANE).edges()
40
+ ring = fillet(tips, P["tip_r"])
41
+
42
+ # pad + neck: loft from the tape footprint up round the lower third of the ring, so the
43
+ # cable's pull spreads into the whole pad and only the upper lips are free to spring
44
+ neck_top = zc - r_in * P["cradle"]
45
+ neck_l = 2 * (r_out**2 - (zc - neck_top) ** 2) ** 0.5 # chord of the ring at that height
46
+ base = loft([
47
+ Plane.XY * RectangleRounded(P["pad_l"], P["pad_w"], P["pad_corner_r"]),
48
+ Plane.XY.offset(P["pad_t"]) * RectangleRounded(P["pad_l"] - 1, P["pad_w"] - 1, P["pad_corner_r"] - 0.5),
49
+ Plane.XY.offset(P["pad_t"] + 0.8) * RectangleRounded(neck_l + 3, P["ring_w"], 2.5),
50
+ Plane.XY.offset(neck_top) * RectangleRounded(neck_l, P["ring_w"] - 1.5, 2.0),
51
+ ])
52
+ # clear the channel out of the neck; cutting at mid-wall hides the cut inside the ring,
53
+ # so the cable only ever touches the smooth swept surface
54
+ base -= Pos(0, 0, zc) * Rot(90, 0, 0) * Cylinder(r_mid, P["pad_w"])
55
+ return base + ring
@@ -0,0 +1,45 @@
1
+ """Chainmail patch: rigid square links that pass through each other, printed in place
2
+ Pattern: one link made from a rounded ring with two box cuts (two bars stay on the bed, two become bridges), then copied on a grid as a Compound of separate solids
3
+ Modelled on: NASA/JPL "space fabric" (https://www.jpl.nasa.gov/news/space-fabric-links-fashion-and-engineering) and Ed Nisley's printable chain mail (https://softsolder.com/2014/12/04/3d-printed-chain-mail-armor-cosplay-edition/)
4
+ Published sizes used: 2.4 mm = bar width, 6 threads of 0.40 mm (maker, https://softsolder.com/2014/12/04/3d-printed-chain-mail-armor-cosplay-edition/); JPL publishes no sizes; the other sizes are design choices
5
+ Concept: A flexible sheet of hard links for costume mail, a trivet, a strap or a fidget, printed flat in one go: rows x cols separate bodies (16 by default). Each link is a square ring whose two bars along X lie on the bed and whose two bars along Y are lifted one clearance higher, carried as short bridges by the four full-height corner posts. Turned 45 degrees and set on a square grid, every link's corner post stands inside the opening of each neighbour, so each pair of rings is threaded like two links of a chain; pull on the sheet and the load goes ring to ring through the posts. Flat feet (the low bars and posts) hold every link to the bed, the bridges span 7.2 mm over the two neighbour bars that pass under them, and nothing overhangs, so no supports. The raised bars are rounded for the hand; the bed edges are chamfered so first-layer squash cannot join neighbours. PETG or PLA, 0.2 mm layers.
6
+ What makes this good: the clearances are stated numbers that the pitch is derived from, so changing the link size keeps the links free, and solid_count proves they did not fuse.
7
+ """
8
+ from build123d import *
9
+ from math import sqrt
10
+
11
+ P = {
12
+ "rows": 4, # links along Y
13
+ "cols": 4, # links along X
14
+ "link": 12.0, # outside of one square link (must be at least 4 * bar + 3 * gap)
15
+ "bar": 2.4, # bar width, and the outside corner radius: 6 lines of 0.4
16
+ "bar_t": 1.2, # bar thickness: 6 layers
17
+ "lift": 0.8, # vertical clearance between a low bar and the bridge over it: 4 layers
18
+ "gap": 0.7, # horizontal clearance between a neighbour's post and this link's bars
19
+ "top_r": 0.8, # rounding of the raised bars, the side the hand feels
20
+ "foot_chamfer": 0.3, # chamfer on the bed edges
21
+ }
22
+
23
+ # Why the links cannot come apart. Take a link at the origin, unrotated, and its neighbour one pitch away on the diagonal
24
+ # (pitch = link - 2 * bar - gap = 6.5). This link's corner post spans 3.6 to 6.0 in X and Y; the neighbour's near bars and
25
+ # post span 0.5 to 2.9, so the neighbour's post stands INSIDE this ring's opening (-3.6 to 3.6) and this post stands inside
26
+ # the neighbour's. Each ring is closed, so the two are threaded like chain links: this link's low bar (z 0 to 1.2) runs
27
+ # under the neighbour's bridge (z from 2.0) and its own bridge runs over the neighbour's low bar. To separate, a bar would
28
+ # have to pass through a bar. Gaps, from those coordinates: post to bar 3.6 - 2.9 = 0.7; post to the next neighbour's post
29
+ # 0.5 - (-0.5) = 1.0; link to the link two pitches away 13.0 - 12.0 = 1.0; low bar to bridge 2.0 - 1.2 = 0.8. All above 0.4.
30
+
31
+ def link():
32
+ s, b, t = P["link"], P["bar"], P["bar_t"]
33
+ high = t + P["lift"] # underside of the bridges
34
+ ring = extrude(RectangleRounded(s, s, b) - Rectangle(s - 2 * b, s - 2 * b), high + t)
35
+ low_align = (Align.CENTER, Align.CENTER, Align.MIN)
36
+ ring -= Pos(0, 0, t) * Box(s - 2 * b, 2 * s, high, align=low_align) # bars along X keep only their bottom: feet on the bed
37
+ ring -= Box(2 * s, s - 2 * b, high, align=low_align) # bars along Y keep only their top: bridges between the posts
38
+ ring = fillet(ring.edges().group_by(Axis.Z)[-1], P["top_r"]) # soft raised bars
39
+ return chamfer(ring.edges().group_by(Axis.Z)[0], P["foot_chamfer"]) # room for first-layer squash
40
+
41
+ def build():
42
+ pitch = P["link"] - 2 * P["bar"] - P["gap"] # diagonal neighbour spacing that leaves `gap` beside each post
43
+ step = pitch * sqrt(2) # the same lattice turned 45 degrees is a plain square grid
44
+ one = Rot(0, 0, 45) * link()
45
+ return Compound([Pos(c * step, r * step, 0) * one for r in range(P["rows"]) for c in range(P["cols"])])
@@ -0,0 +1,101 @@
1
+ """Hinged pill and parts box with a snap latch, printed in place
2
+ Pattern: model the lid CLOSED on the box, then swing it 180 degrees about the pin axis into the flat printed pose; hull-profile knuckles with cone pin ends cut as cone sockets
3
+ Modelled on: rose plastic UniBox, a polypropylene hinged box with a press closure (https://shop.rose-plastic.de/en_10/plastic-boxes/unibox.html; the page lists no box this small, the smallest read was 100 x 100 mm inside)
4
+ Published sizes used: none published; sizes are design choices
5
+ Concept: A pocket box for pills or small screws, in 2 bodies: the box (two outer hinge knuckles, the latch spring) and the lid (centre knuckle, locating lip, thumb finger). It is printed open and flat, box and lid side by side with the knuckles between them, because that is the only pose in which both halves stand on the bed with their open sides up, so nothing inside needs support and the hinge prints with a clean gap; it comes off the bed as one working piece. That layout fixes the pin at half the closed height. The lid knuckle ends in a 45 degree cone each side, seated in a cone socket in the box knuckles with 0.4 mm all round, so the pin is captive as printed and its overhangs never pass 45 degrees. Closed, the lid's lip drops inside the box mouth and takes side knocks; the hinge side has no lip because the hinge already locates that edge. The latch is a leaf spring 3 lines (1.26 mm) wide standing along the front wall, bending in the layer plane, with the wall 0.9 mm behind it as its hard stop: the barb on the lid's finger cams the leaf in 0.5 mm and snaps under its nose, and the 45 degree catch faces let a firm pull, or a press on the leaf, open it. PETG or PLA, 0.2 mm layers, no supports.
6
+ What makes this good: it is drawn closed, where the fits are easy to reason about, and one rotation about the pin gives the printable pose, so the closed fit and the printed gaps cannot disagree.
7
+ """
8
+ from build123d import *
9
+ from math import sqrt
10
+
11
+ P = {
12
+ "length": 60.0, # along the hinge (Y), outside
13
+ "width": 40.0, # hinge side to latch side (X), outside
14
+ "box_h": 14.0, # box height including the floor
15
+ "lid_h": 6.0, # lid height including its top
16
+ "wall": 1.6, # walls, floor and lid top: 4 lines of 0.4
17
+ "corner_r": 6.0, # plan corner radius, comfortable in a pocket
18
+ "edge_r": 1.5, # rounded floor edge and lid top edge (small enough to print on the bed)
19
+ "scoop_r": 3.0, # fillet inside the floor so a fingertip can sweep a pill out
20
+ "lip_h": 1.6, # how far the lid's lip drops into the box
21
+ "lip_t": 1.2, # lip thickness: 3 lines
22
+ "lip_fit": 0.25, # lip to box wall, each side
23
+ "gap": 0.4, # print-in-place clearance, hinge faces and cones
24
+ "hinge_off": 4.5, # pin axis to the back walls
25
+ "knuckle_r": 3.0, # knuckle outer radius
26
+ "pin_r": 2.0, # cone pin radius at its root
27
+ "pin_tip_r": 0.6, # cone pin radius at its flat tip
28
+ "box_knuckle": 8.0, # length of each of the box's two knuckles
29
+ "lid_knuckle": 16.0, # length of the lid's centre knuckle
30
+ "leaf_t": 1.26, # latch leaf spring: 3 lines of 0.42, bends in the layer plane
31
+ "leaf_len": 16.0, # free length of the leaf (0.9 mm at the tip strains it under 1 percent)
32
+ "stop_gap": 0.9, # leaf to front wall: the wall is the hard stop
33
+ "nose": 0.8, # how far the leaf's nose stands out
34
+ "catch": 0.5, # overlap of nose and barb = the stroke to open
35
+ "latch_play": 0.2, # vertical play between the catch faces when shut
36
+ "latch_w": 8.0, # width of the nose; the finger is 2 mm wider
37
+ "finger_t": 2.4, # thickness of the lid's thumb finger
38
+ }
39
+
40
+ def rect(x0, x1, y0, y1):
41
+ return Pos((x0 + x1) / 2, (y0 + y1) / 2) * Rectangle(x1 - x0, y1 - y0)
42
+
43
+ def plan(inset=0.0): # the rounded footprint, shared by box, cavity, lid and lip
44
+ return RectangleRounded(P["width"] - 2 * inset, P["length"] - 2 * inset, P["corner_r"] - inset)
45
+
46
+ def knuckle(za, z0, z1, y_len): # round eye on the pin axis, hulled to the face of its own wall between z0 and z1
47
+ d = P["hinge_off"]
48
+ eye = Pos(0, za) * Circle(P["knuckle_r"])
49
+ web = make_hull(eye.edges() + rect(-d, -d + 0.1, z0, z1).edges()) + rect(-d - P["wall"] / 2, -d, z0, z1) # second term keys it into the wall
50
+ return extrude(Plane.XZ * web, y_len / 2, both=True)
51
+
52
+ def pin_end(za, grow): # 45 degree cone along +Y from the lid knuckle's end face; grow > 0 makes the socket `grow` larger all round
53
+ r, tip = P["pin_r"], P["pin_tip_r"]
54
+ cone = Cone(r + grow * sqrt(2), tip + grow * (sqrt(2) - 1), r - tip + grow, align=(Align.CENTER, Align.CENTER, Align.MIN))
55
+ return Pos(0, P["lid_knuckle"] / 2, za) * Rot(-90, 0, 0) * cone
56
+
57
+ def build():
58
+ W, hb, hl, t, gap, d = P["width"], P["box_h"], P["lid_h"], P["wall"], P["gap"], P["hinge_off"]
59
+ za = (hb + hl) / 2 # pin height: half the closed height, so the opened lid lands on the bed
60
+ lo = za - d - P["knuckle_r"] * sqrt(2) # lowest wall point a knuckle web may reach and still rise at 45 degrees
61
+ at_box = Pos(-(d + W / 2), 0, 0) # the pin axis is the Y axis at height za; the box sits on its -X side
62
+ swing_open = Pos(0, 0, za) * Rot(0, 180, 0) * Pos(0, 0, -za)
63
+
64
+ # box: rounded shell with a scooped floor, two outer knuckles with cone sockets
65
+ shell = extrude(plan(), hb)
66
+ shell = fillet(shell.edges().group_by(Axis.Z)[0], P["edge_r"])
67
+ cavity = extrude(Pos(0, 0, t) * plan(t), hb)
68
+ shell -= fillet(cavity.edges().group_by(Axis.Z)[0], P["scoop_r"])
69
+ box_k = Pos(0, (P["lid_knuckle"] + P["box_knuckle"]) / 2 + gap, 0) * knuckle(za, lo, hb, P["box_knuckle"]) - pin_end(za, gap)
70
+ box = at_box * shell + box_k + mirror(box_k, Plane.XZ)
71
+
72
+ # lid, drawn closed on top of the box: cap, lip hanging into the mouth (not on the hinge side), centre knuckle with cone ends
73
+ cap = extrude(Pos(0, 0, hb) * plan(), hl)
74
+ cap = fillet(cap.edges().group_by(Axis.Z)[-1], P["edge_r"])
75
+ a = t + P["lip_fit"]
76
+ lip = extrude(Pos(0, 0, hb - P["lip_h"]) * plan(a), P["lip_h"])
77
+ lip -= Pos(W / 2, 0, hb - P["lip_h"] / 2) * Box(2 * P["corner_r"], P["length"], P["lip_h"]) # a lip here would swing through the back wall
78
+ hollow = extrude(Pos(0, 0, hb - P["lip_h"]) * plan(a + P["lip_t"]), P["lip_h"] + hl - t)
79
+ lid_k = knuckle(za, hb, 2 * za - lo, P["lid_knuckle"]) + pin_end(za, 0) + mirror(pin_end(za, 0), Plane.XZ)
80
+ lid = at_box * (cap + lip - hollow) + lid_k
81
+
82
+ # latch, in the closed pose. out(x, z) is a point x outside the front wall at height z.
83
+ xf = -(d + W)
84
+ out = lambda x, z: (xf - x, z)
85
+ face, zt, half = P["stop_gap"] + P["leaf_t"], hb - gap, P["latch_w"] / 2 # leaf outer face; leaf top, clear of the finger above it
86
+ tip = face + P["nose"] # nose tip
87
+ zn = zt - 1.5 * P["nose"] - gap # bottom of the nose's flat tip
88
+ leaf = rect(xf - face, xf - P["stop_gap"], half - P["leaf_len"], half) # stands on the bed, free at +Y
89
+ root = rect(xf - face, xf + t / 2, half - P["leaf_len"] - 2 * P["leaf_t"], half - P["leaf_len"])
90
+ nose = Polygon(out(face - 0.2, zt), out(face, zt), out(tip, zt - 1.5 * P["nose"]), out(tip, zn), out(face - 0.2, zn - P["nose"] - 0.2), align=None)
91
+ box += extrude(leaf + root, zt) + extrude(Plane.XZ * nose, half, both=True) # nose underside is 45 degrees: catch face, and printable
92
+
93
+ fi, b = tip + gap, P["catch"] + gap # finger inner face clears the nose tip; barb reaches `catch` under the nose
94
+ zc = zn + P["latch_play"] # top of the barb's 45 degree catch face, parallel to the nose's
95
+ zb = zc - b - gap # bottom of the barb's flat tip; the lead-in ramp runs down from here
96
+ finger = Polygon(out(-t / 2, hb), out(fi, hb), out(fi, zc), out(fi - b, zc - b), out(fi - b, zb), out(fi, zb - 1.5 * b),
97
+ out(fi + P["finger_t"], zb - 1.5 * b), out(fi + P["finger_t"], hb + hl), out(-t / 2, hb + hl), align=None)
98
+ finger = extrude(Plane.XZ * finger, half + 1, both=True)
99
+ lid += fillet(finger.edges().filter_by(Axis.Z).group_by(Axis.X)[0], 1.0) # soft corners where the thumb lifts
100
+
101
+ return Compound([box, swing_open * lid])
@@ -0,0 +1,50 @@
1
+ """Fluted clamping knob that captures an M6 hex bolt head
2
+ Pattern: revolve a rounded 2D profile, then pattern a cutter round the axis (polar flutes) and cut the hex pocket
3
+ Modelled on: JW Winco GN 7336 hollow knurled knob, size 34 (https://www.jwwinco.com/en-us/products/2.2-Tensioning-clamping-with-handles/Knurled-knobs/GN-7336-Plastic-Hollow-Knurled-Knobs-without-Tapped-Insert)
4
+ Published sizes used: grip diameter d1 = 34, hub d3 = 16, height h1 = 21, bore d4 = 6.1, hexagon A/F = 10 (maker, URL above, converted from its inch table); M6 hex head across flats s = 10, head height k = 4 (ISO 4017, https://boltsparts.github.io/en/parts/standards/ISO4017.html)
5
+ Concept: A thumb knob that turns an ordinary M6 hex bolt into a clamping screw. The bolt drops in from the top, its head sits in the hex pocket and the thread leaves through the hub. Turning the knob drives the six flats; tightening pulls the head down onto the pocket floor, which is the full solid hub, so the clamp load goes straight through the hub into the work. Prints as modelled: hub on the bed, hex pocket UP, no supports, because the underside of the grip is a 45 degree cone and the pocket is open to the top. PETG or PLA, 4 walls. One body.
6
+ What makes this good: the crowned top and rounded rim sit in the palm, and eighteen finger-width flutes give grip without sharp teeth.
7
+ """
8
+ from build123d import *
9
+
10
+ P = {
11
+ "grip_d": 34.0, # d1, the diameter the fingers hold (maker)
12
+ "hub_d": 16.0, # d3, the narrow hub that bears on the work (maker)
13
+ "height": 21.0, # h1, overall (maker)
14
+ "bore_d": 6.1, # d4, through hole for the M6 thread (maker)
15
+ "hex_af": 10.0, # s, M6 head across flats (ISO 4017)
16
+ "head_k": 4.0, # k, M6 head height (ISO 4017)
17
+ "fit": 0.3, # print allowance added to the hex A/F and the bore diameter
18
+ "head_recess": 1.0, # how far the head sits below the crown, so the palm never feels it
19
+ "hub_h": 3.0, # straight hub before the 45 degree cone starts
20
+ "crown": 2.5, # rise of the domed top above the rim
21
+ "rim_round": 2.5, # radius on the rim's top and bottom corners
22
+ "flutes": 18, # grooves round the rim, about one per 6 mm of rim
23
+ "flute_r": 2.4, # radius of each groove cutter (a fingertip-sized scallop)
24
+ "flute_depth": 1.1, # how deep each groove bites into the rim
25
+ }
26
+
27
+
28
+ def build():
29
+ R, r_hub, H = P["grip_d"] / 2, P["hub_d"] / 2, P["height"]
30
+ z_cone = P["hub_h"] + (R - r_hub) # 45 degree underside: it rises as far as it widens, so it prints unsupported
31
+ z_rim = H - P["crown"]
32
+
33
+ # Half profile in (radius, height): crown arc that is flat at the axis, rim, 45 degree cone, hub with a bed chamfer.
34
+ crown = TangentArc((0, H), (R, z_rim), tangent=(1, 0))
35
+ side = Polyline((R, z_rim), (R, z_cone), (r_hub, P["hub_h"]), (r_hub, 0.6), (r_hub - 0.6, 0), (0, 0), (0, H))
36
+ profile = make_face([crown, side])
37
+ rim_corners = profile.vertices().sort_by(Axis.X)[-2:] # the two corners at the grip radius
38
+ profile = fillet(rim_corners, P["rim_round"]) # round them in 2D, before revolving
39
+ body = revolve(Plane.XZ * profile, Axis.Z)
40
+
41
+ # Pattern one groove cutter round the axis. Its centre is outside the rim so only a shallow scallop is cut.
42
+ pitch_r = R + P["flute_r"] - P["flute_depth"]
43
+ groove = Cylinder(P["flute_r"], 3 * H) # full height: it fades out down the cone and never reaches the hub
44
+ body -= [loc * groove for loc in PolarLocations(pitch_r, P["flutes"])]
45
+
46
+ # Hex pocket for the bolt head (open to the top) and the through hole for its thread.
47
+ floor_z = H - P["head_recess"] - P["head_k"]
48
+ pocket = extrude(RegularPolygon((P["hex_af"] + P["fit"]) / 2, 6, major_radius=False), H)
49
+ bore = Cylinder((P["bore_d"] + P["fit"]) / 2, 3 * H)
50
+ return body - Pos(0, 0, floor_z) * pocket - bore
@@ -0,0 +1,52 @@
1
+ """Ergonomic file handle with an oval palm swell
2
+ Pattern: loft through several sections of different shape (circle to ovals), then fillet the end into a dome
3
+ Modelled on: Bahco ERGO 9-485 oval file handle (https://www.klium.nl/en/bahco-9-485-06-10-oval-shaped-handle-ergo-for-medium-flat-and-semi-circular-files-diameter-6-mm-76671)
4
+ Published sizes used: tang bore = 6 for medium files (retailer, Bahco 9-485-06, URL above); length = 110 (maker, Facom MAN.2 wood file handle, https://www.facom.com/product/man2/28mm-file-and-rasp-wood-handle); power-grip handle diameter 30 to 50, about 40 best, and handle length at least 100 (CCOHS, https://ccohs.ca/oshanswers/ergonomics/handtools/tooldesign.html); the swell here is 36 x 30. Waist, collar, butt and tang depth are design choices.
5
+ Concept: A push-on handle for a medium hand file (6 mm tang). The round collar at the front stands in for a steel ferrule and stops the fingers; behind it a round waist for thumb and forefinger swells into an oval that fills the palm (oval, so the hand feels which way the file faces and it cannot roll), then narrows to a domed butt the heel of the hand pushes on. The file's tapered tang is heated and pressed into the tapered hole. Prints as modelled, STANDING on the collar, no supports: every layer is then a closed ring round the tang, so the tang wedging the hole open cannot split it, and the swell and dome need nothing under them. The cost is that bending at the waist pulls layers apart, the weak direction; a file mostly pushes along the handle, so the waist is kept 20 mm thick with 5 walls. For a tool you lever with, print it lying down with supports instead. PETG. One body.
6
+ What makes this good: every section is sized for a part of the hand, and the loft joins them in one smooth skin.
7
+ """
8
+ from build123d import *
9
+
10
+ P = {
11
+ "length": 110.0, # overall (Facom MAN.2)
12
+ "collar_d": 25.0, # front collar: finger stop and printed ferrule; also the foot it prints on
13
+ "collar_len": 10.0, # collar length
14
+ "waist_d": 20.0, # round waist for thumb and forefinger, just behind the collar
15
+ "swell_z": 66.0, # height of the palm swell above the collar end (where the palm closes)
16
+ "swell_w": 36.0, # palm swell width (CCOHS power grip 30 to 50)
17
+ "swell_t": 30.0, # palm swell thickness; less than the width so the hand can feel the file's angle
18
+ "butt_w": 18.0, # width of the end face before it is domed
19
+ "butt_t": 15.0, # thickness of the end face before it is domed
20
+ "dome_r": 6.5, # fillet that turns the end face into a dome for the heel of the hand
21
+ "tang_d": 6.0, # tang hole at the mouth (Bahco 9-485-06)
22
+ "tang_tip_d": 3.0, # tang hole at its far end: tangs taper
23
+ "tang_depth": 60.0, # tang hole depth
24
+ "fit": 0.3, # print allowance added to both tang hole diameters
25
+ }
26
+
27
+
28
+ def build():
29
+ L, z0 = P["length"], P["collar_len"]
30
+ zs = P["swell_z"]
31
+
32
+ # Sections up the handle: round waist, a first oval, the full palm swell, a shoulder, the small end face.
33
+ # Each one is a different shape; loft() skins them into one smooth body.
34
+ sections = [
35
+ Pos(0, 0, z0) * Circle(P["waist_d"] / 2),
36
+ Pos(0, 0, (z0 + zs) / 2) * Ellipse(P["swell_w"] * 0.37, P["swell_t"] * 0.40),
37
+ Pos(0, 0, zs) * Ellipse(P["swell_w"] / 2, P["swell_t"] / 2),
38
+ Pos(0, 0, (zs + L) / 2) * Ellipse(P["swell_w"] * 0.46, P["swell_t"] * 0.46),
39
+ Pos(0, 0, L) * Ellipse(P["butt_w"] / 2, P["butt_t"] / 2),
40
+ ]
41
+ grip = loft(sections)
42
+ grip = fillet(grip.edges().group_by(Axis.Z)[-1], P["dome_r"]) # dome the butt
43
+
44
+ # Front collar, rounded where the forefinger rests against it and chamfered where it meets the bed.
45
+ collar = Cylinder(P["collar_d"] / 2, z0, align=(Align.CENTER, Align.CENTER, Align.MIN))
46
+ collar = fillet(collar.edges().group_by(Axis.Z)[-1], 2.0)
47
+ collar = chamfer(collar.edges().group_by(Axis.Z)[0], 0.8)
48
+
49
+ # Tapered tang hole, open at the collar end; its narrow top closes like a cone, so it prints unsupported.
50
+ hole = Cone((P["tang_d"] + P["fit"]) / 2, (P["tang_tip_d"] + P["fit"]) / 2, P["tang_depth"],
51
+ align=(Align.CENTER, Align.CENTER, Align.MIN))
52
+ return grip + collar - hole
@@ -0,0 +1,92 @@
1
+ """One-piece desk phone stand (swan neck, leaning back, two hooks, cable opening)
2
+ Pattern: loft rounded sections of changing width along a filleted spine (waisted neck into a broad back), then add parts in a tilted Plane
3
+ Modelled on: Lamicall S1 desk phone stand (https://thegadgetflow.com/product/lamicall-s1-smartphone-dock/)
4
+ Published sizes used: 0.74 in (18.8 mm) = S1 cradle depth (press listing, URL above); iPhone 18 Pro Max 163.4 x 78.0 x 8.75 mm, 249 g (maker, https://support.apple.com/148591); iPhone Duo closed 117.8 x 84.1 x 11.3 mm, open 117.8 x 164.6 x 5.2 mm, 254 g (maker, https://support.apple.com/en-us/148588); every other size is a design choice
5
+ Concept: Holds a phone upright or sideways at a reading angle while it charges. The phone's bottom edge sits on two hooks and its back lies on a flat panel leaning 25 degrees; the charging plug hangs between the hooks and the cable leaves through the slot in the neck. The weight runs down the swan neck into the middle of a wide foot: with the tallest iPhone (163.4 mm, 249 g) upright its centre of mass lands about 45 mm in front of the heel and 60 mm behind the toe, and the 18.8 mm cradle takes the thickest (11.3 mm, 254 g) with a case. Prints as modelled, foot on the bed, no supports: the neck leans 35 degrees and the hook undersides 40 degrees from vertical. PLA or PETG, 3 walls; add stick-on rubber dots under the foot.
6
+ What makes this good: one continuous lofted spine that narrows to a neck and spreads into the back, so it reads as a designed object, not a bent plate.
7
+ """
8
+ from math import cos, radians, sin, tan
9
+
10
+ from build123d import *
11
+
12
+ P = {
13
+ "lean_deg": 25.0, # back leans this far from vertical (65 degree viewing angle)
14
+ "neck_deg": 55.0, # neck rises forward at this angle above the desk (printable overhang)
15
+ "nose_h": 26.0, # height of the bend where neck turns into back
16
+ "nose_y": -22.0, # how far forward of the origin that bend is
17
+ "bend_r": 14.0, # radius of that bend
18
+ "seat_up": 23.0, # hooks sit this far up the back from the bend corner
19
+ "back_len": 80.0, # back panel above the hooks (reaches the middle of a 163.4 mm phone)
20
+ "thick": 5.0, # spine thickness
21
+ "neck_w": 34.0, # narrowest width, at the neck (leaves 10 mm each side of the cable slot)
22
+ "back_w": 58.0, # widest width, behind the phone (phone is 78.0 wide)
23
+ "cradle": 18.8, # hook depth, front of back panel to lip (published S1 cradle)
24
+ "lip_h": 9.0, # lip height above the seat
25
+ "lip_t": 4.0, # lip and seat thickness
26
+ "hook_w": 13.0, # width of each hook
27
+ "cable_gap": 20.0, # clear gap between the hooks for the plug
28
+ "slot_len": 30.0, # cable slot through the neck, measured down the back
29
+ "foot_w": 82.0, # foot width (wider than the phone)
30
+ "foot_d": 106.0, # foot depth: toe ahead of the lip, heel behind the phone's centre of mass
31
+ "foot_y": 8.0, # foot centre, behind the origin
32
+ "foot_t": 5.0, # foot thickness
33
+ "root_fillet": 3.0, # blend of the neck into the foot
34
+ "edge_r": 1.9, # rounding on hooks and panel top (the 4 mm lip becomes a full round)
35
+ }
36
+
37
+
38
+ def build():
39
+ lean, neck, t = radians(P["lean_deg"]), radians(P["neck_deg"]), P["thick"]
40
+ up = Vector(0, sin(lean), cos(lean)) # direction up the back panel
41
+ out = Vector(0, -cos(lean), sin(lean)) # direction out of its front face, towards the phone
42
+ corner = Vector(0, P["nose_y"], P["nose_h"])
43
+ root = corner + Vector(0, 1 / tan(neck), -1) * (P["nose_h"] - P["foot_t"] / 2) # starts inside the foot
44
+ top = corner + up * (P["seat_up"] + P["back_len"])
45
+
46
+ # spine: neck up and forward from the foot, one filleted bend, then the straight leaning back
47
+ spine = Polyline(root, corner, top)
48
+ spine = fillet(spine.vertices(), P["bend_r"])
49
+
50
+ # (position along the spine 0..1, width there): flared root, narrow neck, broad back
51
+ # (the last station lies beyond the top, so the panel ends mid-curve with rounded shoulders)
52
+ stations = [(0, 48), (0.18, P["neck_w"]), (0.45, P["back_w"]), (0.8, P["back_w"]), (1.25, P["back_w"] - 40)]
53
+
54
+ def width_at(u): # smooth blend between neighbouring stations
55
+ for (u0, w0), (u1, w1) in zip(stations, stations[1:]):
56
+ if u <= u1:
57
+ k = (u - u0) / (u1 - u0)
58
+ return w0 + (w1 - w0) * (3 * k**2 - 2 * k**3)
59
+
60
+ # many evenly spaced sections keep the loft on the spine, so the panel stays flat for the phone
61
+ sections = [Plane(spine @ (i / 24), x_dir=(1, 0, 0), z_dir=spine % (i / 24))
62
+ * RectangleRounded(width_at(i / 24), t, t * 0.45) for i in range(25)]
63
+ back = loft(sections)
64
+ back = fillet(back.faces().sort_by(Axis.Z)[-1].edges(), P["edge_r"]) # soft top edge
65
+
66
+ # foot: a pebble-shaped pad, the only thing touching the bed
67
+ foot = Pos(0, P["foot_y"]) * extrude(RectangleRounded(P["foot_w"], P["foot_d"], P["foot_w"] * 0.4), P["foot_t"])
68
+ foot = fillet(foot.edges().group_by(Axis.Z)[-1], P["foot_t"] * 0.6)
69
+
70
+ # hooks, drawn in the side plane of the back: x = up the back, y = out towards the phone
71
+ seat = corner + up * P["seat_up"] + out * (t / 2)
72
+ side = Plane(seat, x_dir=up, z_dir=(1, 0, 0))
73
+ reach = P["cradle"] + P["lip_t"]
74
+ hook_profile = side * Polygon(
75
+ (0, -t / 2), (0, P["cradle"]), (P["lip_h"], P["cradle"]), (P["lip_h"], reach),
76
+ (-P["lip_t"], reach), (-P["lip_t"] - reach * tan(lean), -t / 2), align=None)
77
+ hook = extrude(hook_profile, P["hook_w"] / 2, both=True)
78
+ # round the profile first (full-round lip), then the two flanks with a smaller radius:
79
+ # equal fillets meeting at a corner make a spherical patch that does not export watertight
80
+ hook = fillet(hook.edges().filter_by(Axis.X), P["edge_r"])
81
+ hook = fillet(hook.edges().filter_by(Axis.X, reverse=True), P["edge_r"] / 2)
82
+ hook = Pos((P["cable_gap"] + P["hook_w"]) / 2, 0, 0) * hook
83
+ body = foot + back
84
+ # blend the neck into the foot: the seam is the only spline edge on the foot's top face
85
+ seam = body.edges().filter_by_position(Axis.Z, P["foot_t"] - 0.01, P["foot_t"] + 0.01).filter_by(GeomType.BSPLINE)
86
+ body = fillet(seam, P["root_fillet"])
87
+ body += hook + mirror(hook, Plane.YZ)
88
+
89
+ # cable slot through the neck between the hooks, from the seat downwards
90
+ rest = Plane(seat, x_dir=(1, 0, 0), z_dir=out)
91
+ slot = extrude(SlotOverall(P["slot_len"], P["cable_gap"] - 6, rotation=90), 2 * t, both=True)
92
+ return body - rest * Pos(0, 3 - P["slot_len"] / 2) * slot