bambu-printer-mcp 1.1.91 → 1.1.93

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 (69) hide show
  1. package/CONTRIBUTORS.md +2 -0
  2. package/README.md +8 -4
  3. package/dist/bambu-native.js +1 -1
  4. package/dist/cad/contracts.js +16 -7
  5. package/dist/cad/examples.d.ts +2 -1
  6. package/dist/cad/examples.js +13 -10
  7. package/dist/cad/serial.d.ts +1 -1
  8. package/dist/cad/serial.js +4 -6
  9. package/dist/cad-engine.js +17 -12
  10. package/dist/counterpart/info.d.ts +2 -0
  11. package/dist/counterpart/info.js +6 -1
  12. package/dist/counterpart/remote.js +1 -0
  13. package/dist/counterpart/schemas.d.ts +5 -0
  14. package/dist/counterpart/schemas.js +1 -0
  15. package/dist/counterpart/self-check.d.ts +79 -0
  16. package/dist/counterpart/self-check.js +163 -0
  17. package/dist/index.js +50 -24
  18. package/dist/printers/bambu.d.ts +6 -0
  19. package/dist/printers/bambu.js +59 -25
  20. package/dist/printers/report-merge.d.ts +12 -0
  21. package/dist/printers/report-merge.js +46 -0
  22. package/dist/safety/limits.d.ts +6 -0
  23. package/dist/safety/limits.js +8 -0
  24. package/dist/safety/print-file.js +2 -2
  25. package/dist/safety/printer-state.d.ts +4 -0
  26. package/dist/safety/printer-state.js +14 -1
  27. package/dist/stl/stl-manipulator.js +79 -20
  28. package/dist/studio-print-options.d.ts +9 -0
  29. package/dist/studio-print-options.js +34 -2
  30. package/dist/tool-annotations.js +1 -0
  31. package/package.json +6 -1
  32. package/src/bambu-native.ts +1 -1
  33. package/src/cad/contracts.ts +17 -7
  34. package/src/cad/examples/bag_clip.py +1 -0
  35. package/src/cad/examples/bistable_clicker.py +1 -0
  36. package/src/cad/examples/broom_grip.py +61 -0
  37. package/src/cad/examples/cable_clip.py +1 -0
  38. package/src/cad/examples/chainmail.py +1 -0
  39. package/src/cad/examples/desk_clamp_hook.py +91 -0
  40. package/src/cad/examples/desk_edge_cable_holder.py +55 -0
  41. package/src/cad/examples/drawer_divider.py +56 -0
  42. package/src/cad/examples/hinged_box.py +1 -0
  43. package/src/cad/examples/knurled_knob.py +1 -0
  44. package/src/cad/examples/loft_handle.py +1 -0
  45. package/src/cad/examples/organizer_tray.py +41 -0
  46. package/src/cad/examples/phone_stand.py +1 -0
  47. package/src/cad/examples/plant_pot.py +53 -0
  48. package/src/cad/examples/shelf_bracket.py +53 -0
  49. package/src/cad/examples/swept_hook.py +1 -0
  50. package/src/cad/examples/threaded_jar.py +1 -0
  51. package/src/cad/examples/trigger_capo.py +1 -0
  52. package/src/cad/examples/wall_hook.py +1 -0
  53. package/src/cad/examples.ts +13 -10
  54. package/src/cad/geometry.py +6 -0
  55. package/src/cad/serial.ts +4 -6
  56. package/src/cad-engine.ts +9 -3
  57. package/src/counterpart/info.ts +7 -1
  58. package/src/counterpart/remote.ts +1 -0
  59. package/src/counterpart/schemas.ts +3 -1
  60. package/src/counterpart/self-check.ts +164 -0
  61. package/src/index.ts +48 -20
  62. package/src/printers/bambu.ts +57 -24
  63. package/src/printers/report-merge.ts +48 -0
  64. package/src/safety/limits.ts +8 -0
  65. package/src/safety/print-file.ts +2 -2
  66. package/src/safety/printer-state.ts +13 -1
  67. package/src/stl/stl-manipulator.ts +75 -14
  68. package/src/studio-print-options.ts +33 -2
  69. package/src/tool-annotations.ts +1 -0
