Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/balltransferunit.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const definition = mp
const dimensions = getBallTransferUnitDimensions()
```

The roadmap spelling `_mount(face3hole)` is accepted as an alias for `_face3hole`.
Both produce `faceThreeHole: true`; repeated or mixed selectors are rejected.
The value-free flag `_face3hole` produces `faceThreeHole: true`. Repeated flags,
flags with values and enum selectors are rejected.
Only this circular three-hole construction is supported.

| Property | Tokens | Default (mm) |
Expand Down
11 changes: 8 additions & 3 deletions docs/button-screw.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Button screw parameter contract

`buttonscrew_m3_l10mm` selects ISO 7380-1:2022 (second edition) by default.
`buttonscrew_m3_l10mm_hexsocket_fullthread_righthanded` selects ISO 7380-1:2022 (second edition) by default.
The optional value-free flag in `buttonscrew_iso7380-1_m3_l10mm` selects the
same dimensions and normalizes to `iso73801: true`. The schemas reject false
ISO flags and the legacy `standard` property; `standard(...)` selectors,
Expand All @@ -27,8 +27,13 @@ is not claimed. Longer or partially threaded screws require a separate contract.

`m` and `l`/`length` are required. Length inputs accept millimeter numbers or
complete numeric strings with `mm`, `cm`, `m`, `in`, `inch`, `mil`, `ft`, or
`feet`; JSON normalizes them to mm. Selectors `drive(hexsocket)`, `thread(full)`,
`threadhand(right)`, and `threadclass(6g)` have those fixed defaults.
`feet`; JSON normalizes them to mm. The value-free flags `hexsocket` and
`fullthread` directly set the boolean props `hexSocket: true` and
`fullThread: true`; both fixed features default true. `righthanded` sets
`leftHanded: false`, its default and the only supported handedness in this family.
`lefthanded` is rejected. `threadclass(6g)` retains the ISO thread-class designation.
The former drive/thread/hand selector tokens and corresponding string properties
are rejected. Repeated and conflicting flags are rejected before schema validation.
`threadpitch` may explicitly restate the coarse pitch, including equivalent
units; fine pitch is rejected. `threads`/`nothreads` control `showThreads`, which
defaults true. Flags have no value. Duplicate tokens, alias conflicts, malformed
Expand Down
9 changes: 6 additions & 3 deletions docs/cable-grommet.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Cable grommet model strings

```
cablegrommet_panelhole20mm_id10mm_od24mm_h8mm_groovew3mm_grooved2mm_shape(symmetricring)
cablegrommet_panelhole20mm_id10mm_od24mm_h8mm_groovew3mm_grooved2mm_symmetricring
```

This custom nominal protection ring uses two equal circular flanges and a
centered annular panel groove. It selects no supplier series or dimensional
standard. `shape(symmetricring)` is the sole shape and defaults when omitted.
standard. The `symmetricRing` boolean defaults to `true`; `symmetricring` is a
value-free flag. Valued flags, old `shape(...)` tokens and `shape` properties
are rejected.
The six dimensions are required; no physical size is inferred.

| Token | Property | Meaning |
Expand All @@ -17,11 +19,12 @@ The six dimensions are required; no physical size is inferred.
| `h` | `height` | Overall axial height |
| `groovew` | `grooveWidth` | Axial groove width / nominal panel thickness |
| `grooved` | `grooveDepth` | Radial groove depth, not a diametral reduction |
| `symmetricring` | `symmetricRing` | Value-free flag, defaults to `true` |

The lowercase property spellings in the table also work as string tokens. All
lengths accept numbers in millimeters or unit strings (`mm`, `cm`, `m`, `in`,
`inch`, `mil`, `ft`, `feet`) and normalize to millimeters. Tokens, aliases, and
selectors are case insensitive. Repeated properties and unknown tokens fail.
flags are case insensitive. Repeated properties and unknown tokens fail.

The ring axis is Z. Its origin is the bore center in the panel midplane. The
body spans `-height/2 .. +height/2`; the groove spans
Expand Down
12 changes: 7 additions & 5 deletions docs/clamping-shaft-collar.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ Roadmap [#13, proposal 0018](https://github.com/tscircuit/modelprinter/issues/13
```ts
import { mp, getClampingShaftCollarDimensions } from "@tscircuit/modelprinter"

