tscad GitHub

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).

PropTypeDescription
fitHoleFitISO 273 clearance fit. Default "normal" (medium series: M3 → 3.4 mm).
diameternumberOverride 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).

PropTypeDescription
fitHoleFitISO 273 clearance fit. Default "normal" (medium series: M3 → 3.4 mm).
diameternumberOverride the diameter, mm (e.g. for a printer that shrinks holes).
boreDiameternumberCounterbore diameter, mm. Default: DIN 974-1 for a socket head cap screw (M3 → 6.5).
boreDepthnumberCounterbore depth, mm. Default: head height + clearance (M3 → 3.4).

<CountersinkHole />

A clearance hole with a countersink for a flat-head screw (ISO 10642, 90°).

PropTypeDescription
fitHoleFitISO 273 clearance fit. Default "normal" (medium series: M3 → 3.4 mm).
diameternumberOverride the diameter, mm (e.g. for a printer that shrinks holes).
sinkDiameternumberCountersink diameter at the surface, mm. Default: the ISO 10642 head diameter (M3 → 6.72).
anglenumberIncluded countersink angle, degrees. Default 90 (metric).

<TapHole />

A tap-drill hole for cutting (or self-tapping) a coarse metric thread. Default depth 10.

PropTypeDescription
diameternumberOverride the drill diameter, mm (default: tap drill, M4 → 3.3).

<NutTrap />

A hexagonal nut pocket (flats parallel to X), from z = 0 down.

PropTypeDescription
size*MetricSizeISO metric size of the nut (ISO 4032), e.g. "M3" (5.5 mm across flats).
depthnumberPocket depth, mm. Default: nut height + 0.2.
clearancenumberExtra size across flats for a press/slide fit, mm. Default 0.3.
boltDepthnumberAlso cut a clearance hole for the bolt this far below the pocket, mm. Default 0 (none).
fitHoleFitFit of that bolt hole. Default "normal".

Also takes placement props.

<HeatSetInsert />

A blind pocket for a heat-set threaded insert, from z = 0 down.

PropTypeDescription
size*MetricSizeInsert size, "M2" to "M8".
diameternumberPocket diameter, mm (default: common insert recommendation, M3 → 4.0).
depthnumberPocket 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.

PropTypeDescription
size*MetricSizeScrew size, e.g. "M3".
height*numberHeight above z = 0, mm.
odnumberOuter 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).
holeDepthnumberBore depth from the top, mm. Default: the whole height.
hexbooleanHexagonal 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).

PropTypeDescription
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).

PropTypeDescription
pattern*MountPatternThe pattern; its size picks the screw.
type"clearance" | "counterbore" | "countersink" | "tap" | "insert"Hole style. Default "clearance".
depthnumberHole 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.

PropTypeDescription
length*numberLength along +Z from z = 0, mm.
borenumberCentre 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.

PropTypeDescription
af*numberAcross flats, mm.
height*numberHeight along +Z from z = 0, mm.
borenumberOptional 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).

PropTypeDescription
anchorsboolean | string
thread*MetricSizeISO metric thread, "M2" to "M12".
length*numberNominal length, mm, as catalogues sell it: under the head for socket, hex, button and pan heads; overall (head included) for flat, countersunk heads.
headBoltHeadHead style. Default "socket" (ISO 4762 cap screw).
cutterboolean | HoleFitMake 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".
ghostbooleanWith 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.
headClearancenumberExtra clearance around the head in the cutter's pocket, mm (diameter). Default 1.
namestringInstance 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.

PropTypeDescription
anchorsboolean | string
thread*MetricSizeISO metric thread.
type"hex" | "nyloc""hex" (ISO 4032, default) or "nyloc" (ISO 10511, with the nylon insert's dome).
namestringInstance 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.

PropTypeDescription
anchorsboolean | string
thread*MetricSizeThe 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).
namestringInstance 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.

PropTypeDescription
anchorsboolean | string
thread*MetricSize
length*numberLength, mm.
namestringInstance 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.

PropTypeDescription
anchorsboolean | string
d*numberDiameter, mm (ISO 8734: 1 to 20).
length*numberLength, mm.
namestringInstance 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.

PropTypeDescription
anchorsboolean | string
designation*BearingDesignationDesignation, e.g. "608" (8 × 22 × 7), "625", "6001", "MR105".
namestringInstance 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.

PropTypeDescription
anchorsboolean | string
bore*CollarBoreShaft diameter, mm: 3, 4, 5, 6, 8, 10 or 12.
namestringInstance 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 />

PropTypeDescription
width*numberOuter width (X), mm.
depth*numberOuter depth (Y), mm.
height*numberOuter height (Z), mm.
thickness*numberSheet thickness, mm (e.g. 3 for 3 mm plywood).
fingerWidthnumberTarget finger width, mm (each edge gets an odd number of about this size). Default 3 × thickness.
kerfnumberLaser 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.
lidbooleanAdd a finger-jointed lid. Default false (open top).
dividersnumberDividers across the width, slotted into the bottom, front and back. Default 0.
assembledbooleanfalse (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.
labelsbooleanEngrave each panel's name on it (layer "engrave"). Default true.
spacingnumberGap between panels in the flat layout, mm. Default 5.
namestringPrefix for drawing/part names. Default "box".
materialstringMaterial 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>

PropTypeDescription
width*numberWidth of the hinge area (across the bend lines), mm.
height*numberHeight of the hinge area (along the cut lines), mm.
spacingnumberDistance between cut lines, mm. Default 2.
bridgenumberUncut bridge between cuts in a line, mm. Default 3.
cutLengthnumberLength of each cut, mm. Default about a third of height.
slotWidthnumberWidth of each cut slot, mm (≈ the kerf). Default 0.3.

Also takes placement props.