bambu-printer-mcp 1.1.90 → 1.1.92

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 (86) hide show
  1. package/CONTRIBUTORS.md +2 -0
  2. package/README.md +48 -3
  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/flight-record.d.ts +155 -0
  11. package/dist/counterpart/flight-record.js +831 -0
  12. package/dist/counterpart/flight-tools.d.ts +213 -0
  13. package/dist/counterpart/flight-tools.js +232 -0
  14. package/dist/counterpart/fresh-frame.d.ts +16 -0
  15. package/dist/counterpart/fresh-frame.js +26 -0
  16. package/dist/counterpart/make-3mf.js +1 -4
  17. package/dist/counterpart/physical-evidence.d.ts +70 -0
  18. package/dist/counterpart/physical-evidence.js +103 -0
  19. package/dist/counterpart/print-geometry.d.ts +13 -0
  20. package/dist/counterpart/print-geometry.js +181 -0
  21. package/dist/counterpart/remote.js +2 -0
  22. package/dist/counterpart/schemas.d.ts +32 -0
  23. package/dist/counterpart/schemas.js +2 -0
  24. package/dist/counterpart/visual-evidence.d.ts +38 -0
  25. package/dist/counterpart/visual-evidence.js +155 -0
  26. package/dist/index.js +63 -24
  27. package/dist/printers/bambu.d.ts +15 -2
  28. package/dist/printers/bambu.js +64 -12
  29. package/dist/safety/limits.d.ts +6 -0
  30. package/dist/safety/limits.js +8 -0
  31. package/dist/safety/print-file.js +2 -2
  32. package/dist/safety/print-preview.d.ts +2 -0
  33. package/dist/safety/print-preview.js +1 -1
  34. package/dist/safety/printer-state.d.ts +4 -0
  35. package/dist/safety/printer-state.js +14 -1
  36. package/dist/slicer/3mf-xml.d.ts +7 -0
  37. package/dist/slicer/3mf-xml.js +61 -0
  38. package/dist/stl/stl-manipulator.js +5 -2
  39. package/dist/studio-print-options.d.ts +9 -0
  40. package/dist/studio-print-options.js +34 -2
  41. package/dist/tool-annotations.js +2 -0
  42. package/package.json +2 -1
  43. package/src/bambu-native.ts +1 -1
  44. package/src/cad/contracts.ts +17 -7
  45. package/src/cad/examples/bag_clip.py +1 -0
  46. package/src/cad/examples/bistable_clicker.py +1 -0
  47. package/src/cad/examples/broom_grip.py +61 -0
  48. package/src/cad/examples/cable_clip.py +1 -0
  49. package/src/cad/examples/chainmail.py +1 -0
  50. package/src/cad/examples/desk_clamp_hook.py +91 -0
  51. package/src/cad/examples/desk_edge_cable_holder.py +55 -0
  52. package/src/cad/examples/drawer_divider.py +56 -0
  53. package/src/cad/examples/hinged_box.py +1 -0
  54. package/src/cad/examples/knurled_knob.py +1 -0
  55. package/src/cad/examples/loft_handle.py +1 -0
  56. package/src/cad/examples/organizer_tray.py +41 -0
  57. package/src/cad/examples/phone_stand.py +1 -0
  58. package/src/cad/examples/plant_pot.py +53 -0
  59. package/src/cad/examples/shelf_bracket.py +53 -0
  60. package/src/cad/examples/swept_hook.py +1 -0
  61. package/src/cad/examples/threaded_jar.py +1 -0
  62. package/src/cad/examples/trigger_capo.py +1 -0
  63. package/src/cad/examples/wall_hook.py +1 -0
  64. package/src/cad/examples.ts +13 -10
  65. package/src/cad/geometry.py +6 -0
  66. package/src/cad/serial.ts +4 -6
  67. package/src/cad-engine.ts +9 -3
  68. package/src/counterpart/flight-record.ts +984 -0
  69. package/src/counterpart/flight-tools.ts +282 -0
  70. package/src/counterpart/fresh-frame.ts +45 -0
  71. package/src/counterpart/make-3mf.ts +1 -5
  72. package/src/counterpart/physical-evidence.ts +185 -0
  73. package/src/counterpart/print-geometry.ts +192 -0
  74. package/src/counterpart/remote.ts +2 -0
  75. package/src/counterpart/schemas.ts +3 -0
  76. package/src/counterpart/visual-evidence.ts +212 -0
  77. package/src/index.ts +61 -21
  78. package/src/printers/bambu.ts +64 -10
  79. package/src/safety/limits.ts +8 -0
  80. package/src/safety/print-file.ts +2 -2
  81. package/src/safety/print-preview.ts +1 -1
  82. package/src/safety/printer-state.ts +13 -1
  83. package/src/slicer/3mf-xml.ts +52 -0
  84. package/src/stl/stl-manipulator.ts +4 -1
  85. package/src/studio-print-options.ts +33 -2
  86. package/src/tool-annotations.ts +2 -0
@@ -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
  }