const model = mp.string("clampingshaftcollar_bore8mm_od18mm_w9mm_split1mm_mount(singleclamp)_m4").json()
const model = mp.string("clampingshaftcollar_bore8mm_od18mm_w9mm_split1mm_singleclamp_m4").json()
if (model.fn !== "clampingshaftcollar") throw new Error("Unexpected family")
const { fn, ...props } = model
const dimensions = getClampingShaftCollarDimensions(props)
```

The schema is `clampingShaftCollarModelPropsSchema`; the definition schema is `clampingShaftCollarModelDefinitionSchema`. Input/output/definition TypeScript types are exported, and the family participates in `modelDefinitionSchema` and `modelprinter.getModelNames()`. The dimension helper accepts properties without `fn`, validates them, and supplies exact cutter locations and depths for a downstream renderer. Modelprinter owns this contract; geometry is generated elsewhere.

All lengths normalize to millimeters. Numbers mean millimeters; strings accept a complete decimal with an optional `mm`, `cm`, `m`, `in`, `inch`, `mil`, `ft`, or `feet` suffix. Angles are degrees. Model strings are case insensitive; selectors require parentheses. Unknown fields/tokens, duplicate tokens (including aliases), missing required values, unrecognized units, trailing text, nonfinite values, and incompatible dimensions fail validation. Counts are unitless integers.
All lengths normalize to millimeters. Numbers mean millimeters; strings accept a complete decimal with an optional `mm`, `cm`, `m`, `in`, `inch`, `mil`, `ft`, or `feet` suffix. Angles are degrees. Model strings are case insensitive; flags take no values. Only the standard `_threadclass(6H)` designation uses parentheses. Unknown fields/tokens, duplicate tokens (including aliases), missing required values, unrecognized units, trailing text, nonfinite values, and incompatible dimensions fail validation. Counts are unitless integers.

The `_mN` token controls the female clamping/set-screw thread, not the axial shaft bore. It selects nominal ISO metric diameter, coarse pitch, and right hand. Supported nominal sizes/coarse pitches (mm): M2/0.4, M2.5/0.45, M3/0.5, M4/0.7, M5/0.8, M6/1, M8/1.25, M10/1.5, M12/1.75. `_threadpitch0.5mm` and `_threadhand(left)` override pitch and hand; pitch must be positive and less than diameter. `_threadclass(6H)` is the sole supported internal class and defaults to 6H. The contract defines nominal threaded cylindrical holes; tolerances and helical thread root/crest relief are not encoded. No screw is included.
The `_mN` token controls the female clamping/set-screw thread, not the axial shaft bore. It selects nominal ISO metric diameter, coarse pitch, and right hand. Supported nominal sizes/coarse pitches (mm): M2/0.4, M2.5/0.45, M3/0.5, M4/0.7, M5/0.8, M6/1, M8/1.25, M10/1.5, M12/1.75. `_threadpitch0.5mm` and `_lefthanded` override pitch and hand; pitch must be positive and less than diameter. `_threadclass(6H)` is the sole supported internal class and defaults to 6H. The contract defines nominal threaded cylindrical holes; tolerances and helical thread root/crest relief are not encoded. No screw is included.

| Token | JSON property | Default/meaning |
| --- | --- | --- |
| `bore` | `boreDiameter` | Required, plain shaft bore |
| `od` | `outerDiameter` | Required, cylindrical exterior |
| `m` | `metricSize` | Required, female mounting thread |
| `threadpitch` | `threadPitch` | Coarse pitch for `metricSize` |
| `threadhand(...)` | `threadHand` | `right`; also accepts `left` |
| `lefthanded`, `righthanded` | `leftHanded` | `false` (right handed); `_lefthanded` selects `true` |
| `threadclass(...)` | `threadClass` | Fixed `6H` |
| `chamfer` | `chamfer` | 0; equal 45-degree radial/axial setbacks at both outer end edges and both bore entries |
| `w`, `width` | `width` | Required axial width |
| `split` | `splitWidth` | Required slit width |
| `mount(...)` | `mount` | Fixed `singleclamp` |
| `singleclamp` | `singleClamp` | `true`; value-free fixed construction flag |
| `screwz` | `screwZ` | `width / 2`, from the lower face |
| `clampx` | `clampX` | `(outerDiameter+boreDiameter)/4`, halfway across the radial wall on +X |
| `clearance` | `clearanceHoleDiameter` | Thread diameter + 0.5 mm |
Expand All @@ -43,3 +43,5 @@ The clamp screw axis is +Y at X=`clampX`, Z=`screwZ`. It enters from -Y through
The extents deliberately cover the curved outer surface across each cylinder's full diameter. Hole depth is a fixed through-arm construction, not a blind depth selected from the thread size. The thread hole carries pitch, hand, female gender, and class.

Validation requires OD > bore, clearance diameter > thread diameter, and `bore/2 < clampX-clearance/2` with `clampX+clearance/2 < OD/2`, so neither cylindrical hole intersects the shaft bore or the radial exterior edges. The slit width must be less than the bore diameter and must leave a positive arm thickness at the outermost clearance-cylinder edge. The clearance hole must fit strictly between both end faces and their chamfers. A chamfer must be smaller than half the radial wall and half the width; derived dimensions must be finite.

The resolved JSON and hole dimensions contain `leftHanded: false` by default. `_lefthanded` selects `true` and `_righthanded` selects `false`. Repeated or conflicting hand flags are rejected. The old `mount(...)` and `threadhand(...)` selector tokens and `mount`/`threadHand` JSON properties are rejected.
8 changes: 3 additions & 5 deletions docs/compression-spring.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Compression spring parameter contract

`compressionspring_spec(custom)_od8mm_wire1mm_l20mm_turns8_active6_ends(closedground)_hand(right)_state(free)`
`compressionspring_custom_od8mm_wire1mm_l20mm_turns8_active6_closedground_righthanded_free`
selects custom construction version 1. This family defines an exact nominal
spring for assembly visualization; it does not claim a standard profile,
material stiffness, force, fatigue life or manufacturing tolerances.

Required tokens are `od` (outside diameter), `wire` (round-wire diameter),
`l`/`length`/`freelength` (free bearing-face separation), and `turns` (total
complete revolutions). `active` is optional and defaults to totalTurns-2.
`spec(custom)`, `ends(closedground)`, `hand(right)` and `state(free)` are defaults.
`hand(left)` mirrors winding. Only this end construction and free state are
`custom`, `closedground`, and `free` are optional value-free flags whose JSON properties `custom`, `closedGround`, and `free` default to `true`. `leftHanded` defaults to `false`; `_righthanded` selects that default explicitly and `_lefthanded` selects `true`, mirroring the winding. Only this end construction and free state are
supported; open ends, unground ends, variable-pitch coils and loaded/solid
poses require separate contracts. No `threadhand` token is used: winding is
independent of thread conventions.
poses require separate contracts. The old `spec(...)`, `ends(...)`, `hand(...)`, and `state(...)` selectors and their JSON properties are rejected. Repeated or conflicting hand flags are rejected.

All lengths accept positive finite millimeter numbers or complete numeric
strings with `mm`, `cm`, `m`, `in`, `inch`, `mil`, `ft`, or `feet`, normalized to
Expand Down
14 changes: 8 additions & 6 deletions docs/flanged-bushings.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tolerances. Edges are square, with no implicit chamfers or shoulder fillets.
```ts
import { flangedBushingModelPropsSchema, getFlangedBushingDimensions, mp } from "@tscircuit/modelprinter"

