forgecad 0.9.16 → 0.10.0

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 (147) hide show
  1. package/dist/assets/{AdminPage-CXvls4-J.js → AdminPage-DwYHz72L.js} +1 -1
  2. package/dist/assets/{BenchmarkPage-B27zk8xL.js → BenchmarkPage-a9_f-1US.js} +1 -1
  3. package/dist/assets/{BlogPage-CMAVvgQL.js → BlogPage-DodHpvmf.js} +1 -1
  4. package/dist/assets/{DocsPage-knf4I4h7.js → DocsPage-B5LePEuj.js} +8 -858
  5. package/dist/assets/EditorApp-QXsAISLR.js +16307 -0
  6. package/dist/assets/{EmbedViewer-D7ZGlFjx.js → EmbedViewer-DdEHGUMU.js} +2 -2
  7. package/dist/assets/{LandingPageProofDriven-CnevhTE8.js → LandingPageProofDriven-yhhOodbf.js} +1 -1
  8. package/dist/assets/{LegalPage-BPTUmqeg.js → LegalPage-5RbKRGYK.js} +1 -1
  9. package/dist/assets/{PricingPage-B0D4goG_.js → PricingPage-E3Rma7aV.js} +1 -1
  10. package/dist/assets/{SettingsPage-CFF-UgjI.js → SettingsPage-BJZcM97j.js} +1 -1
  11. package/dist/assets/{app-T0pDcSX4.js → app-DSYrDg0V.js} +733 -205
  12. package/dist/assets/cli/{render-C5pcIISc.js → render-ZMHR9HkV.js} +19 -46
  13. package/dist/assets/{constructionHistoryWorker-Ba2Hm58b.js → constructionHistoryWorker-AwMMWSxg.js} +1103 -349
  14. package/dist/assets/{evalWorker-vkx310U2.js → evalWorker-DbNs7Dkp.js} +3798 -1622
  15. package/dist/assets/{inspectWorker-BuTJDVX6.js → inspectWorker-CZsCFtQT.js} +1163 -409
  16. package/dist/assets/{jointPose-B_Cgedn9.js → jointPose-DO6mnXn_.js} +1 -1
  17. package/dist/assets/{manifold-BWgsjmAM.js → manifold-BGlQBBH9.js} +1 -1
  18. package/dist/assets/{manifold-rZexZI0G.js → manifold-BU-tJwQh.js} +1 -1
  19. package/dist/assets/{manifold-D6IFSkhH.js → manifold-fy2MV7K1.js} +2 -2
  20. package/dist/assets/{reportWorker-0AGij1Ru.js → reportWorker-DO6hcQbh.js} +7155 -2437
  21. package/dist/assets/{scalar-sampling-budget-J5cuzxT1.js → scalar-sampling-budget-o90NSNmF.js} +3940 -1742
  22. package/dist/assets/{scanProxyWorker-Vl4Wxa1y.js → scanProxyWorker-2GtDLk-R.js} +1 -1
  23. package/dist/assets/{javascript-1kQXfVaz.js → typescript-DBQ6RN5l.js} +874 -22
  24. package/dist/cli/render.html +1 -1
  25. package/dist/docs/index.html +3 -3
  26. package/dist/docs-raw/AI/usage.md +1 -1
  27. package/dist/docs-raw/CLI.md +63 -241
  28. package/dist/docs-raw/README.md +6 -0
  29. package/dist/docs-raw/component-model.md +17 -150
  30. package/dist/docs-raw/generated/assembly.md +139 -598
  31. package/dist/docs-raw/generated/concepts.md +245 -3501
  32. package/dist/docs-raw/generated/core.md +277 -1251
  33. package/dist/docs-raw/generated/curves.md +387 -1608
  34. package/dist/docs-raw/generated/legacy.md +162 -0
  35. package/dist/docs-raw/generated/lib.md +227 -85
  36. package/dist/docs-raw/generated/output.md +38 -73
  37. package/dist/docs-raw/generated/runtime-names.md +23 -23
  38. package/dist/docs-raw/generated/sdf.md +68 -284
  39. package/dist/docs-raw/generated/sheet-metal.md +68 -335
  40. package/dist/docs-raw/generated/sketch.md +240 -1161
  41. package/dist/docs-raw/generated/viewport.md +75 -316
  42. package/dist/docs-raw/generated/wood.md +21 -49
  43. package/dist/docs-raw/guides/coordinate-system.md +4 -42
  44. package/dist/docs-raw/guides/inspection-bundles.md +44 -442
  45. package/dist/docs-raw/guides/joint-design.md +18 -79
  46. package/dist/docs-raw/guides/positioning.md +21 -143
  47. package/dist/docs-raw/guides/scene-presentation.md +89 -0
  48. package/dist/docs-raw/skills/forgecad-3d-reconstruction.md +25 -111
  49. package/dist/docs-raw/skills/forgecad-blockout-model.md +20 -117
  50. package/dist/docs-raw/skills/forgecad-component-model.md +23 -107
  51. package/dist/docs-raw/skills/forgecad-high-level-spec.md +47 -155
  52. package/dist/docs-raw/skills/forgecad-image-replicator.md +26 -143
  53. package/dist/docs-raw/skills/forgecad-lld.md +19 -113
  54. package/dist/docs-raw/skills/forgecad-make-a-model.md +112 -532
  55. package/dist/docs-raw/skills/forgecad-model-grader.md +38 -108
  56. package/dist/docs-raw/skills/forgecad-prepare-prompt.md +24 -211
  57. package/dist/docs-raw/skills/forgecad-project.md +13 -131
  58. package/dist/docs-raw/skills/forgecad-reconstruction-benchmark.md +42 -134
  59. package/dist/docs-raw/skills/forgecad-render-inspect.md +27 -174
  60. package/dist/docs-raw/skills/forgecad-visual-spec.md +32 -112
  61. package/dist/docs-raw/skills/forgecad.md +19 -18
  62. package/dist/docs-raw/skills/index.md +2 -0
  63. package/dist/docs-raw/welcome.md +2 -2
  64. package/dist/index.html +1 -1
  65. package/dist/llms.txt +1 -2
  66. package/dist/sitemap.xml +13 -13
  67. package/dist-cli/{check-compiler-SYQ2PWOB.js → check-compiler-JTVBITCR.js} +1 -1
  68. package/dist-cli/{check-query-propagation-HIAGV62W.js → check-query-propagation-3FFLSMVN.js} +1 -1
  69. package/dist-cli/{chunk-SPZE3DUY.js → chunk-OAN5T4XD.js} +4412 -2212
  70. package/dist-cli/forgecad.js +507 -179
  71. package/dist-skill/CONTEXT.md +2172 -8377
  72. package/dist-skill/SKILL.md +15 -15
  73. package/dist-skill/docs/API/core/concepts.md +27 -157
  74. package/dist-skill/docs/CLI.md +63 -241
  75. package/dist-skill/docs/generated/assembly.md +138 -549
  76. package/dist-skill/docs/generated/core.md +277 -1251
  77. package/dist-skill/docs/generated/curves.md +387 -1609
  78. package/dist-skill/docs/generated/lib.md +227 -85
  79. package/dist-skill/docs/generated/output.md +38 -73
  80. package/dist-skill/docs/generated/runtime-names.md +16 -21
  81. package/dist-skill/docs/generated/sdf.md +68 -284
  82. package/dist-skill/docs/generated/sheet-metal.md +68 -335
  83. package/dist-skill/docs/generated/sketch.md +240 -1160
  84. package/dist-skill/docs/generated/viewport.md +75 -223
  85. package/dist-skill/docs/generated/wood.md +21 -49
  86. package/dist-skill/docs/guides/coordinate-system.md +4 -42
  87. package/dist-skill/docs/guides/inspection-bundles.md +44 -442
  88. package/dist-skill/docs/guides/joint-design.md +18 -79
  89. package/dist-skill/docs/guides/positioning.md +21 -143
  90. package/dist-skill/docs/guides/scene-presentation.md +89 -0
  91. package/dist-skill/docs/guides/surface-members.md +26 -0
  92. package/dist-skill/library/forgecad-3d-reconstruction/SKILL.md +23 -111
  93. package/dist-skill/library/forgecad-blockout-model/SKILL.md +18 -117
  94. package/dist-skill/library/forgecad-component-model/SKILL.md +21 -107
  95. package/dist-skill/library/forgecad-high-level-spec/SKILL.md +45 -155
  96. package/dist-skill/library/forgecad-image-replicator/SKILL.md +24 -143
  97. package/dist-skill/library/forgecad-lld/SKILL.md +17 -113
  98. package/dist-skill/library/forgecad-make-a-model/SKILL.md +110 -532
  99. package/dist-skill/library/forgecad-model-grader/SKILL.md +36 -108
  100. package/dist-skill/library/forgecad-prepare-prompt/SKILL.md +35 -224
  101. package/dist-skill/library/forgecad-prepare-prompt/references/default-profiles.md +43 -271
  102. package/dist-skill/library/forgecad-prepare-prompt/references/master-prompt.md +30 -99
  103. package/dist-skill/library/forgecad-project/SKILL.md +13 -133
  104. package/dist-skill/library/forgecad-reconstruction-benchmark/SKILL.md +29 -123
  105. package/dist-skill/library/forgecad-render-inspect/SKILL.md +25 -174
  106. package/dist-skill/library/forgecad-visual-spec/SKILL.md +30 -111
  107. package/dist-skill/website/skills/forgecad-3d-reconstruction.md +58 -0
  108. package/dist-skill/website/skills/forgecad-blockout-model.md +49 -0
  109. package/dist-skill/website/skills/forgecad-component-model.md +53 -0
  110. package/dist-skill/website/skills/forgecad-high-level-spec.md +101 -0
  111. package/dist-skill/website/skills/forgecad-image-replicator.md +63 -0
  112. package/dist-skill/website/skills/forgecad-lld.md +41 -0
  113. package/dist-skill/website/skills/forgecad-make-a-model.md +186 -0
  114. package/dist-skill/website/skills/forgecad-model-grader.md +82 -0
  115. package/dist-skill/website/skills/forgecad-prepare-prompt.md +63 -0
  116. package/dist-skill/website/skills/forgecad-project.md +26 -0
  117. package/dist-skill/website/skills/forgecad-reconstruction-benchmark.md +60 -0
  118. package/dist-skill/website/skills/forgecad-render-inspect.md +80 -0
  119. package/dist-skill/website/skills/forgecad-visual-spec.md +71 -0
  120. package/dist-skill/website/skills/forgecad.md +122 -0
  121. package/dist-skill/website/skills/index.md +26 -0
  122. package/examples/api/comparison-imported-sphere-candidate.forge.js +1 -1
  123. package/examples/api/conformal-product-ribbon.forge.js +1 -1
  124. package/examples/api/exact-sheet-shell-assembly.forge.js +1 -1
  125. package/examples/api/extrude-options.forge.js +4 -2
  126. package/examples/api/field-loft-drive-tip.forge.js +40 -0
  127. package/examples/api/guided-loft-olive-oil-bottle.forge.js +1 -1
  128. package/examples/api/highlight-debug.forge.js +10 -10
  129. package/examples/api/mesh-import-slats.forge.js +1 -1
  130. package/examples/api/real-product-curves.forge.js +1 -1
  131. package/examples/api/sculpt-box-circle-booleans.forge.js +1 -1
  132. package/examples/api/sdf-shapes.forge.js +2 -5
  133. package/examples/api/sketch-rounding-strategies.forge.js +6 -6
  134. package/examples/api/surface-member-bottle-cage.forge.js +3 -3
  135. package/examples/api/surface-member-conformal-product-ribbon.forge.js +3 -3
  136. package/examples/api/surface-member-razor-inlay.forge.js +1 -1
  137. package/examples/api/variable-sweep-test.forge.js +3 -3
  138. package/examples/mechanical/airplane-propeller.forge.js +74 -39
  139. package/examples/nurbs-surface.forge.js +1 -1
  140. package/examples/products/iphone.forge.js +1 -1
  141. package/package.json +1 -1
  142. package/dist/assets/EditorApp-BHMQlJ-D.js +0 -14686
  143. package/dist/docs-raw/guides/geometry-conventions.md +0 -52
  144. package/dist/docs-raw/guides/modeling-recipes.md +0 -78
  145. package/dist-skill/docs/guides/geometry-conventions.md +0 -52
  146. package/dist-skill/docs/guides/modeling-recipes.md +0 -78
  147. package/dist-skill/library/forgecad-visual-spec/references/prompt-template.md +0 -79