@@ -0,0 +1,91 @@
1
+ """Clamp-on desk headphone hook (rounded S frame, printed thumbscrew, hook hanging under the desk)
2
+ Use for: hanging headphones, a bag or a cable coil from a desk, shelf or table edge without tape or screws; any clamp that grips a board 18 to 30 mm thick with a printed screw
3
+ Pattern: one rounded section swept along a filleted S path (top jaw, spine, lower jaw, drop, hook, tip); a boss for the nut thread; the screw and nut threads are one section on one helix, the nut's moved out by the fit; "pose" shows it clamped or on the plate
4
+ Modelled on: Brainwavz Hoist headphone hanger with adjustable clamp (https://brainwavzaudio.com/de/products/brainwavz-hoist-headphone-hanger-with-adjustable-clamp)
5
+ Published sizes used: 5 to 40 mm = desk thickness the bought clamp takes, 50 mm = its hanger width (maker's listing, URL above); this printed one is sized for 18 to 30 mm desks and every other size is a design choice
6
+ Concept: Hangs a headset under the desk edge with nothing stuck or screwed to the desk. 2 bodies: the frame and the thumbscrew. Frame as used: the desk edge is at x = 0 and the desk runs towards +x; the top jaw lies on the desk, the spine passes in front of the edge, the lower jaw runs back under the desk and carries the threaded boss, then the frame drops and comes forward again as the hook, with an upturned tip at the front so the headband lifts on and off from where you sit. The screw comes up through the boss and presses the underside of the desk, so one frame takes any desk from 18 to 30 mm; the headphones' weight pulls the frame down onto the top jaw, so the clamp only has to stop it sliding. The knob hangs in the hook's opening, above where the headband rests. The frame is printed on its side so every layer holds the whole S and no bend is a layer joint; its threaded hole then lies level, which a 4 mm pitch, 45 degree thread survives without supports. The screw prints standing on its knob. Stick felt on the top jaw and the screw tip. PETG or PLA, 4 walls.
7
+ What makes this good: the whole frame is a single swept bar with large bends, so it reads as a bent-steel hanger, not a bracket, and the load goes round the bends inside the layers.
8
+ """
9
+ from build123d import *
10
+
11
+ P = {
12
+ "pose": "plate", # "plate": as printed, frame on its side and screw on its knob; "assembled": clamped on desk_t, standing as used (the screw is then off the plate, which cad_run notes: that pose is for looking, not printing)
13
+ "desk_t": 25.0, # the desk it is shown clamped on (assembled pose only)
14
+ "opening": 32.0, # between the jaws; takes desks up to 30 mm with a felt pad
15
+ "min_desk": 18.0, # thinnest desk the screw still reaches
16
+ "reach": 46.0, # jaws over the desk, from the desk edge
17
+ "bar_t": 10.0, # frame bar thickness, in the bending direction
18
+ "width": 26.0, # frame width = what the headband rests on
19
+ "edge_r": 3.0, # rounding of the bar's four long edges
20
+ "bend_r": 13.0, # centreline radius of every bend
21
+ "drop": 84.0, # lower jaw down to the hook arm (centrelines): knob plus a padded headband
22
+ "hook_len": 60.0, # hook arm, back towards the desk edge
23
+ "tip_h": 24.0, # upturned tip, centreline rise
24
+ "boss_h": 18.0, # threaded length through the lower jaw and its boss (4.5 turns)
25
+ "boss_l": 28.0, # boss length along the jaw
26
+ "thread_d": 14.0, # screw outside diameter
27
+ "pitch": 4.0, # coarse, so it prints lying level in the frame
28
+ "thread_depth": 1.2, # 45 degree flanks
29
+ "crest": 0.8, # flat on the thread crest
30
+ "fit": 0.4, # radial clearance, screw to nut
31
+ "knob_d": 32.0,
32
+ "knob_h": 11.0,
33
+ "flutes": 8,
34
+ "gap_on_plate": 10.0, # frame to screw on the plate
35
+ "print_in_place": False, # two parts assembled by hand: only touching is a problem
36
+ }
37
+
38
+
39
+ def thread(root_r, crest_r, z0, length):
40
+ """A 45 degree trapezoid swept along a helix about Z, from z0. root_r > crest_r makes the nut's thread."""
41
+ depth = crest_r - root_r
42
+ half_root = P["crest"] / 2 + abs(depth)
43
+ bury = 0.3 if depth > 0 else -0.3 # the flanks run on into the wall: no section corner lies on the wall's surface
44
+ section = Polygon((root_r - bury, -half_root - 0.3), (crest_r, -P["crest"] / 2),
45
+ (crest_r, P["crest"] / 2), (root_r - bury, half_root + 0.3), align=None)
46
+ return Pos(0, 0, z0) * sweep(Plane.XZ * section, path=Helix(P["pitch"], length, (root_r + crest_r) / 2), is_frenet=True)
47
+
48
+
49
+ def build():
50
+ t, w, r = P["bar_t"], P["width"], P["bend_r"]
51
+ major, root = P["thread_d"] / 2, P["thread_d"] / 2 - P["thread_depth"]
52
+ low = -P["opening"] - t / 2 # lower jaw centreline; the desk top is y = 0
53
+ x_spine = -(r - t / 2) - t / 2 # the inside of the bend ends at the desk edge
54
+ x_screw = P["reach"] - P["boss_l"] / 2
55
+
56
+ # frame, drawn lying on the bed: X into the desk, Y up as used, Z across the width
57
+ path = Polyline((P["reach"], t / 2), (x_spine, t / 2), (x_spine, low), (P["reach"] + r, low),
58
+ (P["reach"] + r, low - P["drop"]), (P["reach"] + r - P["hook_len"], low - P["drop"]),
59
+ (P["reach"] + r - P["hook_len"], low - P["drop"] + P["tip_h"]))
60
+ path = Pos(0, 0, w / 2) * fillet(path.vertices(), r)
61
+ frame = sweep(Plane(path @ 0, x_dir=(0, 0, 1), z_dir=path % 0) * RectangleRounded(w, t, P["edge_r"]), path=path)
62
+ ends = [frame.faces().sort_by_distance(path @ u)[0] for u in (0, 1)]
63
+ frame = fillet(ends[0].edges() + ends[1].edges(), P["edge_r"] - 0.5) # soft jaw end and hook tip; a radius over edge_r exports open
64
+ boss = Pos(x_screw, -P["opening"] - P["boss_h"] / 2) * RectangleRounded(P["boss_l"], P["boss_h"], 5)
65
+ frame += extrude(boss, w)
66
+
67
+ # threads in the screw's own frame: axis Z, origin on the lower jaw's top face. Plain hole first, then the
68
+ # nut's thread added to its wall (a thread subtracted from the cutter does not cut)
69
+ z_nut = -P["boss_h"] + 2.5
70
+ to_frame = Pos(x_screw, -P["opening"], w / 2) * Rot(-90, 0, 0)
71
+ frame -= to_frame * Cylinder(major + P["fit"], 3 * P["boss_h"])
72
+ frame += to_frame * thread(major + P["fit"], root + P["fit"], z_nut, P["boss_h"] - 5)
73
+
74
+ # screw: fluted knob, threaded shank long enough for the thinnest desk, tip and thread ends cut to a chamfer
75
+ shank = P["boss_h"] + P["opening"] - P["min_desk"] + 4
76
+ kh = P["knob_h"]
77
+ knob = fillet(Cylinder(P["knob_d"] / 2, kh, align=(Align.CENTER, Align.CENTER, Align.MIN)).edges(), 2.0)
78
+ flute = Pos(P["knob_d"] / 2 + 1.5, 0, 0) * Cylinder(4.0, kh, align=(Align.CENTER, Align.CENTER, Align.MIN))
79
+ knob -= [Rot(0, 0, i * 360 / P["flutes"]) * flute for i in range(P["flutes"])]
80
+ # the envelope is wider than the thread (a surface shared with the crest breaks the cut) and chamfers the tip
81
+ envelope = chamfer(Cylinder(major + 0.6, shank + 1, align=(Align.CENTER, Align.CENTER, Align.MIN)).edges().group_by(Axis.Z)[-1], P["thread_depth"] + 1.2)
82
+ screw = knob + Pos(0, 0, kh - 1) * ((Cylinder(root, shank + 1, align=(Align.CENTER, Align.CENTER, Align.MIN))
83
+ + thread(root, major, 2.0, shank - 3)) & envelope)
84
+
85
+ if P["pose"] == "plate":
86
+ return Compound([frame, Pos(P["reach"] + r + P["knob_d"] / 2 + P["gap_on_plate"], 0, 0) * screw])
87
+ # assembled: tip on the underside of the desk; the turn that puts the screw's ridge in the nut's groove
88
+ lift = P["opening"] - P["desk_t"] - (kh + shank)
89
+ turn = 360 * (lift + kh + 1 - z_nut) / P["pitch"] + 180
90
+ used = Rot(90, 0, 0) * Compound([frame, to_frame * Pos(0, 0, lift) * Rot(0, 0, turn) * screw])
91
+ return Pos(0, 0, -used.bounding_box().min.Z) * used
@@ -0,0 +1,55 @@
1
+ """Stick-on desk-edge cable holder (five sprung slots in one small rail)
2
+ Use for: keeping several charging cables (USB-C, Lightning, earphone leads) side by side at a desk edge, bedside or shelf so the plugs do not fall behind; any multi-slot stick-on cable organiser
3
+ Pattern: a comb drawn in the plane its arms bend in: per slot, two tapered spring arms with round beads over a cradled seat, patterned along a base with rounded end blocks; extruded to the rail's depth and its outline chamfered
4
+ Modelled on: Orico CBS5 5-slot self-adhesive silicone desk cable holder (https://www.scom.hu/ORICO-CBS5-GY-Cable-Organizer-Grey)
5
+ Published sizes used: 96 x 20 x 12 mm = the bought holder's length, depth and height, for cables under 5 mm (retailer listing, URL above); this rigid one is shorter because its slots sit closer, and the slot sizes are design choices
6
+ Concept: A small rail taped to the desk top at its edge (or to the edge's front face) that parks five cables. Each cable is pushed down between two round beads into a seat a little bigger than itself: it slides freely, cannot lift out, and its plug is too big to pull back through, so the end stays on the desk. The bought one is soft silicone, which a printer cannot copy, so each slot has two thin arms that spring apart instead: 12 mm long and 3 lines thick at the tip, they let a 5 mm cable through the 3.2 mm mouth at about 1.6 percent strain, and the script prints that figure for whatever sizes it is given. It holds cables from 3.4 to 5.0 mm; a thinner one lifts out. The arms taper to the base so they bend along their length, not at the root, and the gaps beside them are what lets them move. This one is rightly an extrusion: it is printed standing on its front face, comb outline on the bed, so every arm bends within its layers and none can snap along a layer line; printed tape-face down the arms would be weak. No supports. PETG, 0.2 mm layers; 12.7 mm foam tape on the flat underside.
7
+ What makes this good: it is as small as the thing you buy (about 68 x 16 x 16 mm for five cables), with no clamp or screw, and the spring is drawn and printed in the plane it bends in.
8
+ """
9
+ from build123d import *
10
+
11
+ P = {
12
+ "slots": 5,
13
+ "cable_max": 5.0, # thickest cable it takes
14
+ "seat_clear": 0.4, # seat is this much bigger than cable_max so every cable slides
15
+ "mouth": 3.2, # gap between the beads; holds cables from about 3.4 mm
16
+ "arm_tip_t": 1.26, # arm thickness under the bead: 3 lines of 0.42
17
+ "arm_root_t": 1.7, # arm thickness at the base: the taper spreads the bending along the arm
18
+ "pitch": 10.6, # slot to slot
19
+ "base_t": 3.0, # base under the seats (the taped strip)
20
+ "cradle": 1.0, # the seat is sunk this far into the base
21
+ "height": 16.0, # underside to the top of the beads; taller means longer, easier arms
22
+ "depth": 16.0, # along the cable = height off the bed as printed; room for 12.7 mm tape
23
+ "end_w": 7.0, # solid block at each end
24
+ "relief": 1.4, # gap between the outer arms and the end blocks
25
+ "edge": 0.6, # chamfer round both faces of the comb: no sharp edge on a cable jacket
26
+ }
27
+
28
+
29
+ def build():
30
+ seat_r = (P["cable_max"] + P["seat_clear"]) / 2
31
+ h, tip, root_t = P["height"], P["arm_tip_t"], P["arm_root_t"]
32
+ bead_r = (seat_r + tip - P["mouth"] / 2) / 2 # the bead spans from the mouth to the arm's outer face
33
+ seat_y = P["base_t"] + seat_r - P["cradle"] # seat centre
34
+ half = (P["slots"] - 1) * P["pitch"] / 2 + seat_r + root_t + P["relief"] + P["end_w"]
35
+
36
+ comb = Pos(0, P["base_t"] / 2) * Rectangle(2 * half, P["base_t"])
37
+ for side in (-1, 1): # end blocks, outer corners rounded
38
+ block = Pos(side * (half - P["end_w"] / 2), h / 2) * Rectangle(P["end_w"], h)
39
+ comb += fillet(block.vertices().sort_by(Axis.X)[2 if side > 0 else 0:][:2], P["end_w"] * 0.45)
40
+ for i in range(P["slots"]):
41
+ x = (i - (P["slots"] - 1) / 2) * P["pitch"]
42
+ for side in (-1, 1): # one tapered arm and its bead; the inner face is straight
43
+ pts = [(side * seat_r, 0), (side * (seat_r + root_t), 0), (side * (seat_r + tip), h - bead_r), (side * seat_r, h - bead_r)]
44
+ arm = Polygon(*pts[::side], align=None) # anticlockwise on both sides, so every face extrudes up
45
+ comb += Pos(x, 0) * (arm + Pos(side * (P["mouth"] / 2 + bead_r), h - bead_r) * Circle(bead_r))
46
+ comb -= Pos(x, seat_y) * Circle(seat_r) # the cradle in the base
47
+
48
+ # the spring, worked out: each arm is a cantilever from the base to its bead, pushed out by half of (cable - mouth)
49
+ arm_len = h - bead_r - P["base_t"]
50
+ t_base = root_t - (root_t - tip) * P["base_t"] / (h - bead_r)
51
+ strain = 1.5 * t_base * (P["cable_max"] - P["mouth"]) / 2 / arm_len ** 2
52
+ print(f"arm strain while the thickest cable passes the mouth: {100 * strain:.1f} % (keep to about 2 % for PETG)")
53
+
54
+ rail = extrude(comb, P["depth"])
55
+ return chamfer(rail.edges().group_by(Axis.Z)[0] + rail.edges().group_by(Axis.Z)[-1], P["edge"])
@@ -0,0 +1,56 @@
1
+ """Interlocking drawer divider grid (slotted strips that cross in half-laps)
2
+ Use for: dividing a drawer, box or shelf into compartments for cutlery, tools, socks or stationery; any grid of flat strips that slot together; flat parts cut to a measured space
3
+ Pattern: one function makes a strip from its length and slot count; every strip is a flat plate with rounded corners and half-depth slots with a lead-in; the set is laid out on the plate from the drawer's inside sizes, and "pose" stands it up as the grid
4
+ Modelled on: slotted plastic drawer divider strips, as in the 2 in high clip-and-strip sets (https://www.med-supply.net/products/divider-strip-only-2-inch)
5
+ Published sizes used: 2 in (50.8 mm) high x 21 1/4 in long = a bought strip (retailer listing, URL above), which is cut to the drawer; these are printed to length, so the drawer's inside length, width and height are the person's measurements
6
+ Concept: A grid that drops into a drawer and makes compartments. The long strips have slots cut down from the top edge and the cross strips have slots cut up from the bottom edge, each to half the height, so they cross flush like an egg crate and hold each other upright; the drawer's walls stop the grid sliding. Strips are 1 mm shorter than the drawer so they go in without bowing its sides. The slot is the strip thickness plus 0.3 mm: a hand push fit that still comes apart. Each strip is a plate, so it is drawn flat and extruded to its thickness, and printed lying down: the layers then run the length of the strip and it cannot split along its slots. 6 lines (2.4 mm) thick is stiff enough at 45 mm high. Measure the drawer at the bottom, where it is narrowest. PLA or PETG, no supports; a drawer longer than the bed needs each long strip in two halves butted at a cross strip.
7
+ What makes this good: it is sized from the three numbers a person can measure, every strip comes from one function, and the slots, not glue, do the holding.
8
+ """
9
+ from build123d import *
10
+
11
+ P = {
12
+ "drawer_l": 240.0, # inside length of the drawer (the person's measurement)
13
+ "drawer_w": 150.0, # inside width
14
+ "height": 45.0, # strip height: a few mm under the drawer's inside height
15
+ "long_strips": 2, # strips running the length
16
+ "cross_strips": 3, # strips running the width
17
+ "t": 2.4, # strip thickness: 6 lines of 0.4
18
+ "fit": 0.3, # slot is this much wider than the strip
19
+ "end_gap": 1.0, # strips are this much shorter than the drawer
20
+ "corner_r": 4.0, # rounded top corners
21
+ "lead_in": 1.2, # flare at the mouth of each slot
22
+ "gap_on_plate": 4.0,
23
+ "pose": "plate", # "plate": every strip lying flat, as printed; "assembled": the grid standing as it sits in the drawer
24
+ "print_in_place": False, # assembled, the strips sit in each other's slots at the fit: only touching is a problem
25
+ }
26
+
27
+
28
+ def strip(length, slots, from_top):
29
+ """A flat strip lying on the bed, `slots` equally spaced half-depth slots cut from its top or bottom edge."""
30
+ h, w = P["height"], P["t"] + P["fit"]
31
+ plate = Rectangle(length, h)
32
+ plate = fillet(plate.vertices().group_by(Axis.Y)[-1], P["corner_r"]) # top corners only: the bottom sits square
33
+ edge = h / 2 if from_top else -h / 2
34
+ inward = -1 if from_top else 1
35
+ for i in range(slots):
36
+ x = length * (i + 1) / (slots + 1) - length / 2
37
+ cut = Pos(x, edge + inward * h / 4) * Rectangle(w, h / 2 + 0.6) # 0.3 past half way, so the laps seat fully
38
+ pts = [(x - w / 2 - P["lead_in"], edge), (x + w / 2 + P["lead_in"], edge), (x + w / 2, edge + inward * P["lead_in"] * 2),
39
+ (x - w / 2, edge + inward * P["lead_in"] * 2)]
40
+ plate -= cut + Polygon(*pts[::-inward], align=None)
41
+ return Pos(0, h / 2) * extrude(plate, P["t"])
42
+
43
+
44
+ def build():
45
+ long_l, cross_l = P["drawer_l"] - P["end_gap"], P["drawer_w"] - P["end_gap"]
46
+ parts = [strip(long_l, P["cross_strips"], True) for _ in range(P["long_strips"])]
47
+ parts += [strip(cross_l, P["long_strips"], False) for _ in range(P["cross_strips"])]
48
+ if P["pose"] == "plate":
49
+ step = P["height"] + P["gap_on_plate"]
50
+ return Compound([Pos(-(long_l - s.bounding_box().size.X) / 2, i * step, 0) * s for i, s in enumerate(parts)])
51
+ # assembled: stand each strip up (its Y becomes Z), long strips along X, cross strips along Y, each centred in its slot
52
+ up = Rot(90, 0, 0) * Pos(0, 0, -P["t"] / 2)
53
+ longs = [Pos(0, cross_l * (j + 1) / (P["long_strips"] + 1) - cross_l / 2, 0) * up * parts[j] for j in range(P["long_strips"])]
54
+ crosses = [Pos(long_l * (i + 1) / (P["cross_strips"] + 1) - long_l / 2, 0, 0) * Rot(0, 0, 90) * up * parts[P["long_strips"] + i]
55
+ for i in range(P["cross_strips"])]
56
+ return Compound(longs + crosses)
@@ -1,4 +1,5 @@
1
1
  """Hinged pill and parts box with a snap latch, printed in place
2
+ Use for: a small box or case with a hinged, latching lid for pills, parts, cards or earbuds
2
3
  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
4
  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
5
  Published sizes used: none published; sizes are design choices
@@ -1,4 +1,5 @@
1
1
  """Fluted clamping knob that captures an M6 hex bolt head
