Machinist Bench Vise

A 100 mm engineer's bench vise in cutaway, bolted to a piece of bench top. The Tr 20 x 4 screw thread, the fastener sizes and threads, the jaw width and the 9 kg catalogue mass are published figures. The turns parameter opens the jaw by one 4 mm pitch for each turn of the handle, and the kernel measures the mass from the part volumes. Every thread is a helix in its mating thread: the lead screw in the nut, the cap screws in tapped holes, the bench bolts in nuts. The castings, the nut, the jaw plates and the bench are a display model.
Code
This is the full program. The playground runs it in your browser without a change.
ts
import { box, cut, cutAll, cylinder, extrude, fuseAll, line, loft, measureVolume, polygon, revolve, rotate, sphere, translate, unwrap, wire } from 'brepjs/quick';
import { color } from 'brepjs/playground';
// 100 mm engineer's bench vise in cutaway. The screw is along Y, the bench top is Z = 0, units are millimetres.
// The screw thread, the fasteners, the jaw width and the mass are published figures. The castings are a display model.
// Every thread is a helix in a mating thread: the lead screw in its nut, the cap screws in tapped holes, the bolts in nuts.
interface ViseParams {
turns?: number; // handle turns from the closed position (0 to 30). The jaw opens by one thread pitch for each turn.
cutaway?: boolean; // cut the right side of the castings and a quarter of the nut to show the screw
}
type P2 = [number, number];
type P3 = [number, number, number];
type Shape = ReturnType<typeof cylinder>;
// Kernel shapes live in WASM memory. Every temporary goes through own(). freeing() runs a build and then frees them all.
const owned: { delete(): void }[] = [];
const own = <T extends { delete(): void }>(s: T): T => {
owned.push(s);
return s;
};
const freeing = <T,>(build: () => T): T => { try { return build(); } finally { owned.splice(0).forEach((s) => s.delete()); } }; // also when the build throws
// ---- published figures
const JAW_WIDTH = 100;
const CATALOGUE_KG = 9; // 100 mm vise with a cast iron body
const TR = { major: 20, minor: 15.5, pitch: 4, nutMajor: 20.5, nutMinor: 16, flank: 15 }; // Tr 20 x 4 trapezoidal thread, flank angle in degrees
const CAP_M6 = { d: 6, minor: 4.917, pitch: 1, head: 10, k: 6, hex: 5 }; // socket head cap screws, ISO coarse thread
const CAP_M8 = { d: 8, minor: 6.647, pitch: 1.25, head: 13, k: 8, hex: 6 };
const HEX_M10 = { d: 10, minor: 8.376, pitch: 1.5, flats: 16, k: 6.4, washer: 20, washerT: 2, nut: 8.4, threaded: 26 }; // hex bolt, nut and plain washer
const DENSITY = { iron: 7.2e-3, steel: 7.85e-3, bronze: 8.8e-3 }; // grams per cubic millimetre
// ---- display model
const MAX_TURNS = 30; // 120 mm of opening
const AXIS = 42; // height of the screw axis
const SLIDE = { half: 22, z0: 24, z1: 66, wall: 7, length: 190 }; // channel bar of the moving jaw, open below
const BODY = { half: 36, length: 120, top: 80, foot: 14 };
const JAW = { top: 136, head: 104, plate: 8, plateH: 24, block: 34 };
const NUT = { half: 14, y0: 10, y1: 34, top: 57 };
const SERRATION = { pitch: 4, depth: 1.2 };
const THREAD = { start: 8, length: 176 }; // the thread starts this far behind the jaw
const FORM = { root: 1.3, crest: 0.7, nutRoot: 1.25, nutCrest: 0.65 }; // half widths of the Tr teeth, from the 15 degree flanks and a clearance
const HANDLE = { d: 10, length: 120, ball: 9 };
const BENCH = { thick: 30, half: 72, y0: 0, y1: 124 }; // a piece of the bench top
const BOLT_LENGTH = 60; // under the head: foot, bench top, washer and nut
const PLAY = 0.08; // radial clearance between a screw thread and its mating thread
const bx = (x0: number, x1: number, y0: number, y1: number, z0: number, z1: number): Shape =>
own(box(x1 - x0, y1 - y0, z1 - z0, { at: [(x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2] }));
// A closed (y, z) profile, extruded from x0 to x1.
const prism = (pts: P2[], x0: number, x1: number): Shape =>
own(unwrap(extrude(own(unwrap(polygon(pts.map(([y, z]): P3 => [x0, y, z])))), [x1 - x0, 0, 0]))) as Shape;
// A closed (r, y) profile, revolved about the screw axis.
const lathe = (pts: P2[]): Shape =>
own(translate(own(unwrap(revolve(own(unwrap(polygon(pts.map(([r, y]): P3 => [r, y, 0])))), { axis: [0, 1, 0] }))), [0, 0, AXIS]) as Shape);
const along = (r: number, y0: number, y1: number, x = 0, z = AXIS): Shape => own(cylinder(r, y1 - y0, { at: [x, y0, z], axis: [0, 1, 0] }));
const up = (r: number, z0: number, z1: number, x: number, y: number): Shape => own(cylinder(r, z1 - z0, { at: [x, y, z0] }));
const fused = (parts: Shape[]): Shape => own(unwrap(fuseAll(parts))) as Shape;
const minus = (s: Shape, tools: Shape[]): Shape => own(unwrap(cutAll(s, tools))) as Shape;
const hexagon = (flats: number, z0: number, z1: number): Shape => {
const r = flats / Math.sqrt(3);
const pts = Array.from({ length: 6 }, (_, i): P3 => [r * Math.cos((i * Math.PI) / 3), r * Math.sin((i * Math.PI) / 3), z0]);
return own(unwrap(extrude(own(unwrap(polygon(pts))), z1 - z0))) as Shape;
};
const volume = (s: Shape): number => unwrap(measureVolume(s));
// One helical thread tooth about Z, from z0 to z1. Its crest passes the +X side at z = ref.
// tip > core is the thread of a screw on a core. tip < core is the thread in a bore: ref is half a pitch away.
// half and flat are the half widths at the root and at the crest: a trapezoidal thread has a flat crest.
// The loft is smooth, so each flank is one helical face. A long loft drifts off the helix: a long thread is pieces of 4 turns.
const SECTIONS = 12; // sections of the loft in each turn
const SLACK = 0.998; // keeps the tooth of a screw a hair clear of its core
const BORE_SLACK = 0.99; // and the tooth in a bore clear of the wall
const helixTooth = (core: number, tip: number, pitch: number, z0: number, z1: number, ref: number, half = 0.42 * pitch, flat = 0): Shape[] => {
const root = tip > core ? core / SLACK : core * BORE_SLACK;
const crest = tip > core ? tip : tip / SLACK;
const piece = (from: number, to: number): Shape => {
const n = Math.max(2, Math.round(((to - from) / pitch) * SECTIONS));
const sections = Array.from({ length: n + 1 }, (_, j) => {
const z = from + ((to - from) * j) / n;
const a = 2 * Math.PI * ((z - ref) / pitch);
const at = (r: number, dz: number): P3 => [r * Math.cos(a), r * Math.sin(a), z + dz];
const pts = flat > 0 ? [at(root, -half), at(crest, -flat), at(crest, flat), at(root, half)] : [at(root, -half), at(crest, 0), at(root, half)];
return own(unwrap(wire(pts.map((p, i) => own(line(p, pts[(i + 1) % pts.length]!))))));
});
return unwrap(loft(sections, { ruled: false })) as Shape;
};
const count = Math.max(1, Math.ceil((z1 - z0) / (4 * pitch) - 0.001));
const pieces = Array.from({ length: count }, (_, i) => piece(z0 + ((z1 - z0) * i) / count, z0 + ((z1 - z0) * (i + 1)) / count));
return pieces;
};
type Fastener = { d: number; minor: number; pitch: number };
// The thread of a screw about Z from z0 up to z1, and the thread of the hole or the nut that it mates with.
const screwThread = (s: Fastener, z0: number, z1: number): Shape[] => helixTooth(s.minor / 2, s.d / 2, s.pitch, z0 + 0.45 * s.pitch, z1 - 0.45 * s.pitch, 0).map(own);
const holeThread = (s: Fastener, z0: number, z1: number): Shape[] => helixTooth(s.d / 2 + PLAY, s.minor / 2 + PLAY, s.pitch, z0 + 0.45 * s.pitch, z1 - 0.45 * s.pitch, s.pitch / 2).map(own);
// The Tr thread is built on Z and then laid on the screw axis, with z = 0 at y0.
const onAxis = (s: Shape, y0: number): Shape => translate(own(rotate(s, -90, { axis: [1, 0, 0] })), [0, y0, AXIS]) as Shape;
// A socket head cap screw along +Z, with the top of the head at z = 0: the body and its thread.
const capScrew = (s: Fastener & { head: number; k: number; hex: number }, length: number): Shape[] => {
const blank = fused([own(cylinder(s.head / 2, s.k, { at: [0, 0, -s.k] })), own(cylinder(s.minor / 2, length, { at: [0, 0, -s.k - length] }))]);
return [minus(blank, [hexagon(s.hex, -s.k * 0.55, 1)]), ...screwThread(s, -s.k - length, -s.k)];
};
function vise({ turns = 13.4, cutaway = true }: ViseParams = {}) {
const n = Math.min(Math.max(turns, 0), MAX_TURNS);
const opening = n * TR.pitch; // the law of the screw
const ys = -2 * JAW.plate - opening; // back face of the moving jaw block
const plateZ = JAW.top - JAW.plateH;
const screwX = [-30, 30];
const feet: P2[] = [[-47, 22], [47, 22], [-47, 98], [47, 98]];
// Body: a foot, a housing with a tunnel for the slide, the fixed jaw and an anvil.
const bodyBlank = fused([
bx(-58, 58, 6, 114, 0, BODY.foot),
bx(-BODY.half, BODY.half, 0, BODY.length, 0, BODY.top),
prism([[0, BODY.top - 2], [0, JAW.top], [24, JAW.top], [46, BODY.top + 8], [46, BODY.top - 2]], -BODY.half, BODY.half),
prism([[0, JAW.head], [0, JAW.top], [24, JAW.top], [32, JAW.head]], -JAW_WIDTH / 2, JAW_WIDTH / 2),
bx(-30, 30, 54, 118, BODY.top - 2, BODY.top + 10),
]);
const body = minus(bodyBlank, [
bx(-SLIDE.half, SLIDE.half, -1, BODY.length + 1, SLIDE.z0, SLIDE.z1),
...screwX.map((x) => along(CAP_M6.d / 2 + PLAY, -1, 14, x, plateZ + JAW.plateH / 2)),
...feet.map(([x, y]) => up(HEX_M10.d / 2 + 0.5, -1, BODY.foot + 1, x, y)),
up(CAP_M8.d / 2 + 0.4, -1, SLIDE.z0 + 1, 0, 22),
up(CAP_M8.head / 2, -1, CAP_M8.k, 0, 22),
]);
// Moving jaw: the jaw block, a boss for the screw and the slide.
const front = ys - JAW.block;
const jawBlank = fused([
bx(-SLIDE.half, SLIDE.half, ys - 1, ys + SLIDE.length, SLIDE.z0, SLIDE.z1),
prism([[ys, SLIDE.z0], [ys, JAW.top], [ys - 22, JAW.top], [front, JAW.head - 6], [front, SLIDE.z0]], -BODY.half, BODY.half),
prism([[ys, JAW.head], [ys, JAW.top], [ys - 22, JAW.top], [ys - 30, JAW.head]], -JAW_WIDTH / 2, JAW_WIDTH / 2),
along(18, front - 8, front + 1),
]);
const jaw = minus(jawBlank, [
bx(-SLIDE.half + SLIDE.wall, SLIDE.half - SLIDE.wall, ys, ys + SLIDE.length + 1, SLIDE.z0 - 1, SLIDE.z1 - SLIDE.wall),
along(TR.major / 2, front - 9, ys + 1),
...screwX.map((x) => along(CAP_M6.d / 2 + PLAY, ys - 14, ys + 1, x, plateZ + JAW.plateH / 2)),
]);
// Jaw plate: rows of teeth from an extruded profile, then one comb of V grooves across them. This leaves pyramids.
const rows: P2[] = [[0, -JAW.plateH / 2], [0, JAW.plateH / 2], [-JAW.plate + SERRATION.depth, JAW.plateH / 2]];
for (let z = JAW.plateH / 2; z > -JAW.plateH / 2; z -= SERRATION.pitch) rows.push([-JAW.plate, z - SERRATION.pitch / 2], [-JAW.plate + SERRATION.depth, z - SERRATION.pitch]);
const zig: P3[] = [[-52, -JAW.plate - 1, -15]];
for (let x = -52; x < 52; x += SERRATION.pitch) zig.push([x, -JAW.plate, -15], [x + SERRATION.pitch / 2, -JAW.plate + SERRATION.depth, -15]);
const comb = own(unwrap(extrude(own(unwrap(polygon([...zig, [52, -JAW.plate, -15], [52, -JAW.plate - 1, -15]]))), 30))) as Shape;
const plate = minus(prism(rows, -JAW_WIDTH / 2, JAW_WIDTH / 2), [
comb,
...screwX.flatMap((x) => [along(CAP_M6.head / 2, -JAW.plate - 1, -JAW.plate + CAP_M6.k, x, 0), along(CAP_M6.d / 2 + 0.3, -JAW.plate, 1, x, 0)]),
]);
const plateAt = plateZ + JAW.plateH / 2;
const fixedPlate = translate(plate, [0, 0, plateAt]) as Shape;
const movingPlate = translate(own(rotate(plate, 180)), [0, ys, plateAt]) as Shape;
// One M6 joint in the frame of the screw: the screw with its thread, and the thread of the tapped hole behind the plate.
const lay = (s: Shape): Shape => own(rotate(s, 90, { axis: [1, 0, 0] })); // head toward -Y
const m6 = { screw: capScrew(CAP_M6, 12 + JAW.plate - CAP_M6.k).map(lay), hole: holeThread(CAP_M6, -JAW.plate - 13.5, -JAW.plate).map(lay) };
const inBody = (parts: Shape[]): Shape[] => screwX.flatMap((x) => parts.map((s) => translate(s, [x, -JAW.plate, plateAt]) as Shape));
const inJaw = (parts: Shape[]): Shape[] => screwX.flatMap((x) => parts.map((s) => translate(own(rotate(s, 180)), [x, ys + JAW.plate, plateAt]) as Shape));
const plateScrews = [...inBody(m6.screw), ...inJaw(m6.screw)];
const taps = { body: inBody(m6.hole), jaw: inJaw(m6.hole) };
// Screw: a hub for the handle, a thrust collar, a journal in the jaw and the thread core.
const hub = front - 8;
const tip = ys + THREAD.start + THREAD.length + 2;
const core = minus(lathe([
[0, hub - 36], [13, hub - 36], [15, hub - 34], [15, hub - 6], [19, hub - 6], [19, hub], [TR.major / 2, hub], [TR.major / 2, ys],
[TR.minor / 2, ys], [TR.minor / 2, tip - 1.5], [TR.minor / 2 - 1.5, tip], [0, tip],
]), [own(cylinder(HANDLE.d / 2, 40, { at: [0, hub - 20, AXIS - 20] }))]);
const flight = helixTooth(TR.minor / 2, TR.major / 2, TR.pitch, 0, THREAD.length, 0, FORM.root, FORM.crest).map((s) => own(onAxis(own(s), ys + THREAD.start)));
const collar = lathe([[TR.minor / 2, ys], [13, ys], [13, ys + 6], [TR.minor / 2, ys + 6]]);
const h = HANDLE.length / 2;
const bar = fused([
own(cylinder(HANDLE.d / 2, HANDLE.length, { at: [0, hub - 20, AXIS - h] })),
own(sphere(HANDLE.ball, { at: [0, hub - 20, AXIS - h] })),
own(sphere(HANDLE.ball, { at: [0, hub - 20, AXIS + h] })),
]);
// The screw turns once for each pitch of travel, so its thread stays in the thread of the nut.
const turned = (s: Shape): Shape => rotate(s, -360 * n, { at: [0, 0, AXIS], axis: [0, 1, 0] }) as Shape;
// Nut: a bronze block on the floor of the tunnel. One cap screw holds it from below.
// Its thread is half a pitch from the screw thread. The cutaway takes a quarter: each turn of the tooth runs from 0 to 270 degrees.
const nut = minus(bx(-NUT.half, NUT.half, NUT.y0, NUT.y1, SLIDE.z0, NUT.top), [along(TR.nutMajor / 2, NUT.y0 - 1, NUT.y1 + 1), up(CAP_M8.d / 2 + PLAY, SLIDE.z0 - 1, 30.6, 0, 22)]);
const nutTooth = (from: number, to: number): Shape[] => helixTooth(TR.nutMajor / 2, TR.nutMinor / 2, TR.pitch, from, to, TR.pitch / 2, FORM.nutRoot, FORM.nutCrest);
const turnsInNut = Array.from({ length: (NUT.y1 - NUT.y0) / TR.pitch - 1 }, (_, k) => NUT.y0 + TR.pitch * (k + 0.5)); // each starts at 0 degrees
const nutTeeth = (cutaway ? turnsInNut.flatMap((y0) => nutTooth(y0, y0 + 0.75 * TR.pitch)) : nutTooth(turnsInNut[0]!, turnsInNut[0]! + TR.pitch * turnsInNut.length)).map((s) => onAxis(own(s), 0));
const flip = (s: Shape): Shape => translate(own(rotate(s, 180, { axis: [1, 0, 0] })), [0, 22, 0]) as Shape;
const nutScrew = capScrew(CAP_M8, 30 - CAP_M8.k).map(flip);
const nutTap = holeThread(CAP_M8, -30.4, -SLIDE.z0).map(flip);
// Bench bolts: a hex head on a washer, through the foot and the bench top, with a washer and a nut below.
const under = -BODY.foot - BENCH.thick; // underside of the bench, from the top of the foot
const bolt = [
fused([
own(cylinder(HEX_M10.washer / 2, HEX_M10.washerT)),
hexagon(HEX_M10.flats, HEX_M10.washerT - 0.5, HEX_M10.washerT + HEX_M10.k),
own(cylinder(HEX_M10.d / 2, BOLT_LENGTH - HEX_M10.threaded + 0.5, { at: [0, 0, HEX_M10.threaded - BOLT_LENGTH] })),
own(cylinder(HEX_M10.minor / 2, HEX_M10.threaded, { at: [0, 0, -BOLT_LENGTH] })),
]),
...screwThread(HEX_M10, -BOLT_LENGTH, HEX_M10.threaded - BOLT_LENGTH),
];
const benchNut = [
minus(own(cylinder(HEX_M10.washer / 2, HEX_M10.washerT, { at: [0, 0, under - HEX_M10.washerT] })), [own(cylinder(HEX_M10.d / 2 + 0.5, 4, { at: [0, 0, under - 3] }))]),
minus(hexagon(HEX_M10.flats, under - HEX_M10.washerT - HEX_M10.nut, under - HEX_M10.washerT), [own(cylinder(HEX_M10.d / 2 + PLAY, 12, { at: [0, 0, under - 12] }))]),
...holeThread(HEX_M10, under - HEX_M10.washerT - HEX_M10.nut, under - HEX_M10.washerT),
];
const atFeet = (parts: Shape[]): Shape[] => feet.flatMap(([x, y]) => parts.map((s) => translate(s, [x, y, BODY.foot]) as Shape));
const bench = unwrap(cutAll(bx(-BENCH.half, BENCH.half, BENCH.y0, BENCH.y1, -BENCH.thick, 0), feet.map(([x, y]) => up(HEX_M10.d / 2 + 0.5, -BENCH.thick - 1, 1, x, y)))) as Shape;
const bolts = atFeet(bolt);
// Mass from the kernel volumes of the complete parts. The bench bolts are not part of the vise.
const total = (parts: Shape[]): number => parts.reduce((sum, s) => sum + volume(s), 0);
const steel = total([core, ...flight, collar, bar, plate, plate, ...plateScrews, ...nutScrew]);
const bronze = volume(nut) + total(nutTeeth) * (cutaway ? 4 / 3 : 1) + total(nutTap); // the whole nut thread
const kg = ((volume(body) + volume(jaw) + total([...taps.body, ...taps.jaw])) * DENSITY.iron + steel * DENSITY.steel + bronze * DENSITY.bronze) / 1000;
// Cutaway: the right side of the castings, from the foot to the jaw heads.
const bite = bx(0, 80, ys - 60, 220, BODY.foot, JAW.head);
const quarter = bx(0, 80, 0, 50, AXIS, 70); // the nut loses one quarter only
const open = (s: Shape, tool = bite): Shape => (cutaway ? (unwrap(cut(s, tool)) as Shape) : (translate(s, [0, 0, 0]) as Shape));
return {
body: [open(body), ...taps.body], jaw: [open(jaw), ...taps.jaw], nut: [open(nut, quarter), ...nutTeeth, ...nutTap],
nutScrew, plates: [fixedPlate, movingPlate], plateScrews, bolts, benchNuts: atFeet(benchNut), bench,
screw: [turned(core), ...flight.map(turned), turned(collar), turned(bar)], opening, kg,
};
}
const part = freeing(() => vise());
console.log('Opening: ' + part.opening.toFixed(1) + ' mm, one ' + TR.pitch + ' mm pitch for each turn of the handle.');
console.log('Mass: ' + part.kg.toFixed(1) + ' kg from the kernel volumes. The catalogue has ' + CATALOGUE_KG + ' kg.');
export default [
...part.body.map((s) => color(s, '#12b5b0')),
...part.jaw.map((s) => color(s, '#0e8f8b')),
...part.screw.map((s) => color(s, '#c3c9d1')),
...part.nut.map((s) => color(s, '#d3a956')),
...part.nutScrew.map((s) => color(s, '#48515c')),
...part.plates.map((s) => color(s, '#48515c')),
...part.plateScrews.map((s) => color(s, '#22262c')),
...part.bolts.map((s) => color(s, '#c3c9d1')),
...part.benchNuts.map((s) => color(s, '#c3c9d1')),
color(part.bench, '#b08a5c'),
];Functions used
box cut cutAll cylinder extrude fuseAll line loft measureVolume polygon revolve rotate sphere translate unwrap wire color