@@ -33,55 +33,27 @@ Pre-built fasteners, gears, pipes, structural profiles, and utility shapes. Acce
33
33
 
34
34
  **Methods:**
35
35
 
36
- #### `toSketch()` — Convert the loop centerline into a thin visual sketch.
36
+ #### `toSketch(width?: number): Sketch` — Convert the loop centerline into a thin visual sketch.
37
37
 
38
- ```ts
39
- toSketch(width?: number): Sketch
40
- ```
38
+ #### `toProfile(): Sketch` — Convert the loop into a filled profile using the pitch path itself as the boundary.
41
39
 
42
- #### `toProfile()` — Convert the loop into a filled profile using the pitch path itself as the boundary.
43
-
44
- ```ts
45
- toProfile(): Sketch
46
- ```
47
-
48
- #### `offsetBand()` — Build a belt band sketch by offsetting the route to inner and outer pulley radii.
49
-
50
- ```ts
51
- offsetBand(thickness: number): Sketch
52
- ```
40
+ #### `offsetBand(thickness: number): Sketch` — Build a belt band sketch by offsetting the route to inner and outer pulley radii.
53
41
 
54
42
  ### `DriveWheelBuilder`
55
43
 
56
- #### `addSpurTeethBetween()` — Add an involute spur-tooth window on part of the pitch circle.
57
-
58
- ```ts
59
- addSpurTeethBetween(options: DriveWheelSpurTeethRegionOptions): this
60
- ```
44
+ #### `addSpurTeethBetween(options: DriveWheelSpurTeethRegionOptions): this` — Add an involute spur-tooth window on part of the pitch circle.
61
45
 
62
46
  `DriveWheelSpurTeethRegionOptions`: `{ name?: string, teethOnFullCircle: number, toothCount: number, firstTooth?: number, faceWidth?: number }`
63
47
 
64
- #### `addSolidArcBetween()` — Add a constant-radius solid arc region such as a dwell, stop, or pusher.
65
-
66
- ```ts
67
- addSolidArcBetween(options: DriveWheelSolidArcRegionOptions): this
68
- ```
48
+ #### `addSolidArcBetween(options: DriveWheelSolidArcRegionOptions): this` — Add a constant-radius solid arc region such as a dwell, stop, or pusher.
69
49
 
70
50
  **`DriveWheelSolidArcRegionOptions`**: `name?: string`, `fromAngleDeg: number`, `toAngleDeg: number`, `innerRadius?: number`, `outerRadius: number`, `faceWidth?: number`, `segments?: number`
71
51
 
72
- #### `addShapeRegion()` — Add a fully custom region shape while preserving region metadata.
73
-
74
- ```ts
75
- addShapeRegion(name: string, shape: Shape, options?: DriveWheelShapeRegionOptions): this
76
- ```
52
+ #### `addShapeRegion(name: string, shape: Shape, options?: DriveWheelShapeRegionOptions): this` — Add a fully custom region shape while preserving region metadata.
77
53
 
78
54
  `DriveWheelShapeRegionOptions`: `{ fromAngleDeg?: number, toAngleDeg?: number, innerRadius?: number, outerRadius?: number }`
79
55
 
80
- #### `build()` — Build the final wheel shape with a bore connector and region metadata.
81
-
82
- ```ts
83
- build(): Shape
84
- ```
56
+ #### `build(): Shape` — Build the final wheel shape with a bore connector and region metadata.
85
57
 
86
58
  ---
87
59
 
@@ -91,69 +63,239 @@ build(): Shape
91
63
 
92
64
  Pre-built parametric parts available in user scripts as `lib.*`.
93
65
 
