Parts library
tscad/parts is a library of ordinary components built from the intrinsic elements: the
"parts are npm packages" idea. Holes and pockets are cutting tools pointing −Z from z = 0:
drop them into a <difference> at the top face of a part.
import { BoltPattern, CounterboreHole, mountPatterns } from "tscad/parts"
<difference>
<box size={[60, 60, 6]} />
<cylinder d={mountPatterns.nema17.pilot + 0.5} h={6} />
<BoltPattern pattern={mountPatterns.nema17} z={6}>
<CounterboreHole size="M3" depth={6} />
</BoltPattern>
</difference>
ISO data is exported too: metric.M3.clearance.normal (3.4 mm), metric.M4.tapDrill (3.3 mm),
metric.M5.socketHead, .counterbore, .countersunk, .nut, .insert for M2 – M12, and
mountPatterns for the Raspberry Pi 4 / Zero, Arduino Uno, NEMA 17 and NEMA 23.
<Hole />
A plain clearance hole (ISO 273).
| Prop | Type | Description |
|---|---|---|
| fit | HoleFit | ISO 273 clearance fit. Default "normal" (medium series: M3 → 3.4 mm). |
| diameter | number | Override the diameter, mm (e.g. for a printer that shrinks holes). |
<CounterboreHole />
A clearance hole with a counterbore for a socket head cap screw (ISO 4762).
| Prop | Type | Description |
|---|---|---|
| fit | HoleFit | ISO 273 clearance fit. Default "normal" (medium series: M3 → 3.4 mm). |
| diameter | number | Override the diameter, mm (e.g. for a printer that shrinks holes). |
| boreDiameter | number | Counterbore diameter, mm. Default: DIN 974-1 for a socket head cap screw (M3 → 6.5). |
| boreDepth | number | Counterbore depth, mm. Default: head height + clearance (M3 → 3.4). |
<CountersinkHole />
A clearance hole with a countersink for a flat-head screw (ISO 10642, 90°).
| Prop | Type | Description |
|---|---|---|
| fit | HoleFit | ISO 273 clearance fit. Default "normal" (medium series: M3 → 3.4 mm). |
| diameter | number | Override the diameter, mm (e.g. for a printer that shrinks holes). |
| sinkDiameter | number | Countersink diameter at the surface, mm. Default: the ISO 10642 head diameter (M3 → 6.72). |
| angle | number | Included countersink angle, degrees. Default 90 (metric). |
<TapHole />
A tap-drill hole for cutting (or self-tapping) a coarse metric thread. Default depth 10.
| Prop | Type | Description |
|---|---|---|
| diameter | number | Override the drill diameter, mm (default: tap drill, M4 → 3.3). |
<NutTrap />
A hexagonal nut pocket (flats parallel to X), from z = 0 down.
| Prop | Type | Description |
|---|---|---|
| size* | MetricSize | ISO metric size of the nut (ISO 4032), e.g. "M3" (5.5 mm across flats). |
| depth | number | Pocket depth, mm. Default: nut height + 0.2. |
| clearance | number | Extra size across flats for a press/slide fit, mm. Default 0.3. |
| boltDepth | number | Also cut a clearance hole for the bolt this far below the pocket, mm. Default 0 (none). |
| fit | HoleFit | Fit of that bolt hole. Default "normal". |
Also takes placement props.
<HeatSetInsert />
A blind pocket for a heat-set threaded insert, from z = 0 down.
| Prop | Type | Description |
|---|---|---|
| size* | MetricSize | Insert size, "M2" to "M8". |
| diameter | number | Pocket diameter, mm (default: common insert recommendation, M3 → 4.0). |
| depth | number | Pocket depth, mm (default: insert length + 0.5 for displaced plastic, M3 → 6.2). |
Also takes placement props.
<Standoff />
A standoff boss standing on z = 0, with a bore from the top.
| Prop | Type | Description |
|---|---|---|
| size* | MetricSize | Screw size, e.g. "M3". |
| height* | number | Height above z = 0, mm. |
| od | number | Outer diameter, mm. Default: 2 × nominal + 1 (M3 → 7). |
| hole | "tap" | "clearance" | "insert" | "none" | The bore: "tap" (default, for self-tapping/tapping), "clearance", "insert" (a heat-set insert pocket from the top), or "none" (solid). |
| holeDepth | number | Bore depth from the top, mm. Default: the whole height. |
| hex | boolean | Hexagonal instead of round (od is then across flats). Default false. |
Also takes placement props.
<BoltPattern />
Repeat the children at every point of a pattern (in XY).
| Prop | Type | Description |
|---|---|---|
| pattern* | MountPattern | readonly Vec2[] | The pattern (e.g. mountPatterns.nema17), or a list of [x, y] points. |
Also takes placement props.
<MountHoles />
The pattern's holes as cutting tools (pointing −Z from z = 0).
| Prop | Type | Description |
|---|---|---|
| pattern* | MountPattern | The pattern; its size picks the screw. |
| type | "clearance" | "counterbore" | "countersink" | "tap" | "insert" | Hole style. Default "clearance". |
| depth | number | Hole depth below z = 0, mm. Default 20 (insert: the insert length). |
Also takes placement props.
<Extrusion2020 />
A 20 × 20 mm aluminium T-slot extrusion (simplified profile: 6.2 mm slot openings, 1.8 mm lips, trapezoidal slot cavity, Ø 4.2 centre bore; no corner radii or inner webs), standing on z = 0 along +Z, centred in XY.
| Prop | Type | Description |
|---|---|---|
| length* | number | Length along +Z from z = 0, mm. |
| bore | number | Centre bore diameter (M5 tap), mm. Default 4.2; 0 for none. |
Also takes placement props.
<HexPrism />
A hexagonal prism (flats parallel to X), centred in XY, base on z = 0.
| Prop | Type | Description |
|---|---|---|
| af* | number | Across flats, mm. |
| height* | number | Height along +Z from z = 0, mm. |
| bore | number | Optional through bore diameter, mm. |
Also takes placement props.
<Bolt />
A metric bolt (cap screw). Frame: the head's bearing face at z = 0, the shank down −Z, the head up +Z; for a flat (countersunk) head z = 0 is the flush top face and the head's cone goes down. Sub-solids: head, shank, socket (the recess, cut from the head). Anchors: head (z = 0, axis +Z) and tip (the shank's end).
| Prop | Type | Description |
|---|---|---|
| anchors | boolean | string | |
| thread* | MetricSize | ISO metric thread, "M2" to "M12". |
| length* | number | Nominal length, mm, as catalogues sell it: under the head for socket, hex, button and pan heads; overall (head included) for flat, countersunk heads. |
| head | BoltHead | Head style. Default "socket" (ISO 4762 cap screw). |
| cutter | boolean | HoleFit | Make the bolt's clearance cutter instead of the bolt: a clearance hole down the shank and a pocket for the head (a countersink for flat heads), for a <difference>. true is the "normal" fit; or give "close" / "loose". |
| ghost | boolean | With cutter: make the cutter a ghost, a tool-only solid that is left out of the output unless a <difference> or a ref op (<subtract tool=".b > .clearance">) uses it. Default true. |
| headClearance | number | Extra clearance around the head in the cutter's pocket, mm (diameter). Default 1. |
| name | string | Instance name for refs (<Bolt name="b" /> → .b > .shank); tscad records it. |
Also takes placement props.
<Nut />
A hex nut. Frame: its bearing face on z = 0, axis +Z. Sub-solids: body and bore. Anchors: face (z = 0) and top.
| Prop | Type | Description |
|---|---|---|
| anchors | boolean | string | |
| thread* | MetricSize | ISO metric thread. |
| type | "hex" | "nyloc" | "hex" (ISO 4032, default) or "nyloc" (ISO 10511, with the nylon insert's dome). |
| name | string | Instance name for refs (<Bolt name="b" /> → .b > .shank); tscad records it. |
Also takes placement props.
<Washer />
A washer lying on z = 0. Sub-solids: body. Anchors: bottom, top.
| Prop | Type | Description |
|---|---|---|
| anchors | boolean | string | |
| thread* | MetricSize | The bolt's ISO metric thread. |
| type | "flat" | "spring" | "flat" (ISO 7089, default) or "spring" (DIN 127 B split lock washer, modelled flat with its split). |
| name | string | Instance name for refs; tscad records it. |
Also takes placement props.
<SetScrew />
A hex socket set screw with a flat point (ISO 4026), z 0..length, socket at the top. Sub-solids: body, socket. Anchors: point (z = 0) and top.
| Prop | Type | Description |
|---|---|---|
| anchors | boolean | string | |
| thread* | MetricSize | |
| length* | number | Length, mm. |
| name | string | Instance name for refs; tscad records it. |
Also takes placement props.
<DowelPin />
A hardened dowel pin (ISO 8734), z 0..length, with chamfered ends. Anchors: bottom, top.
| Prop | Type | Description |
|---|---|---|
| anchors | boolean | string | |
| d* | number | Diameter, mm (ISO 8734: 1 to 20). |
| length* | number | Length, mm. |
| name | string | Instance name for refs; tscad records it. |
Also takes placement props.
<Bearing />
A shielded deep-groove ball bearing (ISO 15 dimensions), axis Z, z 0..B. Sub-solids: outer (ring), inner (ring), shield (recessed 0.2 mm each side). Anchors: face (z = 0), back (z = B), both on the axis.
| Prop | Type | Description |
|---|---|---|
| anchors | boolean | string | |
| designation* | BearingDesignation | Designation, e.g. "608" (8 × 22 × 7), "625", "6001", "MR105". |
| name | string | Instance name for refs; tscad records it. |
Also takes placement props.
<ShaftCollar />
A set-screw shaft collar, axis Z, z 0..width, with a tapped radial hole along +X at mid width. Sub-solids: body, bore, screwHole. Anchors: face (z = 0), back.
| Prop | Type | Description |
|---|---|---|
| anchors | boolean | string | |
| bore* | CollarBore | Shaft diameter, mm: 3, 4, 5, 6, 8, 10 or 12. |
| name | string | Instance name for refs; tscad records it. |
Also takes placement props.
<FingerJointBox />
A finger-jointed box for laser cutting: bottom, four walls, optional lid and dividers, with fingers that mate. Flat, it emits one <drawing> per panel (layer "cut") plus engraved labels (layer "engrave"): tscad build box.tsx -o box.dxf gives the cutting file. Assembled, it folds the panels into the box so you can see it and check it.
<FingerJointBox width={120} depth={80} height={60} thickness={3} kerf={0.15} lid />| Prop | Type | Description |
|---|---|---|
| width* | number | Outer width (X), mm. |
| depth* | number | Outer depth (Y), mm. |
| height* | number | Outer height (Z), mm. |
| thickness* | number | Sheet thickness, mm (e.g. 3 for 3 mm plywood). |
| fingerWidth | number | Target finger width, mm (each edge gets an odd number of about this size). Default 3 × thickness. |
| kerf | number | Laser kerf, mm: every outline is offset outward by kerf / 2 (slots shrink by the same) so the parts come out at size and the joints are snug. Default 0. |
| lid | boolean | Add a finger-jointed lid. Default false (open top). |
| dividers | number | Dividers across the width, slotted into the bottom, front and back. Default 0. |
| assembled | boolean | false (default): flat panels laid out for cutting (one <drawing> per panel, with thickness, so the viewer shows the sheet). true: the panels folded into the assembled box as <part>s (check the fit with interference), plus the same flat drawings for export. |
| labels | boolean | Engrave each panel's name on it (layer "engrave"). Default true. |
| spacing | number | Gap between panels in the flat layout, mm. Default 5. |
| name | string | Prefix for drawing/part names. Default "box". |
| material | string | Material preset for the parts. Default "wood". |
<LivingHinge />
A straight-line living-hinge pattern: staggered columns of thin slots that let sheet material bend. Put it inside a <drawing> (or <extrude>) over a solid shape; the slots become holes. Centred on its position; the cut lines run along Y.
<drawing name="cover"><rect w={100} h={60} /><LivingHinge width={30} height={56} /></drawing>| Prop | Type | Description |
|---|---|---|
| width* | number | Width of the hinge area (across the bend lines), mm. |
| height* | number | Height of the hinge area (along the cut lines), mm. |
| spacing | number | Distance between cut lines, mm. Default 2. |
| bridge | number | Uncut bridge between cuts in a line, mm. Default 3. |
| cutLength | number | Length of each cut, mm. Default about a third of height. |
| slotWidth | number | Width of each cut slot, mm (≈ the kerf). Default 0.3. |
Also takes placement props.