2
+ Use for: a knob, thumbwheel or handwheel that takes a bought bolt or nut; replacing a lost appliance or jig knob
2
3
  Pattern: revolve a rounded 2D profile, then pattern a cutter round the axis (polar flutes) and cut the hex pocket
3
4
  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
5
  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)
@@ -1,4 +1,5 @@
1
1
  """Ergonomic file handle with an oval palm swell
2
+ Use for: a handle or grip for a file, tool, drawer or lid; anything a hand closes round
2
3
  Pattern: loft through several sections of different shape (circle to ovals), then fillet the end into a dome
3
4
  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
5
  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.
@@ -0,0 +1,41 @@
1
+ """Drawer organiser tray (tapered bin with rounded corners, scooped floor and one divider)
2
+ Use for: a tray, bin, tub or caddy for small things in a drawer, on a desk or a shelf (pens, cutlery, make-up, screws, chargers); any open box sized to a measured space
3
+ Pattern: loft a rounded rectangle up to a larger one for the tapered outside, cut a second loft for the inside, fillet the inside floor edge before the cut; a divider trimmed to the inside by intersecting it with the outside
4
+ Modelled on: madesmart Classic 9.75 x 3.75 in drawer organiser tray (https://www.canadiantire.ca/en/pdp/p-1423398p.html)
5
+ Published sizes used: 9.75 x 3.75 x 2.13 in (248 x 95 x 54 mm) = the bought tray's outside length, width and height (retailer listing, URL above); the taper, corner radius, wall and divider are design choices
6
+ Concept: An open tray that sits in a drawer and keeps one kind of thing together. What makes the bought one pleasant is all in the shape: the walls lean out about 3 degrees so trays nest and fingers get in, the corners are round in plan so nothing lodges in them, and the floor curves up into the walls so a coin or a screw slides up and out under one finger instead of hiding in a square corner. One divider makes a short compartment for small things; it is the same thickness as the walls and joins them along its whole height. Printed upright as modelled, floor on the bed, no supports: the walls lean outwards by far less than 45 degrees. The walls are 4 lines (1.6 mm), stiff enough at this height because the rounded corners and the divider brace them. PLA or PETG, 0.2 mm layers. Size it from the drawer's inside width and the things' length, 1 mm under the space it goes into.
7
+ What makes this good: the taper, the round plan corners and the scooped floor are the whole difference between a tray and a box, and each is one operation here.
8
+ """
9
+ from build123d import *
10
+
11
+ P = {
12
+ "length": 248.0, # outside, at the rim (published)
13
+ "width": 95.0, # outside, at the rim (published)
14
+ "height": 54.0, # outside (published)
15
+ "taper": 3.0, # each side is this much smaller at the floor (about 3 degrees)
16
+ "corner_r": 14.0, # plan corner radius at the rim
17
+ "wall": 1.6, # 4 lines of 0.4
18
+ "floor": 1.2,
19
+ "scoop_r": 8.0, # radius where the floor curves up into the walls
20
+ "divider_at": 0.3, # divider position along the length (0 to 1); 0 for none
21
+ }
22
+
23
+
24
+ def shell_loft(inset, z0):
25
+ """The tray's tapered shape, `inset` smaller all round, from height z0 to the rim."""
26
+ l, w, r, h = P["length"] - 2 * inset, P["width"] - 2 * inset, P["corner_r"] - inset, P["height"]
27
+ shrink = 2 * P["taper"] * (1 - z0 / h) # the taper at height z0
28
+ return loft([Plane.XY.offset(z0) * RectangleRounded(l - shrink, w - shrink, r - P["taper"] * 0.5),
29
+ Plane.XY.offset(h) * RectangleRounded(l, w, r)])
30
+
31
+
32
+ def build():
33
+ outside = shell_loft(0, 0)
34
+ inside = shell_loft(P["wall"], P["floor"])
35
+ inside = fillet(inside.edges().group_by(Axis.Z)[0], P["scoop_r"]) # the scoop, made on the plain inside shape
36
+ tray = outside - inside
37
+ if P["divider_at"] > 0:
38
+ x = (P["divider_at"] - 0.5) * P["length"]
39
+ wall = Pos(x, 0, P["height"] / 2) * Box(P["wall"], P["width"], P["height"])
40
+ tray += wall & outside # trimmed to the tapered outside, so it meets both walls
41
+ return tray
@@ -1,4 +1,5 @@
1
1
  """One-piece desk phone stand (swan neck, leaning back, two hooks, cable opening)
2
+ Use for: propping a phone or tablet on a desk or bedside; any stand that leans a flat device back at a viewing angle
2
3
  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
4
  Modelled on: Lamicall S1 desk phone stand (https://thegadgetflow.com/product/lamicall-s1-smartphone-dock/)
4
5
  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
@@ -0,0 +1,53 @@
1
+ """Plant pot and saucer (4 in nursery pot, rolled rim, drain holes, ribbed saucer)
2
+ Use for: a plant pot, planter, cup, tumbler, pen pot or vase with or without a saucer; any round tapered vessel or dish
3
+ Pattern: draw half the wall as one closed profile, fillet its corners in 2D, revolve it; pattern holes round the axis; a second revolved profile for the saucer with ribs added
4
+ Modelled on: 4 inch plastic nursery pots with drainage and saucers (https://planetdesert.com/products/white-4-inch-flower-plastic-nursery-pots-with-drainage-and-saucers-perfect-for-succulents)
5
+ Published sizes used: 4 in (10 cm) = pot top diameter, 3.3 in (8.5 cm) = height, 2.8 in (7 cm) = bottom diameter (seller's listing, URL above); wall, rim, hole and saucer sizes are design choices
6
+ Concept: A pot for a small house plant, with the saucer that catches what drains. 2 bodies, printed side by side. The pot is one revolved wall: it leans out 10 degrees so the root ball slides out for repotting and pots nest, the rim is thickened and rounded because the rim is where a pot is picked up and where it cracks, and the floor curves into the wall so there is no corner to split. Water leaves through six holes in the floor. The saucer has three low ribs: the pot stands on them, so the holes are never sealed against a flat floor and the plant does not sit in its own water. Its wall leans out further than the pot's so the pot lifts out easily. Both print upright as modelled, floors on the bed, no supports; every wall is within 20 degrees of vertical. 3 walls and 4 bottom layers hold water; PETG outdoors, PLA indoors.
7
+ What makes this good: each wall is one closed profile revolved, so thickness, taper and rim are decided in a drawing a person can read, and the saucer's ribs solve the real problem (drainage), not just the look.
8
+ """
9
+ from build123d import *
10
+
11
+ P = {
12
+ "top_d": 100.0, # pot outside diameter at the rim (published: 4 in)
13
+ "bottom_d": 70.0, # pot outside diameter at the floor (published: 2.8 in)
14
+ "height": 85.0, # published: 3.3 in
15
+ "wall": 2.0, # 5 lines of 0.4
16
+ "floor": 2.0,
17
+ "rim_t": 3.2, # thickened rim
18
+ "rim_h": 6.0,
19
+ "floor_r": 6.0, # radius where the floor curves into the wall, inside
20
+ "holes": 6,
21
+ "hole_d": 7.0,
22
+ "saucer_h": 16.0,
23
+ "saucer_gap": 6.0, # saucer floor is this much wider than the pot's, all round
24
+ "saucer_flare": 9.0, # saucer wall leans out this far over its height
25
+ "rib_h": 2.0, # ribs the pot stands on
26
+ "gap_on_plate": 10.0,
27
+ }
28
+
29
+
30
+ def vessel(r_bottom, r_top, h, rim_t, rim_h):
31
+ """A revolved cup: wall profile in XZ (floor, leaning wall, thickened rounded rim), inside floor corner rounded."""
32
+ w, f = P["wall"], P["floor"]
33
+ lean = (r_top - r_bottom) / h
34
+ r_at = lambda z: r_bottom + lean * z # outside radius at height z
35
+ pts = [(0, 0), (r_bottom, 0), (r_at(h - rim_h), h - rim_h), (r_top + rim_t - w, h - rim_h + 1.5), (r_top + rim_t - w, h),
36
+ (r_top - w, h), (r_at(f) - w, f), (0, f)]
37
+ half = Polygon(*pts, align=None)
38
+ half = fillet(half.vertices().filter_by(lambda v: v.Y > h - 0.1), min(rim_t, rim_h) * 0.45) # rounded rim
39
+ half = fillet(half.vertices().filter_by(lambda v: abs(v.Y - f) < 0.01 and v.X > 1), P["floor_r"]) # floor into wall
40
+ return revolve(Plane.XZ * half, Axis.Z)
41
+
42
+
43
+ def build():
44
+ r_b, r_t = P["bottom_d"] / 2, P["top_d"] / 2
45
+ pot = vessel(r_b, r_t, P["height"], P["rim_t"], P["rim_h"])
46
+ hole = Pos(r_b * 0.55, 0, 0) * Cylinder(P["hole_d"] / 2, 4 * P["floor"])
47
+ pot -= [Rot(0, 0, i * 360 / P["holes"]) * hole for i in range(P["holes"])]
48
+
49
+ s_b = r_b + P["saucer_gap"]
50
+ saucer = vessel(s_b, s_b + P["saucer_flare"], P["saucer_h"], 2.4, 3.0)
51
+ rib = Pos(r_b * 0.55, 0, P["floor"] + P["rib_h"] / 2 - 0.2) * Box(r_b * 0.7, 3.0, P["rib_h"] + 0.4)
52
+ saucer += [Rot(0, 0, 30 + i * 120) * rib for i in range(3)] # between the holes, not under them
53
+ return Compound([pot, Pos(r_t + s_b + P["saucer_flare"] + P["rim_t"] + P["gap_on_plate"], 0, 0) * saucer])
@@ -0,0 +1,53 @@
1
+ """Shelf bracket with a curved brace (6 x 8 in, four countersunk screws)
2
+ Use for: holding up a shelf, a worktop extension or a box on a wall; any L bracket, corner brace or support that carries a load out from a wall
3
+ Pattern: an L of two legs with the corner filled to an arc, then a filleted window cut out to leave the curved brace, all one profile in the plane the load bends it in, extruded to the bracket's width; countersunk holes cut from the faces a screwdriver can reach
4
+ Modelled on: National Hardware 211BC 6 x 8 in steel shelf bracket (https://www.dkhardware.com/national-hardware-n218-891-xcp20-211bc-shelf-bracket-100-lb-6-in-l-steel-pack-of-20-product-6640429.html); screw is SPAX 4.0 mm flat countersunk (https://www.ahlsell.se/en/products/mounting/wood-screw/wood-screw-spax/71333788---traskruv-tft-spax-svart-4.0x25h-200fp-eta-120114)
5
+ Published sizes used: 6 x 8 in (152 x 203 mm) = the bought bracket's two legs, with 5/32 in (4 mm) screw holes (retailer listing, first URL); 4.0 mm = screw thread, 8.0 mm = head diameter, 2.4 mm = head height (SPAX listing, second URL); thicknesses and the brace are design choices
6
+ Concept: Carries a shelf 150 to 200 mm deep. Frame: the wall is the plane x = 0, the shelf lies on the arm's top face at y = 0. The shelf's weight tries to fold the arm down: the brace takes that as a push along its length into the foot of the wall leg, and the top wall screw takes the matching pull, so the top screw is the one that matters and it sits high, just under the arm. The long leg goes on the wall, where there is more screw spacing. The brace bows a little towards the corner, as on a cast bracket, and the window's corners are filleted so no joint is a sharp notch. This one is rightly an extrusion: it is printed lying on its side, so each layer is the whole L with its brace and the load never pulls layers apart; printed standing, the arm would snap off along a layer. The wall screws are driven through the open window and below the brace's foot; the shelf screws go up from underneath. No supports. PETG or PLA, 5 walls, 40 percent infill; a printed bracket is for books and plants, with no load rating.
7
+ What makes this good: the brace follows the load, the screws are where a driver reaches them, and it prints with the layers running round the whole frame.
8
+ """
9
+ from build123d import *
10
+
11
+ P = {
12
+ "arm": 152.0, # under the shelf, out from the wall (published: 6 in)
13
+ "leg": 203.0, # down the wall (published: 8 in)
14
+ "width": 28.0, # bracket width = height off the bed as printed
15
+ "t": 7.0, # thickness of both legs
16
+ "brace_t": 6.0, # thickness of the brace
17
+ "brace_in": 16.0, # brace meets the arm this far in from its tip
18
+ "brace_up": 30.0, # brace meets the wall leg this far up from its foot
19
+ "bow": 10.0, # how far the brace bows towards the corner at its middle
20
+ "corner_r": 6.0, # fillet in the inside corners
21
+ "tip_r": 3.0, # rounding of the arm tip and leg foot
22
+ "screw_d": 4.0, # screw thread diameter (published)
23
+ "screw_head_d": 8.0, # head diameter (published)
24
+ "screw_head_h": 2.4, # head height (published); sets the countersink depth
25
+ "screw_clear": 0.5, # added to thread and head diameters
26
+ "edge": 0.8, # chamfer round both faces of the outline
27
+ }
28
+
29
+
30
+ def build():
31
+ t, arm, leg, w = P["t"], P["arm"], P["leg"], P["width"]
32
+ # profile: wall leg down the Y axis, arm along X with its top at y = 0; the brace is what is left between the
33
+ # filled corner and a window cut out of it (a window is a simple face, so its corners fillet; the outline's do not)
34
+ a, b = (arm - P["brace_in"], -t), (t, -leg + P["brace_up"])
35
+ mid = ((a[0] + b[0]) / 2 - P["bow"] * 0.7, (a[1] + b[1]) / 2 + P["bow"] * 0.7)
36
+ corner = make_face([Line((t, -t), a), ThreePointArc(a, mid, b), Line(b, (t, -t))])
37
+ k = P["brace_t"] / 2 ** 0.5
38
+ window = fillet((corner & Pos(-k, k) * corner).vertices(), P["corner_r"]) # the same shape moved in by the brace
39
+ arm_bar = Pos(arm / 2, -t / 2) * Rectangle(arm, t)
40
+ leg_bar = Pos(t / 2, -leg / 2) * Rectangle(t, leg)
41
+ profile = (fillet(arm_bar.vertices().group_by(Axis.X)[-1], P["tip_r"]) + fillet(leg_bar.vertices().group_by(Axis.Y)[0], P["tip_r"])
42
+ + corner - window)
43
+ body = extrude(profile, w)
44
+ body = chamfer(body.edges().group_by(Axis.Z)[0] + body.edges().group_by(Axis.Z)[-1], P["edge"])
45
+
46
+ # countersunk holes: head recess on the face the driver comes from
47
+ hole_r, head_r = (P["screw_d"] + P["screw_clear"]) / 2, (P["screw_head_d"] + P["screw_clear"]) / 2
48
+ screw = Cylinder(hole_r, 4 * t) + Cone(hole_r, head_r, P["screw_head_h"], align=(Align.CENTER, Align.CENTER, Align.MAX))
49
+ for y in (-t - 16.0, -leg + 13.0): # into the wall: heads on the inside face of the leg
50
+ body -= Pos(t, y, w / 2) * Rot(0, 90, 0) * screw
51
+ for x in (t + 30.0, arm - 8.0): # up into the shelf: heads on the underside of the arm
52
+ body -= Pos(x, -t, w / 2) * Rot(90, 0, 0) * screw
53
+ return Pos(0, leg, 0) * body
@@ -1,4 +1,5 @@
1
1
  """Under-desk headphone hook (swept arm with a broad saddle, tape or two screws)
2
+ Use for: hanging headphones, a bag or a cable coil under a desk or shelf by tape or screws (no clamp); any bent-rod hook with a broad saddle
2
3
  Pattern: sweep a rounded section along a filleted Polyline path; sweep a second, wider section along part of the same path
3
4
  Modelled on: ElevationLab AnchorPro under-desk headphone mount (https://www.elevationlab.com/products/the-anchor-pro); screw is SPAX 4.0 mm flat countersunk (https://www.ahlsell.se/en/products/mounting/wood-screw/wood-screw-spax/71333788---traskruv-tft-spax-svart-4.0x25h-200fp-eta-120114)
4
5
  Published sizes used: 4.0 mm = screw thread diameter, 8.0 mm = head diameter, 2.4 mm = head height (retailer listing for SPAX, URL above); the maker publishes no hook dimensions, so every hook size is a design choice
@@ -1,4 +1,5 @@
1
1
  """Screw-top jar and lid with a standard 70-400 neck
2
+ Use for: a jar, tub or canister with a screw lid; any printed screw thread, cap or threaded collar
2
3
  Pattern: revolve a wall profile for the body, sweep a thread section along a helix for the screw thread (same pitch on both parts, clearance as a radial offset), pattern a cutter round the lid for grip
3
4
  Modelled on: wide-mouth jars with a GPI/SPI 70-400 continuous-thread finish (https://www.ebottles.com/blogs/articles/guide-for-fitting-closures-on-bottles)
4
5
  Published sizes used: 70-400 finish, converted from the chart's inches: T (thread outside diameter) 68.61 to 69.49 mm; E (neck at the thread root) 66.22 to 67.11 mm; H (finish height) 9.98 to 10.74 mm; S (rim to thread start) 0.79 to 1.55 mm; 6 threads per inch = 4.233 mm pitch; thread depth (T - E)/2 = 1.19 mm (retailer's chart of the standard, URL above). The thread's flank angle is not in the chart: 45 degree flanks are a choice made so it prints.
@@ -1,4 +1,5 @@
1
1
  """Trigger capo for a steel-string acoustic guitar
2
+ Use for: a capo or a spring clamp squeezed with one hand; any two-lever clamp with a printed spring
2
3
  Pattern: two rigid levers on one pivot with a printed hairpin spring; each profile drawn in the plane it bends in, extruded, edges chamfered; one script gives the assembled pose and the print plate
3
4
  Modelled on: Kyser Quick-Change KG6 (https://kysermusical.com/products/acoustic-guitar-capo) and Dunlop Trigger 83CB (https://www.jimdunlop.com/37083002001-trigger-capo-acoustic/)
4
5
  Published sizes used: 44.45 mm = Martin D-28 fingerboard width at the nut, 53.98 mm at the 12th fret (maker, https://www.martinguitar.com/guitars/standard-series/D-28.html), so 48 mm where a capo sits; 406.4 mm (16 in) = the D-28's published saddle radius, used for the bar's curve (maker, same page; the fingerboard radius itself is not on it); 29 to 74 N = clamp force measured on bought spring capos, too little buzzes and too much pulls sharp (G7th, https://www.g7th.com/force-testing-at-sheehans); 4.5 mm = M4 clearance hole (ISO 273 medium). The neck depth (23.5 mm, string tops to the back of the neck) is not published by the maker: measure the guitar.
@@ -1,4 +1,5 @@
1
1
  """Screw-on wall coat hook (single curved arm with a ball tip)
2
+ Use for: hanging a coat, bag, towel or keys on a wall or door; any screw-on hook with a curved arm
2
3
  Pattern: loft elliptical sections placed along a spline (an arm that tapers), ball tip, fillet the arm into the back plate
3
4
  Modelled on: classic cast single coat hook; screw is SPAX 4.0 mm flat countersunk (https://www.ahlsell.se/en/products/mounting/wood-screw/wood-screw-spax/71333788---traskruv-tft-spax-svart-4.0x25h-200fp-eta-120114)
4
5
  Published sizes used: 4.0 mm = screw thread diameter, 8.0 mm = head diameter, 2.4 mm = head height (retailer listing for SPAX, URL above); plate and arm sizes are design choices (no hook maker publishes them)
@@ -5,14 +5,16 @@ import { fileURLToPath } from "node:url";
5
5
  /**
6
6
  * The code engine's cookbook: worked build123d designs, each modelled on the best bought version of the thing, kept as
7
7
  * plain scripts in src/cad/examples/. A design worker reaches them only through this MCP: the cad_design prompt names
8
- * each pattern in one line, and the read-only cad_examples tool returns one script on request, so the prompt pays a
9
- * line per example instead of a script per example.
8
+ * each one by what it is for in one line, and the read-only cad_examples tool lists them and returns one script on
9
+ * request, so the prompt pays a line per example instead of a script per example.
10
10
  *
11
- * A script's header (its docstring) is the record: title on the first line, then "Pattern:", "Modelled on:",
12
- * "Published sizes used:", "Concept:" and "What makes this good:".
11
+ * A script's header (its docstring) is the record: title on the first line, then "Use for:" (the requests it suits,
12
+ * so a worker chooses by purpose before mechanism), "Pattern:", "Modelled on:", "Published sizes used:", "Concept:"
13
+ * and "What makes this good:".
13
14
  */
14
15
  const DIR = fileURLToPath(new URL("../../src/cad/examples/", import.meta.url));
15
16
  const FIELDS = {
17
+ "Use for": "use_for",
16
18
  "Pattern": "pattern",
17
19
  "Modelled on": "modelled_on",
18
20
  "Published sizes used": "published_sizes",
@@ -24,8 +26,9 @@ export type CadExample = { name: string; title: string; script: string } & Recor
24
26
 
25
27
  /** Simplest first: the order the list and the prompt present them in. */
26
28
  export const CAD_EXAMPLE_ORDER = [
27
- "cable_clip", "wall_hook", "knurled_knob", "phone_stand", "swept_hook", "loft_handle", "threaded_jar",
28
- "bag_clip", "hinged_box", "bistable_clicker", "chainmail", "trigger_capo",
29
+ "cable_clip", "wall_hook", "drawer_divider", "organizer_tray", "plant_pot", "knurled_knob", "phone_stand",
30
+ "swept_hook", "loft_handle", "shelf_bracket", "broom_grip", "desk_edge_cable_holder", "threaded_jar",
31
+ "desk_clamp_hook", "bag_clip", "hinged_box", "bistable_clicker", "chainmail", "trigger_capo",
29
32
  ];
30
33
 
31
34
  function parse(name: string, script: string): CadExample {
@@ -55,9 +58,9 @@ export function cadExamples(): CadExample[] {
55
58
  return cache;
56
59
  }
57
60
 
58
- /** One line per example for the cad_design prompt: "name: what it is; the pattern it shows". */
61
+ /** One line per example for the cad_design prompt: "name: what it is for". */
59
62
  export function cadExampleLines(): string {
60
- return cadExamples().map((e) => `${e.name}: ${e.title}; ${e.pattern}`).join("\n");
63
+ return cadExamples().map((e) => `${e.name}: ${e.use_for}`).join("\n");
61
64
  }
62
65
 
63
66
  /** cad_examples: without a name, the list; with one, that example's record and script. */
@@ -67,8 +70,8 @@ export function cadExamplesTool(args: Record<string, unknown>): Record<string, u
67
70
  const all = cadExamples();
68
71
  if (args.name === undefined)
69
72
  return {
70
- examples: all.map(({ name, title, pattern, modelled_on }) => ({ name, title, pattern, modelled_on })),
71
- usage: "Call cad_examples with one name to read its concept and script. Adapt the pattern to the request and to the product the person means; do not paste an example's sizes onto a different object.",
73
+ examples: all.map(({ name, title, use_for, pattern, modelled_on }) => ({ name, title, use_for, pattern, modelled_on })),
74
+ usage: "Choose by use_for: the example made for the nearest request, before you choose a mechanism. Call cad_examples with that name to read its concept and script. Adapt the form and pattern to the request and to the product the person means; do not paste an example's sizes onto a different object.",
72
75
  };
73
76
  if (typeof args.name !== "string") throw new Error("name must be a string.");
74
77
  const found = all.find((e) => e.name === args.name);
@@ -131,7 +131,13 @@ def bodies(step, request, budget_s=20.0):
131
131
  exact = exact_calls < EXACT_CAP and not over()
132
132
  if exact:
133
133
  exact_calls += 1
134
+ screened = d
134
135
  d, pa, pb = solids[i].distance_to_with_closest_points(solids[j])
136
+ if d <= 1e-6 and screened > 1e-3 and not over() and getattr(solids[i] & solids[j], 'volume', 0.0) <= 1e-6:
137
+ # The B-rep distance can call a shaft in its threaded hole "inside" the other solid and return 0
138
+ # where the tessellations are apart and the solids share no volume (a printed screw in its nut,
139
+ # desk_clamp_hook at opening 31): measure the surfaces, which have no inside.
140
+ d, pa, pb = Compound(solids[i].faces()).distance_to_with_closest_points(Compound(solids[j].faces()))
135
141
  at = mid(pa, pb)
136
142
  holds = lambda x, y: all(getattr(x.min, c) <= getattr(y.min, c) and getattr(y.max, c) <= getattr(x.max, c) for c in 'XYZ')
137
143
  if d > 1e-6 and (holds(a, b) or holds(b, a)) and not over() and getattr(solids[i] & solids[j], 'volume', 0.0) > 1e-6:
package/src/cad/serial.ts CHANGED
@@ -14,7 +14,7 @@ function dead(pid: unknown): boolean {
14
14
  return (e as NodeJS.ErrnoException).code === "ESRCH";
15
15
  }
16
16
  }
17
- /** One dispatched operation per environment; runs queue across processes and never replay. */
17
+ /** One dispatched operation per environment; runs and fit checks queue across processes and never replay. */
18
18
  export async function withCadLock<T>(
19
19
  data: string,
20
20
  options: {
@@ -29,7 +29,7 @@ export async function withCadLock<T>(
29
29
  queue = path.join(data, "queue");
30
30
  const start = performance.now();
31
31
  let ticket: string | undefined, temporary: string | undefined;
32
- const queued = options.operation === "run";
32
+ const queued = options.operation !== "setup";
33
33
  if (queued) {
34
34
  await fs.mkdir(queue, { recursive: true, mode: 0o700 });
35
35
  const name = `${String(Date.now()).padStart(13, "0")}-${process.hrtime.bigint().toString().padStart(20, "0")}-${randomUUID()}.json`;
@@ -47,7 +47,7 @@ export async function withCadLock<T>(
47
47
  if (queued && performance.now() >= options.deadline!)
48
48
  throw new CadRefusal(
49
49
  "cad-queue-timeout",
50
- "The CAD run's timeout expired while waiting for another operation. This run was not dispatched.",
50
+ `The CAD ${options.operation === "fit" ? "fit check" : "run"}'s timeout expired while waiting for another operation. It was not dispatched.`,
51
51
  );
52
52
  const names = (
53
53
  await fs.readdir(queue).catch((e) => {
@@ -108,9 +108,7 @@ export async function withCadLock<T>(
108
108
  }
109
109
  if (!queued)
110
110
  throw new CadRefusal(
111
- options.operation === "setup"
112
- ? "cad-setup-busy"
113
- : "cad-operation-busy",
111
+ "cad-setup-busy",
114
112
  "Another CAD operation is already running or queued. Wait for it to finish; this request was not dispatched.",
115
113
  );
116
114
  await delay(
package/src/cad-engine.ts CHANGED
@@ -802,8 +802,13 @@ export class CadEngine {
802
802
  )
803
803
  ).stdout,
804
804
  );
805
+ const printed = built.stdout.trim();
805
806
  const result = {
806
807
  ...checked,
808
+ // Beside the image paths, where the next step is decided.
809
+ next: "Read renders.perspective before the next cad_run or any other change: say what it shows is wrong against what you are making (the bought product you named, or the object in the photos), then fix that.",
810
+ // The script's own print() output: its words, not a measurement by this engine.
811
+ ...(printed ? { printed: printed.length > 4000 ? printed.slice(0, 4000) + "\n[cut at 4000 characters; build.log has the rest]" : printed } : {}),
807
812
  status: "completed",
808
813
  final: args.final === true,
809
814
  completed_at: new Date().toISOString(),
@@ -874,7 +879,7 @@ export class CadEngine {
874
879
  const deadline = performance.now() + milliseconds(args.timeout_ms);
875
880
  const before = await this.ensureReady(signal, deadline);
876
881
  return this.exclusive(
877
- async () => {
882
+ async (queueWaitMs) => {
878
883
  const status = await this.status();
879
884
  if (!status.ready) throw new CadRefusal("cad-not-ready", before.error ?? status.error!);
880
885
  const job = await fs.mkdtemp(path.join(this.dataDir, "fit-"));
@@ -891,7 +896,7 @@ export class CadEngine {
891
896
  clearance_mm: clearance,
892
897
  }),
893
898
  );
894
- return JSON.parse(
899
+ return { queue_wait_ms: queueWaitMs, ...JSON.parse(
895
900
  (
896
901
  await this.confined(
897
902
  "fit",
@@ -910,13 +915,14 @@ export class CadEngine {
910
915
  signal,
911
916
  )
912
917
  ).stdout,
913
- );
918
+ ) };
914
919
  } finally {
915
920
  await fs.rm(job, { recursive: true, force: true });
916
921
  }
917
922
  },
918
923
  "fit",
919
924
  signal,
925
+ deadline,
920
926
  );
921
927
  }
922
928
  }
@@ -21,15 +21,21 @@ export function bambuSliceCapabilities(slicerType: string | undefined): { suppor
21
21
  return { supports: false, copies: false, orient: false };
22
22
  }
23
23
 
24
+ /** The maker's own name for this model ("Bambu Lab P1S"), so a client shows it as given and composes nothing. */
25
+ export const BAMBU_MAKER = "Bambu Lab";
26
+
24
27
  export function bambuPrinterInfo(options: { server: { name: string; version: string }; host: string; serial?: string; model?: string; slicerType?: string }): PrinterInfo {
25
28
  const model = normalizeModel(options.model);
29
+ const named = model ? DISPLAY_NAMES.get(model) : undefined;
26
30
  const serial = options.serial?.trim();
27
31
  return {
28
32
  contract: COUNTERPART_CONTRACT,
29
33
  server: options.server,
30
34
  printer: {
31
35
  kind: "bambu",
32
- ...(model ? { model: DISPLAY_NAMES.get(model) ?? model.toUpperCase() } : {}),
36
+ ...(model ? { model: named ?? model.toUpperCase() } : {}),
37
+ // Only a name Bambu gives the model; nothing is composed from another value.
38
+ ...(named ? { displayName: `${BAMBU_MAKER} ${named}` } : {}),
33
39
  ...(serial ? { serial } : {}),
34
40
  host: options.host,
35
41
  },