mp.string("flangedbushing_id8mm_od12mm_flangeod18mm_l15mm_flangethickness2mm_style(plainclosed)").json()
mp.string("flangedbushing_id8mm_od12mm_flangeod18mm_l15mm_flangethickness2mm_plainclosed").json()
flangedBushingModelPropsSchema.parse({ innerDiameter: 8, outerDiameter: 12, flangeDiameter: 18, length: 15, flangeThickness: "2mm" })
getFlangedBushingDimensions({ innerDiameter: 8, outerDiameter: 12, flangeDiameter: 18, length: 15, flangeThickness: 2 })
```
Expand All @@ -21,12 +21,14 @@ getFlangedBushingDimensions({ innerDiameter: 8, outerDiameter: 12, flangeDiamete
| `flangeDiameter` | Required | `flangeod`, `flangediameter` | Flange outside diameter, greater than the sleeve |
| `length` | Required | `l`, `length` | Overall length **including the flange** |
| `flangeThickness` | Required | `flangethickness` | Flange axial thickness; less than overall length |
| `style` | `"plainclosed"` | `style(plainclosed)` | Continuous plain sleeve; other styles are rejected |
| `plainClosed` | `true` | `plainclosed` | Continuous plain sleeve |

Lengths accept finite numbers in millimeters or complete numeric strings with
optional `mm`, `cm`, `m`, `in`, `inch`, `mil`, `ft`, or `feet` units. Outputs
use millimeters. Token names and style values are case-insensitive; direct props
use the casing shown above. Style tokens require parentheses. Unknown properties,
use millimeters. Token names and flags are case-insensitive; direct props
use the casing shown above. `plainclosed` is a value-free boolean flag. The
`plainClosed` property defaults to `true`; old `style(...)` tokens and `style`
properties are rejected. Unknown properties,
malformed lengths, duplicate tokens/aliases, and empty tokens are rejected.

The bore, sleeve and flange are concentric with the Z axis. The outer flange
Expand All @@ -52,7 +54,7 @@ than overall length. These constraints retain a closed sleeve wall, a flange
with radial overhang and a positive sleeve projection.

The strict exported props/definition schemas share these checks.
`FlangedBushingModelPropsInput` accepts unit strings and optional default style;
`FlangedBushingModelProps` contains normalized lengths and the resolved style.
`FlangedBushingModelPropsInput` accepts unit strings and an optional `plainClosed` flag;
`FlangedBushingModelProps` contains normalized lengths and the resolved `plainClosed: true` flag.
`FlangedBushingModelDefinition` adds `fn: "flangedbushing"` and is included in
the public `modelDefinitionSchema` union.
14 changes: 10 additions & 4 deletions docs/flat-head-screw.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Implements roadmap #0002 from [issue #13](https://github.com/tscircuit/modelprinter/issues/13).

```ts
mp.string("flatheadscrew_m3_l10mm_drive(hexsocket)").json()
mp.string("flatheadscrew_m3_l10mm_hexsocket").json()
```

The model defaults to **ISO10642:2019**, with M3, M4, M5 and M6 supported.
Expand All @@ -12,7 +12,7 @@ both forms normalize to `iso10642: true`. Legacy `standard(...)` selectors,
other sizes/editions, drives, partial threading, thread classes other than 6g,
and fine pitches are rejected. All normalized lengths are millimeters,
angles are degrees, and the primary metric thread is male, coarse and right-hand.
`threadhand(left)` selects the same profile with opposite handedness.
`lefthanded` selects the same profile with opposite handedness.

The [source table](https://www.westfieldfasteners.co.uk/Standards/ScrewBolt-SHCsk-M.html)
is pinned by edition and copied into the exported `flatHeadScrewDimensions` table.
Expand All @@ -36,8 +36,14 @@ d3 = d - 17H/12 root diameter. `showThreads: false` renders a smooth shank at
the major diameter, retaining the same head, under-head blend, tip chamfer,
length and thread identity.

`mN` / `metricsize(mN)` and `l` / `length` are aliases. `drive(...)`, `thread(full)`, `threadhand(...)`, `threadclass(6g)` and
`threadgender(male)` are selectors. `threads` / `nothreads` set visibility.
`mN` / `metricsize(mN)` and `l` / `length` are aliases. `hexsocket`,
`fullthread`, and `male` are value-free flags that directly set `hexSocket: true`,
`fullThread: true`, and `male: true`; those fixed features default to true.
`lefthanded` sets `leftHanded: true`, and `righthanded` restates its false default.
Repeated or conflicting hand flags are rejected. `threadclass(6g)` preserves the
ISO thread-class designation. `threads` / `nothreads` set visibility.
The former `drive`, `thread`, `threadHand`, and `threadGender` schema properties
and their selector tokens are rejected. Flags accept no values.
Dimensional fields in the table can be repeated explicitly using their
lowercase field names (for example `threadpitch0.5mm`), or supplied through the
public schema. They must equal the pinned value; they cannot redefine the
Expand Down
2 changes: 1 addition & 1 deletion docs/flatgasket.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ flatgasket_id20mm_od35mm_t2mm_flatannulus

Flat annular seal centered on XY. The mating face is Z=0 and the opposite face is Z=thickness. Both bore and outside walls are straight, with no bevels. Custom dimensions specify nominal geometry without material or compression properties.

Lengths accept complete decimals with optional units and normalize to millimeters. The schema rejects unknown fields, duplicate aliases, malformed tokens and dimensions that eliminate required material. `getFlatGasketDimensions` exposes the resolved dimensions and installation datums. Legacy roadmap selectors map to value-free flags; there are no enum selectors in the resolved contract.
Lengths accept complete decimals with optional units and normalize to millimeters. The schema rejects unknown fields, duplicate aliases, malformed tokens and dimensions that eliminate required material. `getFlatGasketDimensions` exposes the resolved dimensions and installation datums. `_flatannulus` is a value-free boolean flag. Enum selectors and flags with values are rejected.
28 changes: 27 additions & 1 deletion docs/flex-screens.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ Use a pin count after the model name and the usual `p` pitch token:
```ts
mp.string("flexscreen30_w16_h10_flex5_p0.5mm_sitsflat").json()
// { fn: "flexscreen", pinCount: 30, pitch: 0.5,
// width: 16, height: 10, flexCableLength: 5, orientation: "sitsFlat" }
// width: 16, height: 10, flexCableLength: 5, sitsFlat: true,
// sitsFlatBelowBoard: false, foldedToFaceAboveBoard: false,
// foldedToFaceBelowBoard: false, foldedToRightAngleAboveBoard: false,
// foldedToRightAngleBelowBoard: false }
```

The connector-facing properties match jscad-electronics' `FPC` component:
Expand Down Expand Up @@ -42,3 +45,26 @@ Existing `conductorCount`, `conductorPitch`, `conductorWidth`, and
`exposedContactLength` props and their long model-string tokens remain
supported as compatibility aliases. The FPC-style props take precedence
when both names are supplied.

Placement uses boolean flags. Every parsed definition resolves all six flags,
with exactly one true. If placement is omitted, `sitsFlat` is true.

| Bare model-string flag | Canonical property |
| --- | --- |
| `sitsflat` | `sitsFlat` |
| `sitsflatbelowboard` | `sitsFlatBelowBoard` |
| `foldedtofaceaboveboard` | `foldedToFaceAboveBoard` |
| `foldedtofacebelowboard` | `foldedToFaceBelowBoard` |
| `foldedtorightangleaboveboard` | `foldedToRightAngleAboveBoard` |
| `foldedtorightanglebelowboard` | `foldedToRightAngleBelowBoard` |

The shorter bare flags `sitsflatbelow`, `foldsabove`, `foldsaboveboard`,
`foldsbelow`, `foldsbelowboard`, `rightangleabove`, `rightangleaboveboard`,
`rightanglebelow`, and `rightanglebelowboard` select the same corresponding
canonical flag. JSON aliases `foldsAboveBoard` and `foldsBelowBoard` normalize
to `foldedToFaceAboveBoard` and `foldedToFaceBelowBoard`.

Supply exactly one true placement flag if any placement flags are supplied.
Repeating a flag or its alias in a model string is rejected. Flags accept no
values. The legacy `orientation` JSON field and `orientation(...)` selectors
are rejected. Dimensions, ratios, rotations, and color names remain values.
Loading
Loading