94
- Every key in this object becomes a method or namespace on the `lib` object exposed to `.forge.js` scripts. The catalog includes:
66
+ Every key in this object becomes a method or namespace on the `lib` object exposed to `.forge.js` scripts see the member list below for the catalog. Sizes outside the supported ranges throw at runtime with a descriptive error.
67
+
68
+ - `fastenerHole(opts: FastenerHoleOptions): Shape` — ISO metric fastener hole cutter with optional counterbore or countersink.
69
+
70
+ Returns a cutter shape (subtract from a solid to produce the hole). Sizes outside M2–M10 will throw.
71
+
72
+ ```ts
73
+ const plate = box(60, 40, 8)
74
+ .subtract(lib.fastenerHole({ size: 'M5', fit: 'normal', depth: 8 })
75
+ .translate(15, 10, 4));
76
+ ```
77
+ - `tube(outerX: number, outerY: number, outerZ: number, wall: number): Shape` — Rectangular hollow tube (thin-wall box section).
78
+
79
+ Both the outer and inner boxes are centered on the XY plane with their base at Z=0.
80
+ - `pipe(height: number, outerRadius: number, wall: number, segments?: number): Shape` — Hollow cylindrical pipe.
81
+
82
+ Centered on the XY plane, extending upward along +Z from z=0 to z=height. For complex routed pipe geometry, see `lib.pipeRoute`.
83
+ - `explode<T extends ExplodeItem[] | ShapeGroup>(items: T, options?: ExplodeOptions): T` — Apply deterministic exploded-view offsets to an assembly tree.
84
+
85
+ Traverses arrays, nested `{ name, group: [...] }` structures, and [`ShapeGroup`](/docs/core#shapegroup) outputs, translating each node while preserving names, colors, and nesting; returns the same structure type as the input. `radial` mode is branch-aware and parent-relative — nested assemblies peel apart level by level. Named items accept an inline `explode: { stage?, direction?, axisLock? }` override. Bakes the offset into geometry (e.g. driven by a `param()` slider); for a viewport-only slider use [`explodeView()`](/docs/viewport#explodeview) instead.
86
+
87
+ ```js
88
+ const explodeAmt = param('Explode', 0, { min: 0, max: 40, unit: 'mm' });
89
+
90
+ return lib.explode(assembly, {
91
+ amount: explodeAmt,
92
+ stages: [0.4, 0.8],
93
+ mode: 'radial',
94
+ byName: { Shaft: { direction: [1, 0, 0], stage: 1.4 } },
95
+ });
96
+ ```
97
+ - `bracket(width: number, height: number, depth: number, thick: number, holeDia?: number): Shape` — L-shaped mounting bracket with optional through-holes.
98
+
99
+ Produces a right-angle bracket: a horizontal base plate and a vertical wall. Both legs share `width`. Optional holes are drilled through the base (along Z) and the wall (along Y).
100
+ - `holePattern(rows: number, cols: number, spacingX: number, spacingY: number, holeDia: number, depth: number): Shape` — Rectangular grid of cylindrical hole cutters.
101
+
102
+ Returns the union of `rows × cols` cylinders laid out on a regular grid. Subtract from a solid to produce the full pattern.
103
+
104
+ ```ts
105
+ const pattern = lib.holePattern(3, 4, 20, 20, 4, 10);
106
+ const panel = box(80, 70, 10).subtract(pattern.translate(-30, -20, 0));
107
+ ```
108
+ - `thread(diameter: number, pitch: number, length: number, options?: { depth?: number; segments?: number; }): Shape` — External helical thread — clean mesh, no SDF grid artifacts.
109
+
110
+ Builds a cross-section with a single trapezoidal tooth from the root radius out to the crest radius, then twist-extrudes it so the tooth traces a helix. Manifold's extrude+twist produces structured quad-based geometry that follows the thread profile cleanly.
111
+
112
+ Returns a threaded cylinder along +Z from z=0 to z=length.
113
+ - `bolt(diameter: number, length: number, options?: { ... }): Shape` — ISO-style hex bolt with real helical threads.
114
+
115
+ The hex head sits from z=0 up to z=headHeight. The shaft extends downward along −Z by `length` mm. An unthreaded shank section is included when `threadLength < length`.
116
+
117
+ Default proportions follow ISO 4762 loosely: pitch ≈ 0.15×diameter, head height ≈ 0.65×diameter, across-flats ≈ 1.6×diameter.
118
+
119
+ For standard M-size bolts pre-configured for a complete joint, use `fastenerSet` instead.
120
+ - `nut(diameter: number, options?: { ... }): Shape` — ISO-style hex nut with a clearance bore.
121
+
122
+ Constructed from the intersection of three rotated slabs with a cylindrical bore subtracted. The nut is centered at the origin, height along Z (−height/2 to +height/2).
123
+
124
+ Default proportions follow ISO 4032 loosely: height ≈ 0.8×diameter, across-flats ≈ 1.6×diameter. The bore is a clearance bore — `diameter` + 0.2 mm by default, override with `boreDiameter` for exact bore control — not modelled with helical threads, for rendering efficiency.
125
+
126
+ For standard M-size nuts pre-configured for a complete joint, use `fastenerSet` instead.
127
+ - `washer(size: MetricSize, options?: { standard?: WasherStandard; segments?: number; }): Shape` — ISO metric flat washer (DIN 125-A).
128
+
129
+ Returns a flat ring centered at the origin, thickness along Z. Dimensions are taken from `WASHER_TABLE`. Sizes outside M2–M10 will throw.
130
+ - `fastenerSet(size: MetricSize, boltLength: number, options?: FastenerSetOptions): FastenerSetResult` — Complete ISO metric fastener set — bolt, nut, optional washers, and matching hole cutters.
131
+
132
+ Returns all geometry for one bolted joint: the bolt, nut, up to two washers, a clearance-hole cutter, and a tap-drill cutter. All shapes are returned **un-positioned** (each on the Z-axis). Place them with `.translate()`.
133
+
134
+ Sizes outside M4–M10 are supported for the washer (M2–M10); unsupported combinations will throw.
95
135
 
96
- **Fasteners and hardware patterns:** `bolt`, `nut`, `washer`, `fastenerSet`, `fastenerHole`, `boltHole`, `counterbore`, `hexNut`, `holePattern`
136
+ ```ts
137
+ const hw = lib.fastenerSet('M5', 20);
97
138
 
98
- **Structure:** `tube`, `pipe`, `bracket`, `pipeRoute`, `elbow`, `tSlotProfile`, `tSlotExtrusion`, `profile2020BSlot6Profile`, `profile2020BSlot6`
139
+ const topPlate = box(60, 40, 8).translate(0, 0, 12)
140
+ .subtract(hw.clearanceHole.translate(15, 10, 12));
141
+ const botPlate = box(60, 40, 8)
142
+ .subtract(hw.clearanceHole.translate(15, 10, 0));
99
143
 
100
- **Belt drives:** `beltDrive`, `tangentLoop2d`
144
+ return [
145
+ { name: 'Top Plate', shape: topPlate },
146
+ { name: 'Bot Plate', shape: botPlate },
147
+ { name: 'Bolt', shape: hw.bolt.translate(15, 10, 20) },
148
+ { name: 'Nut', shape: hw.nut.translate(15, 10, -4) },
149
+ ];
150
+ ```
151
+ - `pipeRoute(points: Vec3[], radius: number, options?: { bendRadius?: number; wall?: number; segments?: number; }): Shape` — Route a pipe (solid or hollow) through 3D waypoints with smooth bends.
101
152
 
102
- **Threads:** `thread`
153
+ This is a convenience recipe over `Curve.Route.fromPolyline()` and [`sweep()`](/docs/curves#sweep). Use `Curve.Route` directly when you need route metadata, named ports, or custom swept profiles.
154
+ - `elbow(pipeRadius: number, bendRadius: number, angle?: number | { ... }, options?: { ... }): Shape` — Pipe elbow — a curved pipe section for connecting two pipe directions.
103
155
 
104
- **Gears:** `spurGear`, `sectorGear`, `driveWheel`, `bevelGear`, `faceGear`, `sideGear`, `ringGear`, `rackGear`, `gearPair`, `bevelGearPair`, `faceGearPair`, `sideGearPair`
156
+ This is a convenience recipe over `Curve.Arc()` and [`sweep()`](/docs/curves#sweep). Use `Curve.Route.fromPolyline()` directly when you need named route ports, segment metadata, or multi-bend pipe runs.
157
+ - `beltDrive(options: BeltDriveOptions): BeltDriveResult` — Create a flat open-belt body around two pulley pitch circles.
105
158
 
106
- **Gear bodies:** `gearBodies.disk`, `gearBodies.diskWithHub`, `gearBodies.spoked`, `gearBodies.fromProfile` plus direct aliases `gearBodyDisk`, `gearBodyDiskWithHub`, `gearBodySpoked`, `gearBodyFromProfile`
159
+ The belt is generated as a tangent loop in the XY plane and extruded along +Z by `beltWidth`. The result includes the solid belt, the 2D belt profile, a thin pitch-path sketch for visualization, total belt length, tangent spans, and wrap metadata for each pulley.
107
160
 
108
- **Gear ratios (pure math helpers):** `gearRatio`, `rackRatio`, `planetaryRatio`
161
+ For more than two pulleys, the API intentionally asks for route intent before geometry is created. Use `route: "outer"` for the future outside-envelope mode, or an ordered route for future serpentine/idler layouts.
109
162
 
110
- **Bolt patterns:** `boltPattern` — define hole positions once, cut them from multiple parts
163
+ ```ts
164
+ const drive = lib.beltDrive({
165
+ pulleys: [
166
+ { name: "motor", center: [0, 0], pitchRadius: 12 },
167
+ { name: "output", center: [80, 0], pitchRadius: 28 },
168
+ ],
169
+ beltWidth: 8,
170
+ beltThickness: 2,
171
+ });
172
+ return drive.belt;
173
+ ```
174
+ - `tangentLoop2d(circles: TangentCircle2D[], options?: TangentLoop2DOptions): TangentLoop2D` — Build a closed 2D route made from common tangent spans and pulley wrap arcs.
111
175
 
112
- **Utilities:** `explode`
176
+ Use this when you need reusable belt/chain route geometry before creating a solid body. The first implementation supports two circles. `mode: "open"` uses external tangents; `mode: "crossed"` uses internal tangents.
113
177
 
114
- Sizes outside the supported ranges will throw at runtime with a descriptive error.
178
+ ```ts
179
+ const route = lib.tangentLoop2d([
180
+ { center: [0, 0], radius: 12 },
181
+ { center: [80, 0], radius: 28 },
182
+ ]);
183
+ const belt = route.offsetBand(2).extrude(8);
184
+ ```
185
+ - `tSlotProfile(options?: TSlotProfileOptions): Sketch` — Build a 2D T-slot cross-section sketch.
115
186
 
116
- - `boltHole(diameter: number, depth: number): Shape` — Simple cylindrical through-hole cutter centered on Z=0. Subtract the result from a part to produce a plain cylindrical clearance hole. For ISO metric sizes with fit classes and counterbore/countersink, use {
117
- - `fastenerHole(opts: FastenerHoleOptions): Shape` — ISO metric fastener hole cutter with optional counterbore or countersink. **Details** Returns a cutter shape (subtract from a solid to produce the hole). Sizes outside M2–M10 will throw. Extend `METRIC_HOLE_TABLE` in this file to add new sizes. **Example** ```ts const plate = box(60, 40, 8) .subtract(lib.fastenerHole({ size: 'M5', fit: 'normal', depth: 8 }) .translate(15, 10, 4)); ```
118
- - `counterbore(holeDia: number, boreDia: number, boreDepth: number, totalDepth: number): Shape` — Counterbore hole cutter — through-hole with a wider cylindrical recess at the top. Use for socket-head cap screws that must sit flush. Subtract from a solid. For ISO metric sizing and fit classes, prefer {
119
- - `tube(outerX: number, outerY: number, outerZ: number, wall: number): Shape` — Rectangular hollow tube (thin-wall box section). Both the outer and inner boxes are centered on the XY plane with their base at Z=0.
120
- - `pipe(height: number, outerRadius: number, wall: number, segments?: number): Shape` — Hollow cylindrical pipe. Centered on the XY plane, extending upward along +Z from z=0 to z=height. For complex routed pipe geometry, see `lib.pipeRoute`.
121
- - `explode<T extends ExplodeItem[] | ShapeGroup>(items: T, options?: ExplodeOptions): T` — Apply deterministic exploded-view offsets to an assembly tree. **Details** Traverses arrays of shapes/sketches/named items, nested `{ name, group: [...] }` structures, and [`ShapeGroup`](/docs/core#shapegroup) outputs, translating each node by a computed offset while preserving names, colors, and nesting. Returns the same structure type as the input. In `radial` mode the algorithm is branch-aware and parent-relative: each node fans out from its immediate parent's center, so nested assemblies peel apart level by level. Named items may also include an inline `explode: { stage?, direction?, axisLock? }` property to override per-item behavior. Use this function when you want to bake the explode offset into the geometry before returning (e.g. to drive the amount with a `param()` slider). For a viewport-only explode slider without rerunning the script, use [`explodeView()`](/docs/viewport#explodeview) instead. **Example** ```js const explodeAmt = param('Explode', 0, { min: 0, max: 40, unit: 'mm' }); return lib.explode(assembly, { amount: explodeAmt, stages: [0.4, 0.8], mode: 'radial', byName: { Shaft: { direction: [1, 0, 0], stage: 1.4 } }, }); ```
122
- - `hexNut(acrossFlats: number, height: number, holeDia: number): Shape` — Generic hex nut with a cylindrical bore. Constructed via intersection of three rotated rectangular slabs, then a bore is subtracted. Centered at origin, height along Z. For standard ISO metric nuts by thread size, use `lib.nut` instead.
123
- - `bracket(width: number, height: number, depth: number, thick: number, holeDia?: number): Shape` — L-shaped mounting bracket with optional through-holes. Produces a right-angle bracket: a horizontal base plate and a vertical wall. Both legs share `width`. Optional holes are drilled through the base (along Z) and the wall (along Y).
124
- - `holePattern(rows: number, cols: number, spacingX: number, spacingY: number, holeDia: number, depth: number): Shape` — Rectangular grid of cylindrical hole cutters. Returns the union of `rows × cols` cylinders laid out on a regular grid. Subtract from a solid to produce the full pattern. **Example** ```ts const pattern = lib.holePattern(3, 4, 20, 20, 4, 10); const panel = box(80, 70, 10).subtract(pattern.translate(-30, -20, 0)); ```
125
- - `thread(diameter: number, pitch: number, length: number, options?: { depth?: number; segments?: number; }): Shape` — External helical thread — clean mesh, no SDF grid artifacts. **Details** Builds a cross-section with a single trapezoidal tooth from the root radius out to the crest radius, then twist-extrudes it so the tooth traces a helix. Manifold's extrude+twist produces structured quad-based geometry that follows the thread profile cleanly. Returns a threaded cylinder along +Z from z=0 to z=length. **Example** ```ts const t = lib.thread(5, 0.8, 12); // M5 × 0.8 pitch, 12 mm long ```
126
- - `bolt(diameter: number, length: number, options?: { ... }): Shape` — ISO-style hex bolt with real helical threads. **Details** The hex head sits from z=0 up to z=headHeight. The shaft extends downward along −Z by `length` mm. An unthreaded shank section is included when `threadLength < length`. Default proportions follow ISO 4762 loosely: pitch ≈ 0.15×diameter, head height ≈ 0.65×diameter, across-flats ≈ 1.6×diameter. For standard M-size bolts pre-configured for a complete joint, use { **Example** ```ts const b = lib.bolt(5, 20); // M5 × 20 mm ```
127
- - `nut(diameter: number, options?: { pitch?: number; height?: number; acrossFlats?: number; segments?: number; }): Shape` — ISO-style hex nut with a threaded bore. **Details** Constructed from the intersection of three rotated slabs with a cylindrical bore subtracted. The nut is centered at the origin, height along Z. Default proportions follow ISO 4032 loosely: height ≈ 0.8×diameter, across-flats ≈ 1.6×diameter. The bore is a clearance bore (not modelled with helical threads) for rendering efficiency. For standard M-size nuts pre-configured for a complete joint, use { **Example** ```ts const n = lib.nut(5); // M5 nut ```
128
- - `washer(size: MetricSize, options?: { standard?: WasherStandard; segments?: number; }): Shape` — ISO metric flat washer (DIN 125-A). **Details** Returns a flat ring centered at the origin, thickness along Z. Dimensions are taken from { **Example** ```ts const w = lib.washer('M5'); // DIN 125-A M5 washer ```
129
- - `fastenerSet(size: MetricSize, boltLength: number, options?: FastenerSetOptions): FastenerSetResult` — Complete ISO metric fastener set — bolt, nut, optional washers, and matching hole cutters. **Details** Returns all geometry for one bolted joint: the bolt, nut, up to two washers, a clearance-hole cutter, and a tap-drill cutter. All shapes are returned **un-positioned** (each on the Z-axis). Place them with `.translate()`. Sizes outside M4–M10 are supported for the washer (M2–M10); unsupported combinations will throw. **Example** ```ts const hw = lib.fastenerSet('M5', 20); const topPlate = box(60, 40, 8).translate(0, 0, 12) .subtract(hw.clearanceHole.translate(15, 10, 12)); const botPlate = box(60, 40, 8) .subtract(hw.clearanceHole.translate(15, 10, 0)); return [ { name: 'Top Plate', shape: topPlate }, { name: 'Bot Plate', shape: botPlate }, { name: 'Bolt', shape: hw.bolt.translate(15, 10, 20) }, { name: 'Nut', shape: hw.nut.translate(15, 10, -4) }, ]; ```
130
- - `pipeRoute(points: [ number, number, number ][], radius: number, options?: { bendRadius?: number; wall?: number; segments?: number; }): Shape` — Route a pipe (solid or hollow) through 3D waypoints with smooth bends. This is a convenience recipe over `Curve.Route.fromPolyline()` and [`sweep()`](/docs/curves#sweep). Use `Curve.Route` directly when you need route metadata, named ports, or custom swept profiles.
131
- - `elbow(pipeRadius: number, bendRadius: number, angle?: number | { ... }, options?: { ... }): Shape` — Pipe elbow — a curved pipe section for connecting two pipe directions. This is a convenience recipe over `Curve.Arc()` and [`sweep()`](/docs/curves#sweep). Use `Curve.Route.fromPolyline()` directly when you need named route ports, segment metadata, or multi-bend pipe runs.
132
- - `beltDrive(options: BeltDriveOptions): BeltDriveResult` — Create a flat open-belt body around two pulley pitch circles. The belt is generated as a tangent loop in the XY plane and extruded along +Z by `beltWidth`. The result includes the solid belt, the 2D belt profile, a thin pitch-path sketch for visualization, total belt length, tangent spans, and wrap metadata for each pulley. For more than two pulleys, the API intentionally asks for route intent before geometry is created. Use `route: "outer"` for the future outside-envelope mode, or an ordered route for future serpentine/idler layouts. ```ts const drive = lib.beltDrive({ pulleys: [ { name: "motor", center: [0, 0], pitchRadius: 12 }, { name: "output", center: [80, 0], pitchRadius: 28 }, ], beltWidth: 8, beltThickness: 2, }); return drive.belt; ```
133
- - `tangentLoop2d(circles: TangentCircle2D[], options?: TangentLoop2DOptions): TangentLoop2D` — Build a closed 2D route made from common tangent spans and pulley wrap arcs. Use this when you need reusable belt/chain route geometry before creating a solid body. The first implementation supports two circles. `mode: "open"` uses external tangents; `mode: "crossed"` uses internal tangents. ```ts const route = lib.tangentLoop2d([ { center: [0, 0], radius: 12 }, { center: [80, 0], radius: 28 }, ]); const belt = route.offsetBand(2).extrude(8); ```
134
- - `tSlotProfile(options?: TSlotProfileOptions): Sketch` — Build a 2D T-slot cross-section sketch. Default parameters describe a 20x20 B-type profile with slot 6. Use this when you want a drawing-ready profile sketch before extrusion.
187
+ Default parameters describe a 20x20 B-type profile with slot 6. Use this when you want a drawing-ready profile sketch before extrusion.
135
188
  - `tSlotExtrusion(length: number, options?: TSlotExtrusionOptions): Shape` — Build a T-slot extrusion from the generated 2D profile. Extrudes along +Z by default.
136
- - `profile2020BSlot6Profile(options?: Profile2020BSlot6ProfileOptions): Sketch` — Accurate-ish 2D profile for 20x20 B-type slot 6. Returns a drawing-ready Sketch centered at origin.
137
- - `profile2020BSlot6(length: number, options?: Profile2020BSlot6Options): Shape` — 20x20 B-type slot 6 extrusion with profile-accurate defaults. Pass option overrides if your supplier's profile differs slightly.
138
- - `spurGear(options: SpurGearOptions): Shape` — Involute external spur gear with optional center bore. Specify module, teeth, faceWidth as required parameters. Optional tuning includes pressureAngleDeg (default 20), backlash, clearance, addendum, dedendum, boreDiameter, and segmentsPerTooth (default 10). **Connectors (for assembly-based positioning):** - `bore`: revolute connector at the bore center, axis along +Z. Carries measurements: `{ module, teeth, pitchRadius, outerRadius, faceWidth }`. Use `.connect("Housing.seat", "Gear.bore")` to mount a gear on a shaft seat.
139
- - `bevelGear(options: BevelGearOptions): Shape` — Conical bevel gear generated from a tapered involute extrusion. Specify pitchAngleDeg directly or derive it from mateTeeth + shaftAngleDeg. **Connectors (for assembly-based positioning):** - `bore`: revolute connector at the large-end bore center (Z=0), axis along -Z (away from teeth). - `apex`: connector at the cone apex above the gear (the point where the pitch cone converges), axis along +Z. Useful for meshing two bevel gears — their apices should coincide. Carries measurements: `{ module, teeth, pitchRadius, pitchAngleDeg, coneDistance, faceWidth }`.
140
- - `faceGear(options: FaceGearOptions): Shape` — Face gear (crown style) where teeth are on one face (top or bottom) instead of the outer rim. Uses the same involute tooth sizing as spurGear, then projects the tooth band axially from one side. Alias for sideGear (which is kept for backward compatibility).
141
- - `sideGear(options: SideGearOptions): Shape` Crown/face style gear where the teeth project from one side of the disk instead of the outer cylindrical rim.
142
- - `ringGear(options: RingGearOptions): Shape` — Internal ring gear with involute-derived tooth spaces. Specify rimWidth or outerDiameter for the annular body. **Connectors (for assembly-based positioning):** - `bore`: connector at the ring center, axis along +Z. For planetary gearboxes, this is where the ring mounts to the housing. Carries measurements: `{ module, teeth, pitchRadius, innerRadius, outerRadius, faceWidth }`.
143
- - `rackGear(options: RackGearOptions): Shape` — Linear rack gear with pressure-angle flanks. Use with spurGear for rack-and-pinion mechanisms. **Orientation:** teeth run along the X axis with tooth tips pointing +Y (pitch line at Y=0). The rack is extruded +Z by `faceWidth`. Rotate the rack to align with a different slide axis. **Connectors (for assembly-based positioning):** - `teeth`: prismatic connector at the pitch line center, axis along +X (slide direction). Carries measurements: `{ module, teeth, faceWidth, length }`. Connect to a housing's rack channel: ```js housing.withConnectors({ rack_channel: connector("rack-channel", { origin: [pitchR, 0, channelZ], axis: [1, 0, 0], kind: "prismatic", }), }); assembly.connect("Housing.rack_channel", "Rack.teeth", { as: "slide" }); ```
144
- - `gearPair(options: GearPairOptions): GearPairResult` — Build or validate a spur-gear pair and return ratio, backlash, and mesh diagnostics. Accepts either shapes from spurGear() or analytical specs for each member. When place is true (default), the gear is auto-positioned at the correct center distance.
189
+ - `profile2020BSlot6Profile(options?: Profile2020BSlot6ProfileOptions): Sketch` — Accurate-ish 2D profile for 20x20 B-type slot 6.
190
+
191
+ Returns a drawing-ready Sketch centered at origin.
192
+ - `profile2020BSlot6(length: number, options?: Profile2020BSlot6Options): Shape` — 20x20 B-type slot 6 extrusion with profile-accurate defaults.
193
+
194
+ Pass option overrides if your supplier's profile differs slightly.
195
+ - `spurGear(options: SpurGearOptions): Shape` — Involute external spur gear with optional center bore.
196
+
197
+ Specify module, teeth, faceWidth as required parameters. Optional tuning includes pressureAngleDeg (default 20), backlash, clearance, addendum, dedendum, boreDiameter, and segmentsPerTooth (default 10).
198
+
199
+ **Connectors (for assembly-based positioning):**
200
+
201
+ - `bore`: revolute connector at the bore center, axis along +Z. Carries measurements: `{ module, teeth, pitchRadius, outerRadius, faceWidth }`.
202
+
203
+ Use `.connect("Housing.seat", "Gear.bore")` to mount a gear on a shaft seat.
204
+ - `bevelGear(options: BevelGearOptions): Shape` — Conical bevel gear generated from a tapered involute extrusion. Specify pitchAngleDeg directly or derive it from mateTeeth + shaftAngleDeg.
205
+
206
+ **Connectors (for assembly-based positioning):**
207
+
208
+ - `bore`: revolute connector at the large-end bore center (Z=0), axis along -Z (away from teeth).
209
+ - `apex`: connector at the cone apex above the gear (the point where the pitch cone converges), axis along +Z. Useful for meshing two bevel gears — their apices should coincide.
210
+
211
+ Carries measurements: `{ module, teeth, pitchRadius, pitchAngleDeg, coneDistance, faceWidth }`.
212
+ - `faceGear(options: FaceGearOptions): Shape` — Face gear (crown style) where the teeth project axially from one face (top or bottom) of the disk instead of the outer cylindrical rim.
213
+
214
+ Uses the same involute tooth sizing as spurGear, then projects the tooth band axially from the chosen side (`side`, default `'top'`) with axial tooth height `toothHeight` (default: one module). To mesh it with a perpendicular spur pinion, prefer `lib.faceGearPair()` — it rotates and positions the pinion at the face tooth band for you.
215
+
216
+ **Connectors (for assembly-based positioning):**
217
+
218
+ - `bore`: revolute connector at the bore center on the body side (the face opposite the teeth), axis pointing away from the teeth. Carries measurements: `{ module, teeth, pitchRadius, outerRadius, faceWidth, toothSide }`.
219
+
220
+ ```js
221
+ const crown = lib.faceGear({ module: 1.5, teeth: 30, faceWidth: 5, boreDiameter: 6 });
222
+ assembly().connect("Housing.crown_seat", "Crown.bore");
223
+ ```
224
+ - `ringGear(options: RingGearOptions): Shape` — Internal ring gear with involute-derived tooth spaces. Specify rimWidth or outerDiameter for the annular body.
225
+
226
+ **Connectors (for assembly-based positioning):**
227
+
228
+ - `bore`: connector at the ring center, axis along +Z. For planetary gearboxes, this is where the ring mounts to the housing. Carries measurements: `{ module, teeth, pitchRadius, innerRadius, outerRadius, faceWidth }`.
229
+ - `rackGear(options: RackGearOptions): Shape` — Linear rack gear with pressure-angle flanks. Use with spurGear for rack-and-pinion mechanisms.
230
+
231
+ **Orientation:** teeth run along the X axis with tooth tips pointing +Y (pitch line at Y=0). The rack is extruded +Z by `faceWidth`. Rotate the rack to align with a different slide axis.
232
+
233
+ **Connectors (for assembly-based positioning):**
234
+
235
+ - `teeth`: prismatic connector at the pitch line center, axis along +X (slide direction). Carries measurements: `{ module, teeth, faceWidth, length }`.
236
+
237
+ Connect to a housing's rack channel:
238
+
239
+ ```js
240
+ housing.withConnectors({
241
+ rack_channel: connector("rack-channel", {
242
+ origin: [pitchR, 0, channelZ], axis: [1, 0, 0], kind: "prismatic",
243
+ }),
244
+ });
245
+ assembly.connect("Housing.rack_channel", "Rack.teeth", { as: "slide" });
246
+ ```
247
+ - `gearPair(options: GearPairOptions): GearPairResult` — Build or validate a spur-gear pair and return ratio, backlash, and mesh diagnostics.
248
+
249
+ Accepts either shapes from spurGear() or analytical specs for each member. When place is true (default), the gear is auto-positioned at the correct center distance.
145
250
  - `bevelGearPair(options: BevelGearPairOptions): BevelGearPairResult` — Build or validate a bevel-gear pair and return ratio diagnostics plus recommended joint placement vectors.
146
- - `faceGearPair(options: FaceGearPairOptions): FaceGearPairResult` — Build or validate a perpendicular pair between a face gear and a vertical spur gear.
147
- - `sideGearPair(options: SideGearPairOptions): SideGearPairResult` Pair helper for side (crown/face) gear + perpendicular "vertical" spur gear. Auto-placement rotates the spur around +Y and positions it to mesh at the side tooth band.
148
- - `gearRatio(teethA: number, teethB: number, options?: { internal?: boolean; }): number` — Coupling ratio between two meshed spur gears. When gear A turns 1°, gear B turns `-teethA / teethB` degrees (negative because meshed external gears rotate in opposite directions). Pass `{ internal: true }` for internal gear pairs (ring gear + spur/planet), where the two rotate in the same direction.
149
- - `rackRatio(module: number, pinionTeeth: number): number` — Coupling ratio between a pinion and a rack. When the pinion rotates by `θ` degrees, the rack slides by `θ × (π × module × teeth / 360)` mm. Equivalently, 1mm of rack travel = `180 / (π × pitchRadius)` degrees of pinion rotation.
150
- - `planetaryRatio(sunTeeth: number, ringTeeth: number): number` — Planetary gear reduction ratio when the ring is held fixed. Input: sun. Output: carrier. Ratio: `1 + ringTeeth / sunTeeth`. One turn of the sun produces `1 / ratio` turns of the carrier.
151
- - `boltPattern(options: BoltPatternOptions): BoltPattern` — Define a bolt pattern once and cut it from multiple parts. const base = bolts.cut(box(60, 50, 10), 12, { from: -1 }); const cover = bolts.cut(box(60, 50, 3), 5, { from: -1 }); // Same positions in both parts — guaranteed aligned. ```
251
+ - `faceGearPair(options: FaceGearPairOptions): FaceGearPairResult` — Pair helper for a face (crown) gear + perpendicular "vertical" spur gear. Auto-placement rotates the spur around +Y and positions it to mesh at the face tooth band.
252
+ - `gearRatio(teethA: number, teethB: number, options?: { internal?: boolean; }): number` Coupling ratio between two meshed spur gears.
253
+
254
+ When gear A turns 1°, gear B turns `-teethA / teethB` degrees (negative because meshed external gears rotate in opposite directions).
255
+
256
+ ```js
257
+ const drivenPerDriver = lib.gearRatio(12, 24); // -0.5
258
+ verify.equal("external spur ratio", drivenPerDriver, -0.5);
259
+
260
+ Pass `{ internal: true }` for internal gear pairs (ring gear + spur/planet),
261
+ where the two rotate in the same direction.
262
+ ```
263
+ - `rackRatio(module: number, pinionTeeth: number): number` — Coupling ratio between a pinion and a rack.
264
+
265
+ When the pinion rotates by `θ` degrees, the rack slides by `θ × (π × module × teeth / 360)` mm. Equivalently, 1mm of rack travel = `180 / (π × pitchRadius)` degrees of pinion rotation.
266
+
267
+ ```js
268
+ const pinionDegPerMm = lib.rackRatio(1.5, 12); // ~6.37 deg/mm
269
+ ```
270
+ - `planetaryRatio(sunTeeth: number, ringTeeth: number): number` — Planetary gear reduction ratio when the ring is held fixed.
271
+
272
+ Input: sun. Output: carrier. Ratio: `1 + ringTeeth / sunTeeth`. One turn of the sun produces `1 / ratio` turns of the carrier.
273
+ - `boltPattern(options: BoltPatternOptions): BoltPattern` — Define a bolt pattern once and cut it from multiple parts.
274
+
275
+ ```js
276
+ const bolts = lib.boltPattern({
277
+ size: 'M5',
278
+ positions: [[20, 15], [-20, 15], [20, -15], [-20, -15]],
279
+ });
280
+
281
+ const base = bolts.cut(box(60, 50, 10), 12, { from: -1 });
282
+ const cover = bolts.cut(box(60, 50, 3), 5, { from: -1 });
283
+ // Same positions in both parts — guaranteed aligned.
284
+ ```
152
285
  - `driveWheel(options?: DriveWheelOptions): DriveWheelBuilder` — Start a composable exceptional gear or drive wheel.
153
286
  - `readDriveWheelMeta(shape: Shape): DriveWheelMeta | null` — Read the functional-region metadata attached by `driveWheel().build()`.
154
- - `sectorGear(options: SectorGearOptions): Shape` — Involute sector gear with teeth on only part of the pitch circle. Specify the full-circle pitch as `teethOnFullCircle`, then choose the active tooth window with `firstTooth` and `toothCount`. The body is separate from the tooth region: pass a `gearBody...` shape for spokes, hubs, and product styling, or omit it for a simple root-radius disk. **Example** ```ts const body = lib.gearBodies.spoked({ outerRadius: 22, rimWidth: 3, hubDiameter: 10, spokeCount: 5, spokeWidth: 2.5, faceWidth: 8, boreDiameter: 5, }); const sector = lib.sectorGear({ module: 1.25, teethOnFullCircle: 36, toothCount: 10, faceWidth: 8, body, }); ```
287
+ - `sectorGear(options: SectorGearOptions): Shape` — Involute sector gear with teeth on only part of the pitch circle.
288
+
289
+ Specify the full-circle pitch as `teethOnFullCircle`, then choose the active tooth window with `firstTooth` and `toothCount`. The body is separate from the tooth region: pass a `gearBody...` shape for spokes, hubs, and product styling, or omit it for a simple root-radius disk.
290
+
291
+ ```ts
292
+ const body = lib.gearBodies.spoked({
293
+ outerRadius: 22, rimWidth: 3, hubDiameter: 10,
294
+ spokeCount: 5, spokeWidth: 2.5, faceWidth: 8, boreDiameter: 5,
295
+ });
296
+ const sector = lib.sectorGear({
297
+ module: 1.25, teethOnFullCircle: 36, toothCount: 10,
298
+ faceWidth: 8, body,
299
+ });
300
+ ```
155
301
  - `gearBodies: { ... }` — Gear body preset namespace: disk, diskWithHub, spoked, and fromProfile.
156
- - `gearBodyDisk(options: GearBodyDiskOptions): Shape` — Solid disk/ring gear body, independent from any tooth geometry.
157
- - `gearBodyDiskWithHub(options: GearBodyDiskWithHubOptions): Shape` — Disk gear body with a raised center hub.
158
- - `gearBodySpoked(options: GearBodySpokedOptions): Shape` — Spoked gear body with an outer rim, center hub, and radial spokes.
159
- - `gearBodyFromProfile(profile: Sketch, options: GearBodyFromProfileOptions): Shape` — Extrude a custom 2D profile into a gear body.
@@ -9,14 +9,14 @@ Dimensions, BOM entries, verification checks, and sketch export.
9
9
 
10
10
  ## Contents
11
11
 
12
- - [Annotations & Output](#annotations-output) — `bom`, `robotExport`, `dim`, `dimLine`
13
- - [Sketch Export](#sketch-export) — `sketchToDxf`, `sketchToSvg`
12
+ - [Annotations & Output](#annotations-output)
13
+ - [Sketch Export](#sketch-export)
14
14
 
15
15
  ## Functions
16
16
 
17
17
  ### Annotations & Output
18
18
 
19
- #### `bom()` — Register a Bill of Materials entry for report export.
19
+ #### `bom(quantity: number, description: string, opts?: BomOpts): void` — Register a Bill of Materials entry for report export.
20
20
 
21
21
  BOM entries are accumulated during script execution and exported alongside the model in report views. Rows are grouped by normalized `description + unit`. Pass an explicit `key` to force multiple descriptions to collapse into a single line item.
22
22
 
@@ -42,10 +42,6 @@ bom(tubeLen, "rectangular steel tube", {
42
42
  });
43
43
  ```
44
44
 
45
- ```ts
46
- bom(quantity: number, description: string, opts?: BomOpts): void
47
- ```
48
-
49
45
  **`BomOpts`**
50
46
 
51
47
  | Option | Type | Description |
@@ -62,9 +58,9 @@ bom(quantity: number, description: string, opts?: BomOpts): void
62
58
  | `notes?` | `string` | Free-form notes |
63
59
  | `grain?` | `string` | Wood grain direction, e.g. "long", "cross" |
64
60
 
65
- #### `robotExport()` — Declare that this script should export the assembly as a SDF/URDF robot package.
61
+ #### `robotExport(options: RobotExportOptions): CollectedRobotExport` — Declare that this script should export the assembly as a SDF/URDF robot package.
66
62
 
67
- Call `robotExport()` alongside your assembly definition. The CLI commands `forgecad export sdf` and `forgecad export urdf` pick up the declaration and produce a robot package with:
63
+ Call `robotExport()` alongside your assembly definition. `forgecad export sdf` / `forgecad export urdf` pick up the declaration (see the CLI docs for flags) and produce a robot package with:
68
64
 
69
65
  - Mesh-based inertia tensors (full 6-component, not bounding-box approximations)
70
66
  - Separate collision meshes (convex hull by default — ~50–80% smaller)
@@ -87,22 +83,10 @@ Call `robotExport()` alongside your assembly definition. The CLI commands `forge
87
83
  - Compatibility coupling metadata, when present, maps only the primary term (largest ratio) to `<mimic>` — SDF/URDF support single-leader mimic only. Dropped terms emit a warning.
88
84
 
89
85
  ```ts
90
- const rover = assembly("Scout")
91
- .addPart("Chassis", box(300, 220, 50).translate(0, 0, -25))
92
- .addPart("Left Wheel", cylinder(30, 60, undefined, 48).translate(0, 0, -15))
93
- .addRevolute("leftWheel", "Chassis", "Left Wheel", {
94
- axis: [0, 1, 0],
95
- frame: Transform.identity().translate(90, 140, 60),
96
- effort: 20, velocity: 1080,
97
- });
98
-
99
86
  robotExport({
100
- assembly: rover,
87
+ assembly: rover, // assembly() with parts + revolute wheel joints
101
88
  modelName: "Scout",
102
- links: {
103
- Chassis: { massKg: 10 },
104
- "Left Wheel": { massKg: 0.8 },
105
- },
89
+ links: { Chassis: { massKg: 10 }, "Left Wheel": { massKg: 0.8 } },
106
90
  plugins: {
107
91
  diffDrive: {
108
92
  leftJoints: ["leftWheel"], rightJoints: ["rightWheel"],
@@ -113,17 +97,6 @@ robotExport({
113
97
  });
114
98
  ```
115
99
 
116
- **CLI usage**
117
-
118
- ```bash
119
- forgecad export sdf model.forge.js # SDF package (Gazebo/Ignition)
120
- forgecad export urdf model.forge.js # URDF package (ROS/PyBullet/MuJoCo)
121
- ```
122
-
123
- ```ts
124
- robotExport(options: RobotExportOptions): CollectedRobotExport
125
- ```
126
-
127
100
  **`RobotExportOptions`**: `assembly: Assembly`, `modelName?: string`, `state?: JointState`, `static?: boolean`, `selfCollide?: boolean`, `allowAutoDisable?: boolean`, `links?: Record<string, RobotLinkExportOptions>`, `joints?: Record<string, RobotJointExportOptions>`, `plugins?: { diffDrive?: RobotDiffDrivePluginOptions; jointStatePublisher?: RobotJointStatePublisherOptions; }`, `world?: RobotWorldOptions`
128
101
 
129
102
  `RobotLinkExportOptions`: `{ massKg?: number, densityKgM3?: number, collision?: "visual" | "convex" | "box" | "none" }`
@@ -144,21 +117,13 @@ robotExport(options: RobotExportOptions): CollectedRobotExport
144
117
 
145
118
  **`AssemblyPartDef`**: `name: string`, `part: AssemblyPart`, `base: Transform`, `metadata?: PartMetadata`, `mates: AssemblyPartMateInput[]`, `bindToFrame?: string`
146
119
 
147
- **`PartMetadata`**
148
-
149
- | Option | Type | Description |
150
- |--------|------|-------------|
151
- | `tags?` | `string \| readonly string[]` | Viewport organization tags applied to scene objects produced from this part. |
152
- | `material?`, `process?`, `tolerance?`, `qty?`, `notes?`, `densityKgM3?`, `massKg?` | | — |
120
+ `PartMetadata` — defined in [assembly](/docs/assembly).
153
121
 
154
- **`AssemblyPartMateInput`**
155
- - `connector: string` — Name of a connector declared on the part (via `withConnectors()`).
156
- - `toLink: string` — Name of the link this connector's origin is pinned to.
157
- - `aimLink?: string` — Optional second link to orient toward. When set, the part is rotated so the connector's **axis** aims from `toLink` toward `aimLink`, posing an oriented bone instead of only translating it. For full pose without relying on a connector axis, declare a second mate (two connectors → two links).
122
+ `AssemblyPartMateInput` — defined in [assembly](/docs/assembly).
158
123
 
159
124
  **`AssemblyJointDef`**: `name: string`, `type: JointType`, `parent: string`, `child: string`, `frame: Transform`, `axis: Vec3`, `min?: number`, `max?: number`, `defaultValue: number`, `unit?: string`, `effort?: number`, `velocity?: number`, `damping?: number`, `friction?: number`, `connectorRefs?: JointConnectorRefs`
160
125
 
161
- `JointConnectorRefs`: `{ parent: string, child: string, parentAlign?: PortAlign, childAlign?: PortAlign }`
126
+ `JointConnectorRefs` defined in [assembly](/docs/assembly).
162
127
 
163
128
  `AssemblyJointCouplingDef`: `{ joint: string, terms: JointCouplingTermRecord[], offset: number }`
164
129
 
@@ -170,13 +135,15 @@ robotExport(options: RobotExportOptions): CollectedRobotExport
170
135
 
171
136
  **`AssemblyEdgeBetweenLinksDef`**: `name: string`, `a: string`, `b: string`, `length: number | null`, `min?: number`, `max?: number`, `visualOnly: boolean`, `control?: AssemblyKinematicControlOptions`, `metadata?: Record<string, unknown>`
172
137
 
173
- `AssemblyKinematicControlOptions`: `{ min?: number, max?: number, default?: number, unit?: string }`
138
+ `AssemblyKinematicControlOptions` defined in [assembly](/docs/assembly).
174
139
 
175
140
  **`AssemblyAngleBetweenLinksDef`**: `name: string`, `a?: string`, `b: string`, `c: string`, `reference?: AssemblyAngleReferenceDef`, `target?: number`, `min?: number`, `max?: number`, `control?: AssemblyKinematicControlOptions`, `metadata?: Record<string, unknown>`
176
141
 
177
142
  `AssemblyAngleReferenceDef`: `{ kind: "worldDirection", direction: Vec3 }`
178
143
 
179
- `AssemblyDerivedLinkDef`: `{ name: string, fromLink: string, referenceLink: string, distance: number, direction: AssemblyDerivedLinkDirection }`
144
+ **`AssemblyDerivedLinkDef`**
145
+ - `distance: number` — Signed: positive moves from `fromLink` toward `towardLink`, negative moves away.
146
+ - Also: `name: string`, `fromLink: string`, `towardLink: string`.
180
147
 
181
148
  `AssemblyFrameDef`: `{ name: string, origin: Vec3, axis: Vec3, up: Vec3, fixed: boolean, metadata?: Record<string, unknown> }`
182
149
 
@@ -184,12 +151,20 @@ robotExport(options: RobotExportOptions): CollectedRobotExport
184
151
 
185
152
  `AssemblyFrameEdgeDef`: `{ name: string, a: string, b: string, metadata?: Record<string, unknown> }`
186
153
 
187
- #### `dim()` — Add a dimension annotation between two points.
154
+ #### `dim()` — Add a dimension annotation between two points, or along an entity.
155
+
156
+ Overloads:
157
+
158
+ - `dim(line: Line2D, opts?: DimOpts): void`
159
+ - `dim(edge: EdgeRef, opts?: DimOpts): void`
160
+ - `dim(from: PointArg, to: PointArg, opts?: DimOpts): void`
188
161
 
189
162
  Dimension annotations are purely visual callouts rendered in the viewport and report export. They do not affect geometry or constrain the model.
190
163
 
191
164
  Point arguments accept 2D tuples `[x, y]`, 3D tuples `[x, y, z]`, or [`Point2D`](/docs/sketch#point2d) objects (Z is treated as 0 for 2D inputs).
192
165
 
166
+ Entity arguments: pass a single [`Line2D`](/docs/sketch#line2d) (from a constrained sketch) or an `EdgeRef` (from `shape.edge('left')`) as the first argument to dimension along that entity directly — no manual endpoint extraction needed.
167
+
193
168
  **Ownership Rules (Report Pages)**
194
169
 
195
170
  - `currentComponent: true` — deterministic ownership by the calling import instance. Use when authoring reusable imported parts.
@@ -201,33 +176,31 @@ Point arguments accept 2D tuples `[x, y]`, 3D tuples `[x, y, z]`, or [`Point2D`]
201
176
  dim([-w / 2, 0, 0], [w / 2, 0, 0], { label: "Width" });
202
177
  dim([0, 0, -h / 2], [0, 0, h / 2], { label: "Height", offset: 14 });
203
178
  dim([0, 0, 0], [100, 0, 0], { component: "Base", color: "#00AAFF" });
179
+ dim(sk.line(a, b), { label: "Span", offset: -8 }); // Line2D entity
180
+ dim(myBox.edge("top-right"), { label: "Depth" }); // EdgeRef entity
204
181
  ```
205
182
 
206
- `component` (string or string[] report ownership), `currentComponent` (boolean)
183
+ [`Line2D`](/docs/sketch#line2d) / `EdgeRef` entity (then pass `opts` as the second argument)
207
184
 
208
- ```ts
209
- dim(from: PointArg, to: PointArg, opts?: DimOpts): void
210
- ```
185
+ `component` (string or string[] — report ownership), `currentComponent` (boolean)
211
186
 
212
187
  `DimOpts`: `{ offset?: number, label?: string, color?: string, component?: string | string[], currentComponent?: boolean }`
213
188
 
214
- #### `dimLine()` — Add a dimension annotation along a [`Line2D`](/docs/sketch#line2d).
189
+ **`EdgeRef`**
215
190
 
216
- Convenience wrapper around { points from a constrained-sketch [`Line2D`](/docs/sketch#line2d) entity. All `opts` are forwarded unchanged.
191
+ | Option | Type | Description |
192
+ |--------|------|-------------|
193
+ | `start` | `Vec3` | Start point |
194
+ | `end` | `Vec3` | End point |
195
+ | `query?` | `EdgeQueryRef` | Compiler-owned edge query when available. |
196
+ | `curve?` | `EdgeCurve` | Exact or parametric curve family when the backend/source can identify one. |
197
+ | `faceName?` | `string` | Owning face name when the edge is associated with one face in a larger topology. |
217
198
 
218
- ```ts
219
- const a = point(0, 0);
220
- const b = point(100, 0);
221
- dimLine(line(a, b), { label: "Span", offset: -8 });
222
- ```
223
-
224
- ```ts
225
- dimLine(l: Line2D, opts?: DimOpts): void
226
- ```
199
+ Also: `name: EdgeName`.
227
200
 
228
201
  ### Sketch Export
229
202
 
230
- #### `sketchToDxf()` — Export a 2D sketch as a DXF string (R12/AC1009 — maximally compatible).
203
+ #### `sketchToDxf(sketch: Sketch, options?: SketchDxfOptions): string` — Export a 2D sketch as a DXF string (R12/AC1009 — maximally compatible).
231
204
 
232
205
  For regular sketches, each polygon loop becomes a closed `LWPOLYLINE`. For constrained sketches, exports raw `LINE`, `CIRCLE`, and `ARC` entities from the constraint edge geometry, which preserves internal/shared edges that `toPolygons()` would merge away.
233
206
 
@@ -238,15 +211,11 @@ const s = rect(100, 60);
238
211
  const dxf = sketchToDxf(s, { layer: 'cut' });
239
212
  ```
240
213
 
241
- ```ts
242
- sketchToDxf(sketch: Sketch, options?: SketchDxfOptions): string
243
- ```
244
-
245
214
  **`SketchDxfOptions`**
246
215
  - `layer?: string` — DXF layer name. Default: "0"
247
216
  - `colorIndex?: number` — DXF color index (1–255, AutoCAD ACI). Default: 7 (white/black)
248
217
 
249
- #### `sketchToSvg()` — Export a 2D sketch as an SVG string.
218
+ #### `sketchToSvg(sketch: Sketch, options?: SketchSvgOptions): string` — Export a 2D sketch as an SVG string.
250
219
 
251
220
  For regular sketches, exports filled polygon regions. For constrained sketches, exports raw edge geometry (LINE, ARC, CIRCLE) which preserves internal/shared edges that `toPolygons()` would merge away.
252
221
 
@@ -257,10 +226,6 @@ const s = rect(100, 60);
257
226
  const svg = sketchToSvg(s, { stroke: '#333', strokeWidth: 0.8 });
258
227
  ```
259
228
 
260
- ```ts
261
- sketchToSvg(sketch: Sketch, options?: SketchSvgOptions): string
262
- ```
263
-
264
229
  **`SketchSvgOptions`**
265
230
 
266
231
  | Option | Type | Description |