@rulecad/fixings 0.0.1 → 0.1.1
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.
- package/README.md +627 -22
- package/draw.d.mts +46 -0
- package/draw.mjs +85 -0
- package/fixings.d.mts +26 -0
- package/fixings.mjs +47 -4
- package/hardware.d.mts +215 -0
- package/hardware.mjs +181 -0
- package/holes.d.mts +135 -0
- package/holes.mjs +157 -0
- package/model.d.mts +253 -0
- package/model.mjs +382 -0
- package/package.json +37 -6
- package/seats.d.mts +353 -0
- package/seats.mjs +334 -0
- package/strength.d.mts +221 -0
- package/strength.mjs +262 -0
- package/threads.d.mts +216 -0
- package/threads.mjs +411 -0
package/seats.mjs
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
// Seats: where a screw's head, a nut or an insert sits in a printed part. Each has a twin that gives the numbers with
|
|
2
|
+
// findings (counterboreModel) and one that gives the solid (counterbore), and each prints without supports in the
|
|
3
|
+
// direction it is drawn for. Sizes come from the thread's rules and the printer's; the shapes come from
|
|
4
|
+
// @rulecad/shapes where it has one (countersink, nutPocket, teardropHole, wallOpening), which take plain dimensions.
|
|
5
|
+
// A cutter starts at a point on a face (at) and goes into the part along a direction (into).
|
|
6
|
+
import jscad from '@jscad/modeling';
|
|
7
|
+
import { countersink as cone90, nutPocket as hexPocket, wallOpening } from '@rulecad/shapes';
|
|
8
|
+
import { DEFAULTS, fixingOf, printerOf, headOf, nutOf, figure, cite, rest, finding, positive, oneOf, isNum, shown, mm, r3, a, layers } from './model.mjs';
|
|
9
|
+
import { holeModel, directionOf, pointOf, optionsOf, said, inPart } from './holes.mjs';
|
|
10
|
+
import { along, bore, lathe, teardrop, UP, OUT, SEGMENTS, DIRECTIONS } from './draw.mjs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import('./model.mjs').Fixing} Fixing a fixing's model, as fixingModel gives it
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { cuboid, cylinderElliptic, polygon } = jscad.primitives, { translate, rotateZ, transform } = jscad.transforms, { extrudeLinear } = jscad.extrusions;
|
|
17
|
+
const COS30 = Math.cos(Math.PI / 6);
|
|
18
|
+
const CLEARANCES = ['clearance', 'close', 'loose'];
|
|
19
|
+
// The hole a seat sits on: one of the clearances
|
|
20
|
+
function through(what, fx, o) {
|
|
21
|
+
const kind = oneOf(what, 'hole', o.hole ?? 'clearance', CLEARANCES), n = kind === 'clearance' ? kind : `clearance_${kind}`;
|
|
22
|
+
if (!fx.figures[n]) throw new Error(`${what}: ${fx.thread} has no ${n} in its rule set (${fx.set}): a seat sits on a clearance hole, and this thread has no figure for one`);
|
|
23
|
+
return holeModel(fx, { kind, printer: o.printer });
|
|
24
|
+
}
|
|
25
|
+
// A fit by name, from the printer's rules, or a clearance in mm as printed
|
|
26
|
+
function fitOf(what, fit, pr) {
|
|
27
|
+
if (isNum(fit)) return { name: fit, clearance: fit, rests: [] };
|
|
28
|
+
if (!['snug', 'slip', 'press'].includes(fit)) throw new Error(`${what}: fit is snug (no clearance once printed), slip or press (the printer's), or a clearance in mm (got ${shown(fit)})`);
|
|
29
|
+
return fit === 'snug' ? { name: fit, clearance: 0, rests: [] } : { name: fit, clearance: fit === 'slip' ? pr.n('slip') : -pr.n('press'), rests: [pr.rest(fit)] };
|
|
30
|
+
}
|
|
31
|
+
const figures = (fx, names) => names.map((n) => rest(cite(fx, n), fx.figures[n]));
|
|
32
|
+
const lengthOf = (what, o, least, why) => {
|
|
33
|
+
if (o.length == null) return null;
|
|
34
|
+
positive(what, 'length', o.length);
|
|
35
|
+
if (o.length < least - 1e-9) throw new Error(`${what}: length is the whole hole's, from the face it starts at: ${mm(o.length)} mm is less than ${why} (${mm(least)} mm)`);
|
|
36
|
+
return o.length;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// ---------- counterbore ----------
|
|
40
|
+
/**
|
|
41
|
+
* A counterbore for a screw's head, as numbers: wide enough for the head with the printer's fit round it, and deep
|
|
42
|
+
* enough to hide it.
|
|
43
|
+
* @param {Fixing | string} m
|
|
44
|
+
* @param {{ head?: string, depth?: number, diameter?: number, length?: number, thickness?: number, hole?: string, printer?: object, into?: string, axis?: string, sets?: object }} [o]
|
|
45
|
+
* head: cap, button, hex or pan (default the model's, else cap); depth: of the seat (default the head's height, up to
|
|
46
|
+
* a whole layer); diameter: of the seat, for a socket's room; length: the whole hole's, from the face, to cut the
|
|
47
|
+
* screw's hole as well; thickness: the part's there (a seat deeper than the part is refused); hole: clearance, close or loose
|
|
48
|
+
* @returns {{ thread: string, head: string, diameter: number, depth: number, sunk: number, hole: number, length: number | null, cone: number, into: string, teardrop: boolean, rests: object[], findings: object[] }}
|
|
49
|
+
* sunk: how far the head's top lies under the face (below 0: it stands proud); cone: the height of the 45° cone the seat ends in where it goes up from the bed
|
|
50
|
+
*/
|
|
51
|
+
export function counterboreModel(m, o = {}) {
|
|
52
|
+
const what = 'counterbore';
|
|
53
|
+
optionsOf(what, o, '{ head: \'cap\', length: 8 }');
|
|
54
|
+
const fx = fixingOf(what, m, o), pr = printerOf(what, o.printer), dir = directionOf(what, o), out = [];
|
|
55
|
+
const form = o.head ?? fx.head?.form ?? (fx.made.heads.includes('cap') ? 'cap' : 'pan');
|
|
56
|
+
if (form === 'countersunk') throw new Error(`${what}: a countersunk head sits in a cone, not a counterbore: use countersink`);
|
|
57
|
+
if (form === 'set') throw new Error(`${what}: a set screw has no head to seat: it goes into its hole whole`);
|
|
58
|
+
const head = headOf(what, fx, form), h = through(what, fx, o), fit = pr.n('fit'), comp = pr.n('hole_comp'), layer = pr.n('layer');
|
|
59
|
+
const least = r3(head.across + comp), diameter = o.diameter == null ? r3(head.across + 2 * fit + comp) : positive(what, 'diameter', o.diameter);
|
|
60
|
+
const depth = o.depth == null ? layers(head.height, layer) : positive(what, 'depth', o.depth), sunk = r3(depth - head.height);
|
|
61
|
+
const cone = dir.into === '+z' ? r3((diameter - h.diameter) / 2) : 0, length = lengthOf(what, o, depth + cone, 'the seat\'s depth');
|
|
62
|
+
inPart(what, o, depth + cone, `a seat ${mm(depth)} mm deep for ${a(fx.thread)} ${form} head${cone ? ` with its ${mm(cone)} mm cone` : ''}`);
|
|
63
|
+
out.push(finding('info', `a counterbore for ${a(fx.thread)} ${form} head drawn ${mm(diameter)} mm across and ${mm(depth)} mm deep: the head is ${mm(head.across)} mm across${head.flats ? ' its corners' : ''} and ${mm(head.height)} mm high (${head.figures.map((n) => cite(fx, n)).join(', ')})${o.diameter == null ? `, with ${pr.cite('fit')} ${mm(fit)} mm each side and ${pr.cite('hole_comp')} ${mm(comp)} mm across` : ''}; its top lies ${sunk > 1e-9 ? `${mm(sunk)} mm under the face` : sunk < -1e-9 ? `${mm(-sunk)} mm proud of the face` : 'flush with the face'}`,
|
|
64
|
+
'counterbore.drawn', { values: { diameter, depth, sunk, hole: h.diameter }, refs: { thread: fx.thread, set: fx.set, head: form } }));
|
|
65
|
+
if (diameter < least - 1e-9) out.push(finding('fail', `a ${mm(diameter)} mm seat is smaller than the ${mm(head.across)} mm head once printed: ${mm(least)} mm at least`, 'counterbore.diameter', { values: { diameter, least } }));
|
|
66
|
+
if (sunk < -1e-9) out.push(finding('warn', `the head stands ${mm(-sunk)} mm proud of a ${mm(depth)} mm seat: ${mm(head.height)} mm hides it`, 'counterbore.proud', { values: { depth, head: head.height } }));
|
|
67
|
+
if (form === 'hex' && o.diameter == null) out.push(finding('warn', `a hexagon head is turned by a socket or a spanner, and this seat clears the head's corners by the printer's fit and no more: give { diameter } for your socket's outside`, 'counterbore.socket'));
|
|
68
|
+
out.push(finding('pass', dir.across ? `${said(dir.into)}, the seat and its hole are teardrops: 45° roofs, no support`
|
|
69
|
+
: cone ? `${said(dir.into)}, the seat ends in a 45° cone ${mm(cone)} mm high from the bore to the hole: nothing spans, and the head bears on the cone's rim` : `${said(dir.into)}, a counterbore prints as drawn`, 'counterbore.printable', { values: { into: dir.into } }));
|
|
70
|
+
return { thread: fx.thread, head: form, diameter, depth, sunk, hole: h.diameter, length, cone, into: dir.into, teardrop: dir.across,
|
|
71
|
+
rests: [...figures(fx, head.figures), pr.rest('fit'), pr.rest('hole_comp'), pr.rest('layer'), ...h.rests], findings: [...out, ...h.findings.filter((f) => f.code === 'hole.drawn')] };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A counterbore for a screw's head, to subtract, with the screw's hole on through the part where length is given.
|
|
76
|
+
* On its side, the seat and the hole are one teardrop cutter: a 45° roof over each.
|
|
77
|
+
* @param {Fixing | string} m
|
|
78
|
+
* @param {{ head?: string, depth?: number, diameter?: number, length?: number, hole?: string, printer?: object, into?: string, axis?: string, sets?: object, at?: number[] }} [o] as counterboreModel; at: the point on the face
|
|
79
|
+
* @returns {object} a JSCAD geom3 to subtract, with .model
|
|
80
|
+
*/
|
|
81
|
+
export function counterbore(m, o = {}) {
|
|
82
|
+
const c = counterboreModel(m, o), at = pointOf('counterbore', o.at), R = c.diameter / 2, r = c.hole / 2;
|
|
83
|
+
const steps = [[R, c.depth], ...(c.cone ? [[r, c.depth + c.cone]] : c.length ? [[r, c.depth]] : []), ...(c.length ? [[r, c.length]] : [])];
|
|
84
|
+
return Object.assign(along(c.teardrop ? teardrop(steps, UP[c.into], { through: !!c.length }) : bore(steps, { through: !!c.length }), c.into, at), { model: c });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ---------- countersink ----------
|
|
88
|
+
/**
|
|
89
|
+
* A countersink for a flat-head screw, as numbers: a cone to the head's angle, as wide as the head's sharp edge, so
|
|
90
|
+
* any head sits flush.
|
|
91
|
+
* @param {Fixing | string} m
|
|
92
|
+
* @param {{ length?: number, thickness?: number, hole?: string, printer?: object, into?: string, axis?: string, sets?: object }} [o] length: the whole hole's, from the face (default the cone and no more);
|
|
93
|
+
* thickness: the part's there (a cone deeper than the part is refused)
|
|
94
|
+
* @returns {{ thread: string, diameter: number, angle: number, depth: number, hole: number, length: number, into: string, teardrop: boolean, rests: object[], findings: object[] }}
|
|
95
|
+
* diameter: of the cone at the face, as drawn; depth: of the cone
|
|
96
|
+
*/
|
|
97
|
+
export function countersinkModel(m, o = {}) {
|
|
98
|
+
const what = 'countersink';
|
|
99
|
+
optionsOf(what, o, '{ length: 8 }');
|
|
100
|
+
const fx = fixingOf(what, m, o), pr = printerOf(what, o.printer), dir = directionOf(what, o), head = headOf(what, fx, 'countersunk'), h = through(what, fx, o), comp = pr.n('hole_comp');
|
|
101
|
+
const angle = head.angle ?? 90, diameter = r3(head.diameter + comp), depth = r3((diameter - h.diameter) / 2 / Math.tan((angle * Math.PI) / 360));
|
|
102
|
+
if (!(angle > 0 && angle < 180)) throw new Error(`${what}: ${cite(fx, 'countersunk_angle')} is the cone's whole angle, between 0° and 180° (got ${shown(angle)})`);
|
|
103
|
+
const length = lengthOf(what, o, depth, 'the cone\'s depth') ?? depth, slope = angle / 2, limit = pr.n('overhang'), out = [];
|
|
104
|
+
inPart(what, o, depth, `a countersink ${mm(depth)} mm deep for ${a(fx.thread)} flat head`);
|
|
105
|
+
out.push(finding('info', `a countersink for ${a(fx.thread)} flat head drawn ${mm(diameter)} mm across at ${mm(angle)}°, ${mm(depth)} mm deep on a ${mm(h.diameter)} mm hole: ${cite(fx, 'countersunk_head')} ${mm(head.diameter)} mm, the head's sharp-edge diameter, so any head sits flush, plus ${pr.cite('hole_comp')} ${mm(comp)} mm across`,
|
|
106
|
+
'countersink.drawn', { values: { diameter, angle, depth, hole: h.diameter }, refs: { thread: fx.thread, set: fx.set } }));
|
|
107
|
+
out.push(dir.across ? finding('pass', `${said(dir.into)}, the cone and its hole are teardrops: 45° roofs, no support`, 'countersink.printable', { values: { into: dir.into } })
|
|
108
|
+
: dir.into === '+z' ? finding(slope <= limit + 1e-9 ? 'pass' : 'warn', `${said(dir.into)}, the cone opens on to the bed and its wall overhangs ${mm(slope)}° from upright, ${slope <= limit + 1e-9 ? 'within' : 'past'} the printer's ${mm(limit)}°`, 'countersink.printable', { values: { into: dir.into, slope, limit } })
|
|
109
|
+
: finding('pass', `${said(dir.into)}, a countersink prints as drawn`, 'countersink.printable', { values: { into: dir.into } }));
|
|
110
|
+
return { thread: fx.thread, diameter, angle, depth, hole: h.diameter, length, into: dir.into, teardrop: dir.across,
|
|
111
|
+
rests: [...figures(fx, head.figures), pr.rest('hole_comp'), ...h.rests], findings: [...out, ...h.findings.filter((f) => f.code === 'hole.drawn')] };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A countersink and its hole, to subtract, the head flush with the face at `at`. A 90° head goes through
|
|
116
|
+
* @rulecad/shapes' countersink; another angle (an inch screw's 82°) is drawn here in the same form.
|
|
117
|
+
* @param {Fixing | string} m
|
|
118
|
+
* @param {{ length?: number, hole?: string, printer?: object, into?: string, axis?: string, sets?: object, at?: number[] }} [o] as countersinkModel
|
|
119
|
+
* @returns {object} a JSCAD geom3 to subtract, with .model
|
|
120
|
+
*/
|
|
121
|
+
export function countersink(m, o = {}) {
|
|
122
|
+
const c = countersinkModel(m, o), at = pointOf('countersink', o.at), through = o.length != null, R = c.diameter / 2, r = c.hole / 2;
|
|
123
|
+
if (c.angle === 90) return Object.assign(cone90({ hole: c.hole, head: c.diameter, length: c.length + (through ? OUT : 0), at, into: c.into }), { model: c });
|
|
124
|
+
const steps = [[R, 0], [r, c.depth], ...(c.length > c.depth ? [[r, c.length]] : [])];
|
|
125
|
+
return Object.assign(along(c.teardrop ? teardrop(steps, UP[c.into], { through }) : bore(steps, { through }), c.into, at), { model: c });
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ---------- nuts ----------
|
|
129
|
+
// What every nut seat starts from: the nut, the fit, the drawn size across its flats and the screw's hole
|
|
130
|
+
function nutSeat(what, m, o, fit) {
|
|
131
|
+
optionsOf(what, o, '{ kind: \'hex\' }');
|
|
132
|
+
const fx = fixingOf(what, m, o), pr = printerOf(what, o.printer), nut = nutOf(what, fx, o.kind ?? fx.nut?.kind ?? 'hex'), f = fitOf(what, o.fit ?? fit, pr), comp = pr.n('hole_comp'), h = through(what, fx, o);
|
|
133
|
+
const flats = r3(nut.flats + comp + f.clearance), corner = r3(nut.kind === 'square' ? flats * Math.SQRT2 : flats / COS30);
|
|
134
|
+
const how = `${cite(fx, nut.figures[0])} ${mm(nut.flats)} mm plus ${pr.cite('hole_comp')} ${mm(comp)} mm${f.clearance ? ` and ${isNum(f.name) ? 'the fit given' : pr.cite(f.name)} ${mm(f.clearance)} mm` : ''}`;
|
|
135
|
+
return { fx, pr, nut, f, comp, h, flats, corner, how, rests: [...figures(fx, nut.figures), pr.rest('hole_comp'), ...f.rests, ...h.rests] };
|
|
136
|
+
}
|
|
137
|
+
const nutName = (s) => `${a(s.fx.thread)} ${s.nut.kind === 'hex' ? '' : `${s.nut.kind} `}nut`;
|
|
138
|
+
// A pocket for a nut along the screw's axis, drawn going down from z = 0: a hexagon through shapes, a square drawn here
|
|
139
|
+
function pocket(s, flats, depth, hole, at, into) {
|
|
140
|
+
if (s.nut.kind !== 'square') return hexPocket({ flats, height: depth, hole, at, into });
|
|
141
|
+
const box = translate([0, 0, -depth / 2], cuboid({ size: [flats, flats, depth] }));
|
|
142
|
+
if (into === '+z') { // a 45° roof from the corners to the hole, as the hexagon's
|
|
143
|
+
const rise = (flats * Math.SQRT2 - hole) / 2, roof = translate([0, 0, -depth - rise / 2], rotateZ(Math.PI / 4, cylinderElliptic({ height: rise, startRadius: [hole / 2, hole / 2], endRadius: [flats / Math.SQRT2, flats / Math.SQRT2], segments: 4 })));
|
|
144
|
+
return along(jscad.booleans.union(box, roof), into, at);
|
|
145
|
+
}
|
|
146
|
+
return along(into in UP ? rotateZ(Math.PI / 4, box) : box, into, at); // across a part: turned corner up, its two upper faces at 45°
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* A pocket for a nut, let in from a face along the screw's axis, as numbers.
|
|
151
|
+
* @param {Fixing | string} m
|
|
152
|
+
* @param {{ kind?: string, depth?: number, thickness?: number, fit?: string | number, hole?: string, printer?: object, into?: string, axis?: string, sets?: object }} [o]
|
|
153
|
+
* kind: hex, square or lock (default the model's, else hex); depth: of the pocket (default the nut's height and two
|
|
154
|
+
* layers); thickness: the part's there (a pocket deeper than the part is refused); fit: snug (the default: no clearance once printed, so the nut cannot turn), slip, press, or a clearance in mm
|
|
155
|
+
* @returns {{ thread: string, kind: string, flats: number, nominal: number, corner: number, depth: number, height: number, hole: number, clearance: number, roof: number, into: string, rests: object[], findings: object[] }}
|
|
156
|
+
* flats: across the flats, as drawn; nominal: the nut's; corner: across the pocket's corners; roof: the height of the 45° roof, going up from the bed
|
|
157
|
+
*/
|
|
158
|
+
export function nutPocketModel(m, o = {}) {
|
|
159
|
+
const what = 'nutPocket', s = nutSeat(what, m, o, 'snug'), { fx, pr, nut, h } = s, dir = directionOf(what, o), layer = pr.n('layer'), out = [];
|
|
160
|
+
const depth = o.depth == null ? r3(nut.height + DEFAULTS.nut_sink.value * layer) : positive(what, 'depth', o.depth), roof = dir.into === '+z' ? r3((s.corner - h.diameter) / 2) : 0;
|
|
161
|
+
inPart(what, o, depth + roof, `a pocket ${mm(depth)} mm deep for ${nutName(s)}${roof ? ` with its ${mm(roof)} mm roof` : ''}`);
|
|
162
|
+
out.push(finding('info', `a pocket for ${nutName(s)} drawn ${mm(s.flats)} mm across the flats and ${mm(depth)} mm deep: ${s.how}; the nut is ${mm(nut.height)} mm high (${cite(fx, nut.figures[1])})${o.depth == null ? `, sunk ${DEFAULTS.nut_sink.value} layers of ${pr.cite('layer')}` : ''}`,
|
|
163
|
+
'nutPocket.drawn', { values: { flats: s.flats, depth, hole: h.diameter, clearance: s.f.clearance }, refs: { thread: fx.thread, set: fx.set, nut: nut.kind } }));
|
|
164
|
+
if (depth < nut.height - 1e-9) out.push(finding('warn', `the nut stands ${mm(nut.height - depth)} mm proud of a ${mm(depth)} mm pocket`, 'nutPocket.proud', { values: { depth, height: nut.height } }));
|
|
165
|
+
const side = r3(s.flats / Math.sqrt(3)), bridge = pr.n('bridge');
|
|
166
|
+
out.push(!dir.across ? finding('pass', roof ? `${said(dir.into)}, the pocket has a 45° roof ${mm(roof)} mm high from its corners to the hole: nothing spans` : `${said(dir.into)}, the pocket is open above: it prints as drawn`, 'nutPocket.printable', { values: { into: dir.into } })
|
|
167
|
+
: nut.kind === 'square' ? finding('pass', `${said(dir.into)}, the square is turned corner up: its two upper faces lie at 45°`, 'nutPocket.printable', { values: { into: dir.into } })
|
|
168
|
+
: finding(side <= bridge + 1e-9 ? 'pass' : 'warn', `${said(dir.into)}, the hexagon has a flat on top: a ${mm(side)} mm bridge, ${side <= bridge + 1e-9 ? 'within' : 'past'} the printer's ${mm(bridge)} mm`, 'nutPocket.printable', { values: { into: dir.into, bridge: side, limit: bridge } }));
|
|
169
|
+
return { thread: fx.thread, kind: nut.kind, flats: s.flats, nominal: nut.flats, corner: s.corner, depth, height: nut.height, hole: h.diameter, clearance: s.f.clearance, roof, into: dir.into, rests: [...s.rests, pr.rest('layer')], findings: out };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* A pocket for a nut, to subtract: open at the face at `at`, going in along the screw's axis. A hexagon goes through
|
|
174
|
+
* @rulecad/shapes' nutPocket. The screw's hole is a hole() of its own.
|
|
175
|
+
* @param {Fixing | string} m
|
|
176
|
+
* @param {{ kind?: string, depth?: number, fit?: string | number, hole?: string, printer?: object, into?: string, axis?: string, sets?: object, at?: number[] }} [o] as nutPocketModel
|
|
177
|
+
* @returns {object} a JSCAD geom3 to subtract, with .model
|
|
178
|
+
*/
|
|
179
|
+
export function nutPocket(m, o = {}) {
|
|
180
|
+
const p = nutPocketModel(m, o), s = { nut: { kind: p.kind } };
|
|
181
|
+
return Object.assign(pocket(s, p.flats, p.depth, p.hole, pointOf('nutPocket', o.at), p.into), { model: p });
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* A slot a nut slides into from the side, across the screw's axis, as numbers.
|
|
186
|
+
* @param {Fixing | string} m
|
|
187
|
+
* @param {{ kind?: string, axis?: 'x' | 'y' | 'z', into?: string, depth: number, fit?: string | number, hole?: string, printer?: object, sets?: object }} o
|
|
188
|
+
* axis: the screw's (default z, standing up); into: the way the nut slides in, square to the axis (default +x for a
|
|
189
|
+
* screw standing up, -z, dropped in from the top, for one lying down); depth: from the face to the screw's axis;
|
|
190
|
+
* fit: slip (the default: the nut slides in by hand), snug, press, or a clearance in mm
|
|
191
|
+
* @returns {{ thread: string, kind: string, width: number, gap: number, depth: number, reach: number, hole: number, axis: string, into: string, span: number, rise: number, rests: object[], findings: object[] }}
|
|
192
|
+
* width: across the nut's flats, as drawn; gap: along the screw, for the nut's height; reach: how far the slot goes
|
|
193
|
+
* in from the face; span: what its roof bridges; rise: how far the roof rises at 45° where that is wider than the printer bridges
|
|
194
|
+
*/
|
|
195
|
+
export function nutTrapModel(m, o = {}) {
|
|
196
|
+
const what = o?.slot ?? 'nutTrap', s = nutSeat(what, m, o, 'slip'), { fx, pr, nut, h } = s, layer = pr.n('layer'), bridge = pr.n('bridge'), out = [];
|
|
197
|
+
const axis = oneOf(what, 'axis', o.axis ?? 'z', ['x', 'y', 'z']), into = oneOf(what, 'into', o.into ?? (axis === 'z' ? '+x' : '-z'), DIRECTIONS);
|
|
198
|
+
if (into[1] === axis) throw new Error(`${what}: the nut slides in across the screw, so into is square to axis (got into ${into} with the screw along ${axis}). A pocket along the screw is nutPocket`);
|
|
199
|
+
if (into === '+z') throw new Error(`${what}: a slot open to the bed has the nut's width to bridge over its whole length: turn it so the nut goes in from the top (-z) or from a side (+x, -x, +y, -y)`);
|
|
200
|
+
const depth = positive(what, 'depth (from the face to the screw\'s axis)', o.depth), raw = nut.height + s.comp + s.f.clearance, gap = axis === 'z' ? layers(raw, 2 * layer) : r3(raw); // (an even number of layers, so the slot's floor and roof both fall on layers when its middle does)
|
|
201
|
+
const reach = r3(depth + (nut.kind === 'square' ? s.flats / 2 : s.flats / (2 * COS30))), span = into === '-z' ? 0 : axis === 'z' ? s.flats : gap, rise = span > bridge ? r3((span - bridge) / 2) : 0;
|
|
202
|
+
out.push(finding('info', `a slot for ${nutName(s)} drawn ${mm(s.flats)} mm across the flats and ${mm(gap)} mm along the screw, ${mm(reach)} mm in from the face: ${s.how}; the nut is ${mm(nut.height)} mm high (${cite(fx, nut.figures[1])})${axis === 'z' ? ', its gap an even number of layers' : ''}`,
|
|
203
|
+
'nutTrap.drawn', { values: { width: s.flats, gap, reach, hole: h.diameter, clearance: s.f.clearance }, refs: { thread: fx.thread, set: fx.set, nut: nut.kind } }));
|
|
204
|
+
out.push(finding('pass', into === '-z' ? 'dropped in from the top, the slot is open above: nothing spans' : rise ? `from the side, the slot's roof spans ${mm(span)} mm, more than the printer's ${mm(bridge)} mm bridge: it rises ${mm(rise)} mm at 45° to a flat ${mm(bridge)} mm wide`
|
|
205
|
+
: `from the side, the slot's roof is a ${mm(span)} mm bridge, within the printer's ${mm(bridge)} mm`, 'nutTrap.printable', { values: { into, span, limit: bridge, rise } }));
|
|
206
|
+
if (rise) out.push(finding('info', 'the slot\'s floor is flat and its roof is not: bring the screw in through the floor, so it pulls the nut down on to the flat', 'nutTrap.side'));
|
|
207
|
+
return { thread: fx.thread, kind: nut.kind, width: s.flats, gap, depth, reach, hole: h.diameter, axis, into, span, rise, rests: [...s.rests, pr.rest('layer'), pr.rest('bridge')], findings: out };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A slot a nut slides into from the side, to subtract. `at` is the point on the face in line with the nut's centre.
|
|
212
|
+
* From a side it goes through @rulecad/shapes' wallOpening (a roof that bridges, rising at 45° where it is too wide);
|
|
213
|
+
* dropped in from the top, the slot ends in the nut's own outline, so the nut sits on the screw's axis.
|
|
214
|
+
* @param {Fixing | string} m
|
|
215
|
+
* @param {{ kind?: string, axis?: 'x' | 'y' | 'z', into?: string, depth: number, fit?: string | number, hole?: string, printer?: object, sets?: object, at?: number[] }} o as nutTrapModel
|
|
216
|
+
* @returns {object} a JSCAD geom3 to subtract, with .model
|
|
217
|
+
*/
|
|
218
|
+
export function nutTrap(m, o = {}) {
|
|
219
|
+
const t = nutTrapModel(m, o), at = pointOf(o?.slot ?? 'nutTrap', o.at), pr = printerOf('nutTrap', o.printer), w = t.width / 2;
|
|
220
|
+
if (t.into !== '-z') return Object.assign(wallOpening(t.axis === 'z' ? { width: t.width, height: t.gap, depth: t.reach, at, into: t.into, bridge: pr.n('bridge') } : { width: t.gap, height: t.width, depth: t.reach, at, into: t.into, bridge: pr.n('bridge') }), { model: t });
|
|
221
|
+
// from the top: the slot's outline seen along the screw (across, then up), ending in the lower half of the nut
|
|
222
|
+
const end = t.kind === 'square' ? [[-w, -t.depth - w], [w, -t.depth - w]] : [[-w, -t.depth - w * Math.tan(Math.PI / 6)], [0, -t.reach], [w, -t.depth - w * Math.tan(Math.PI / 6)]];
|
|
223
|
+
const slab = translate([0, 0, -t.gap / 2], extrudeLinear({ height: t.gap }, polygon({ points: [[-w, OUT], ...end, [w, OUT]] })));
|
|
224
|
+
// (across, up, along the screw) to the part's x, y, z
|
|
225
|
+
const turn = t.axis === 'x' ? [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1] : [-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1];
|
|
226
|
+
return Object.assign(translate(at, transform(turn, slab)), { model: t });
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** A slot for a thin square nut, as numbers: nutTrapModel for a square nut, dropped in from the top across a screw lying along x unless told otherwise. */
|
|
230
|
+
export function squareNutSlotModel(m, o = {}) { optionsOf('squareNutSlot', o, '{ depth: 6 }'); return nutTrapModel(m, { axis: 'x', ...o, kind: 'square', slot: 'squareNutSlot' }); }
|
|
231
|
+
/**
|
|
232
|
+
* A slot for a thin square nut (DIN 562), to subtract: the nut drops in from the top and the screw comes in from the side.
|
|
233
|
+
* @param {Fixing | string} m
|
|
234
|
+
* @param {{ axis?: 'x' | 'y' | 'z', into?: string, depth: number, fit?: string | number, printer?: object, sets?: object, at?: number[] }} o as nutTrap
|
|
235
|
+
* @returns {object} a JSCAD geom3 to subtract, with .model
|
|
236
|
+
*/
|
|
237
|
+
export function squareNutSlot(m, o = {}) { optionsOf('squareNutSlot', o, '{ depth: 6 }'); return nutTrap(m, { axis: 'x', ...o, kind: 'square', slot: 'squareNutSlot' }); }
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* A nut closed inside the part, put in while the print is paused, as numbers: a pocket with a flat floor at `at`, as
|
|
241
|
+
* high as the nut and a layer, and a 45° roof over it to the screw's hole. The pause height is where the pocket's
|
|
242
|
+
* walls end: the printer stops there, the nut goes in, and the next layers close the roof.
|
|
243
|
+
* @param {Fixing | string} m
|
|
244
|
+
* @param {{ kind?: string, fit?: string | number, hole?: string, thickness?: number, printer?: object, sets?: object, at?: number[] }} [o] at: the middle of the pocket's floor, its z measured from the bed; fit: slip by default;
|
|
245
|
+
* thickness: the part's height there, from the bed (a pocket whose roof would break out of the top is refused)
|
|
246
|
+
* @returns {{ thread: string, kind: string, flats: number, height: number, pause: number, layer: number, roof: number, top: number, hole: number, rests: object[], findings: object[] }}
|
|
247
|
+
* height: of the pocket's upright walls; pause: the z to pause at; layer: the number of the last layer laid before the pause; top: the z where the roof meets the hole
|
|
248
|
+
*/
|
|
249
|
+
export function captiveNutModel(m, o = {}) {
|
|
250
|
+
const what = 'captiveNut', s = nutSeat(what, m, o, 'slip'), { fx, pr, nut, h } = s, at = pointOf(what, o.at), layer = pr.n('layer'), out = [];
|
|
251
|
+
if (!(layer > 0)) throw new Error(`${what}: the printer's layer is above 0 mm (got ${shown(layer)})`);
|
|
252
|
+
const height = layers(nut.height + DEFAULTS.nut_slack.value * layer, layer), pause = r3(at[2] + height), n = Math.round(pause / layer), roof = r3((s.corner - h.diameter) / 2);
|
|
253
|
+
if (o.thickness != null) { positive(what, 'thickness', o.thickness); if (pause + roof > o.thickness - 1e-9) throw new Error(`${what}: a closed pocket for ${nutName(s)} from z = ${mm(at[2])} mm ends its roof at z = ${mm(r3(pause + roof))} mm, and the part is ${mm(o.thickness)} mm high there: it is deeper than the part, and would break out of its top. Start it lower, or make the part taller`); }
|
|
254
|
+
out.push(finding('info', `a closed pocket for ${nutName(s)} drawn ${mm(s.flats)} mm across the flats and ${mm(height)} mm high: ${s.how}; the nut is ${mm(nut.height)} mm high (${cite(fx, nut.figures[1])}), with ${DEFAULTS.nut_slack.value} layer over it`,
|
|
255
|
+
'captiveNut.drawn', { values: { flats: s.flats, height, hole: h.diameter, clearance: s.f.clearance }, refs: { thread: fx.thread, set: fx.set, nut: nut.kind } }));
|
|
256
|
+
out.push(finding('info', `pause the print at z = ${mm(pause)} mm, once layer ${n} is down (${mm(layer)} mm layers, the bed at z = 0), drop the ${fx.thread} ${nut.kind === 'hex' ? '' : `${nut.kind} `}nut in, and carry on: the next ${mm(roof)} mm closes a roof over it`, 'captiveNut.pause', { values: { pause, layer: n, height: layer } }));
|
|
257
|
+
out.push(finding('info', 'the nut lies on the pocket\'s flat floor and its roof is a cone: bring the screw in from below, through the floor, so it pulls the nut on to the flat', 'captiveNut.side'));
|
|
258
|
+
out.push(finding('pass', `closed in the part, the pocket has a flat floor and a 45° roof ${mm(roof)} mm high from its corners to the hole: nothing spans`, 'captiveNut.printable', { values: { into: '+z' } }));
|
|
259
|
+
return { thread: fx.thread, kind: nut.kind, flats: s.flats, height, pause, layer: n, roof, top: r3(pause + roof), hole: h.diameter, rests: [...s.rests, pr.rest('layer'), rest('fixings.nut_slack', DEFAULTS.nut_slack)], findings: out };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* A nut closed inside the part, to subtract: the pocket and its roof, from the floor at `at` upwards. The screw's hole
|
|
264
|
+
* is a hole() of its own, through the floor.
|
|
265
|
+
* @param {Fixing | string} m @param {{ kind?: string, fit?: string | number, hole?: string, printer?: object, sets?: object, at?: number[] }} [o] as captiveNutModel
|
|
266
|
+
* @returns {object} a JSCAD geom3 to subtract, with .model
|
|
267
|
+
*/
|
|
268
|
+
export function captiveNut(m, o = {}) {
|
|
269
|
+
const c = captiveNutModel(m, o);
|
|
270
|
+
return Object.assign(pocket({ nut: { kind: c.kind } }, c.flats, c.height, c.hole, pointOf('captiveNut', o.at), '+z'), { model: c });
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// ---------- insert boss ----------
|
|
274
|
+
/**
|
|
275
|
+
* A boss for a heat-set insert, as numbers: the hole the insert melts into, its depth, and the wall round it, each
|
|
276
|
+
* from the insert's rules. Refused where the wall is thinner than the insert's rule allows, or the part shorter than
|
|
277
|
+
* the insert.
|
|
278
|
+
* @param {Fixing | string} m
|
|
279
|
+
* @param {{ height?: number, outer?: number, wall?: number, through?: boolean, root?: number, printer?: object, sets?: object }} [o]
|
|
280
|
+
* height: of the boss, or the part's thickness there (default the blind hole's depth, up to a whole layer); outer:
|
|
281
|
+
* the boss's diameter, or wall: the plastic round the hole (default the insert's least wall); through: the hole runs
|
|
282
|
+
* out of the far side; root: the 45° flare where the boss meets what it stands on (default the printer's chamfer)
|
|
283
|
+
* @returns {{ thread: string, hole: number, depth: number, through: boolean, outer: number, wall: number, least: number, height: number, root: number, lead: number, below: number, insert: { diameter: number, length: number }, rests: object[], findings: object[] }}
|
|
284
|
+
* hole: as drawn; least: the wall the insert's rule asks; below: how far a blind hole runs on under the boss's foot
|
|
285
|
+
*/
|
|
286
|
+
export function insertBossModel(m, o = {}) {
|
|
287
|
+
const what = 'insertBoss';
|
|
288
|
+
optionsOf(what, o, '{ height: 8 }');
|
|
289
|
+
const fx = fixingOf(what, m, o), pr = printerOf(what, o.printer), out = [];
|
|
290
|
+
if (!fx.made.insert) throw new Error(`${what}: ${fx.thread} has no heat-set insert in its rule set (${fx.set})`);
|
|
291
|
+
const through = o.through ?? false, h = holeModel(fx, { kind: 'insert', through, printer: o.printer }), least = figure(what, fx, 'insert_wall'), long = figure(what, fx, 'insert_length'), blind = figure(what, fx, 'insert_depth');
|
|
292
|
+
if (o.outer != null && o.wall != null) throw new Error(`${what}: give outer (the boss's diameter) or wall (the plastic round the hole), not both`);
|
|
293
|
+
const outer = o.outer != null ? positive(what, 'outer', o.outer) : r3(h.diameter + 2 * (o.wall != null ? positive(what, 'wall', o.wall) : least)), wall = r3((outer - h.diameter) / 2);
|
|
294
|
+
if (wall < least - 1e-9) throw new Error(`${what}: ${mm(wall)} mm of wall round ${a(fx.thread)} insert's ${mm(h.diameter)} mm hole is thinner than the insert allows: ${cite(fx, 'insert_wall')} asks ${mm(least)} mm, so a boss ${mm(h.diameter + 2 * least)} mm across or more`);
|
|
295
|
+
const height = o.height == null ? layers(through ? long : blind, pr.n('layer')) : positive(what, 'height', o.height);
|
|
296
|
+
if (height < long - 1e-9) throw new Error(`${what}: the part is ${mm(height)} mm thick there and ${a(fx.thread)} insert ${mm(long)} mm long (${cite(fx, 'insert_length')}): it would stand proud. ${mm(long)} mm or more with { through: true }, ${mm(blind)} mm for a blind hole`);
|
|
297
|
+
const depth = through ? height : blind, below = !through && height < blind - 1e-9 ? r3(blind - height) : 0, root = o.root == null ? pr.n('chamfer') : o.root;
|
|
298
|
+
if (!(isNum(root) && root >= 0)) throw new Error(`${what}: root is the flare at the boss's foot, 0 mm or more (got ${shown(o.root)})`);
|
|
299
|
+
out.push(finding('info', `a boss for ${a(fx.thread)} insert drawn ${mm(outer)} mm across and ${mm(height)} mm high round a ${mm(h.diameter)} mm hole ${through ? 'right through' : `${mm(depth)} mm deep`}: ${cite(fx, 'insert_hole')}, as drawn (no hole compensation), with ${mm(wall)} mm of wall where ${cite(fx, 'insert_wall')} asks ${mm(least)} mm`,
|
|
300
|
+
'insertBoss.drawn', { values: { hole: h.diameter, depth, outer, wall, least, height }, refs: { thread: fx.thread, set: fx.set } }));
|
|
301
|
+
if (below) out.push(finding('warn', `the blind hole runs ${mm(below)} mm on under the boss's foot (${cite(fx, 'insert_depth')} asks ${mm(blind)} mm): what it stands on must be thicker than that there`, 'insertBoss.depth', { values: { below, depth, height } }));
|
|
302
|
+
out.push(finding('pass', 'standing up, the boss is a plain column with its hole open above: it prints as drawn, and the insert goes in from the top', 'insertBoss.printable', { values: { into: '-z' } }));
|
|
303
|
+
return { thread: fx.thread, hole: h.diameter, depth, through, outer, wall, least, height, root, lead: h.lead, below, insert: { diameter: figure(what, fx, 'insert_diameter'), length: long },
|
|
304
|
+
rests: [...figures(fx, ['insert_hole', 'insert_wall', 'insert_length', 'insert_depth']), pr.rest('layer'), pr.rest('chamfer')], findings: out };
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* A boss for a heat-set insert: the column to add, standing up from `at` (the middle of its foot), and the hole to
|
|
309
|
+
* subtract once the boss is joined to what it stands on.
|
|
310
|
+
* @param {Fixing | string} m @param {{ height?: number, outer?: number, wall?: number, through?: boolean, root?: number, printer?: object, sets?: object, at?: number[] }} [o] as insertBossModel
|
|
311
|
+
* @returns {{ boss: object, hole: object, model: object }} boss: a JSCAD geom3 to add; hole: one to subtract
|
|
312
|
+
*/
|
|
313
|
+
export function insertBoss(m, o = {}) {
|
|
314
|
+
const b = insertBossModel(m, o), at = pointOf('insertBoss', o.at), R = b.outer / 2, r = b.hole / 2;
|
|
315
|
+
const boss = translate(at, lathe([[0, 0], [R + b.root, 0], [R, b.root], [R, b.height], [0, b.height]], SEGMENTS));
|
|
316
|
+
const cut = along(bore([...(b.lead ? [[r + b.lead, 0], [r, b.lead]] : []), [r, b.depth]], { through: b.through }), '-z', [at[0], at[1], at[2] + b.height]);
|
|
317
|
+
return { boss, hole: cut, model: b };
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* What a printer can make of it, as findings. A fixing is bought, so it fails, and so does a screw, a nut, a washer
|
|
322
|
+
* or an insert drawn as a light solid; a hole's, a seat's or a printed thread's model (or the solid made from one)
|
|
323
|
+
* gives its finding on how it prints in the direction it was drawn for, and so does hardware with its thread drawn.
|
|
324
|
+
* @param {object} x a fixing's model, a model from holeModel, threadModel, a seat's twin or a piece of hardware's, or a solid one of them made
|
|
325
|
+
* @returns {object[]} findings
|
|
326
|
+
*/
|
|
327
|
+
export function printable(x) {
|
|
328
|
+
const bought = (thread, item) => [finding('fail', `${a(thread)} ${item === 'thread' ? 'fixing' : item} is bought and fitted, not printed: its hole and its seat are what print (hole, counterbore, nutPocket)${['screw', 'nut'].includes(item) ? `, or draw it with its thread to print it ({ display: 'thread' })` : ''}`, 'fixing.printable')];
|
|
329
|
+
if (x?.kind === 'fixing') return bought(x.thread, x.item);
|
|
330
|
+
const model = x?.model && Array.isArray(x.model.findings) ? x.model : x?.model?.model && Array.isArray(x.model.model.findings) ? x.model.model : x;
|
|
331
|
+
if (!model || !Array.isArray(model.findings)) throw new Error(`printable: give a fixing's model, or a hole's, a seat's or a thread's (holeModel, counterboreModel, nutPocketModel, threadModel), not ${shown(x)}`);
|
|
332
|
+
const found = model.findings.filter((f) => typeof f.code === 'string' && f.code.endsWith('.printable'));
|
|
333
|
+
return !found.length && ['screw', 'nut', 'washer', 'insert'].includes(model.item) ? bought(model.thread, model.item) : found;
|
|
334
|
+
}
|
package/strength.d.mts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether enough thread is engaged, against the engagement rule for what the thread is in: 1 diameter in steel, 2 in
|
|
3
|
+
* aluminium, 2.5 in plastic (the engagement rule set of @rulecad/rules).
|
|
4
|
+
* @param {Fixing | string} m a fixing's model or name @param {{ depth: number, material: string | object, sets?: object }} o
|
|
5
|
+
* depth: the length of thread engaged, in mm; material: a class (plastic, aluminium, steel), a material of the kit
|
|
6
|
+
* (pla, petg, al6061, al7075, s275, ss304) or a material's rule set
|
|
7
|
+
* @returns {{ thread: string, depth: number, need: number, turns: number, diameters: number, class: string, material: string | null, enough: boolean, rests: object[], findings: object[] }}
|
|
8
|
+
* need: the depth that would do; turns: threads engaged; diameters: the depth in diameters of the screw
|
|
9
|
+
*/
|
|
10
|
+
export function engagement(m: Fixing | string, o?: {
|
|
11
|
+
depth: number;
|
|
12
|
+
material: string | object;
|
|
13
|
+
sets?: object;
|
|
14
|
+
}): {
|
|
15
|
+
thread: string;
|
|
16
|
+
depth: number;
|
|
17
|
+
need: number;
|
|
18
|
+
turns: number;
|
|
19
|
+
diameters: number;
|
|
20
|
+
class: string;
|
|
21
|
+
material: string | null;
|
|
22
|
+
enough: boolean;
|
|
23
|
+
rests: object[];
|
|
24
|
+
findings: object[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The load that strips an internal thread, from its shear area and the strength of what it is cut or formed in,
|
|
28
|
+
* against the screw's own proof load. The shear area is the handbook's for a 60° thread at its basic sizes,
|
|
29
|
+
* 0.875 π d Le; the shear strength is the material's strength over √3, an estimate.
|
|
30
|
+
* @param {Fixing | string} m @param {{ depth: number, material: string | object, screw?: 'steel' | 'stainless', proof?: number, load?: number, sets?: object }} o
|
|
31
|
+
* depth: the length of thread engaged; material: what the internal thread is in; screw: steel (its property class, the
|
|
32
|
+
* default) or stainless; proof: another screw's proof stress in MPa (830 for class 10.9); load: the load the joint
|
|
33
|
+
* carries along the screw, in N, to hold with twice the margin
|
|
34
|
+
* @returns {{ thread: string, depth: number, material: string, area: number, shear: number, strip: number, stressArea: number, proof: number, margin: number, depthFor: number, load: number | null, rests: object[], findings: object[] }}
|
|
35
|
+
* area: the internal thread's shear area, mm²; shear: the shear strength taken, MPa; strip: the load that strips the thread, N;
|
|
36
|
+
* proof: the screw's proof load, N; margin: strip over proof (under 1: the thread goes first); depthFor: the depth at which the thread is as strong as the screw
|
|
37
|
+
*/
|
|
38
|
+
export function stripping(m: Fixing | string, o?: {
|
|
39
|
+
depth: number;
|
|
40
|
+
material: string | object;
|
|
41
|
+
screw?: "steel" | "stainless";
|
|
42
|
+
proof?: number;
|
|
43
|
+
load?: number;
|
|
44
|
+
sets?: object;
|
|
45
|
+
}): {
|
|
46
|
+
thread: string;
|
|
47
|
+
depth: number;
|
|
48
|
+
material: string;
|
|
49
|
+
area: number;
|
|
50
|
+
shear: number;
|
|
51
|
+
strip: number;
|
|
52
|
+
stressArea: number;
|
|
53
|
+
proof: number;
|
|
54
|
+
margin: number;
|
|
55
|
+
depthFor: number;
|
|
56
|
+
load: number | null;
|
|
57
|
+
rests: object[];
|
|
58
|
+
findings: object[];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The clamp force a tightening torque gives, or the torque for a clamp force: T = K d F, with the nut factor K an
|
|
62
|
+
* estimate (0.2 unless given). Give torque or force.
|
|
63
|
+
* @param {Fixing | string} m @param {{ torque?: number, force?: number, K?: number, screw?: 'steel' | 'stainless', proof?: number, sets?: object }} o
|
|
64
|
+
* torque: in N·m; force: the clamp force (preload) wanted, in N; K: another nut factor (a lubricated thread's is lower)
|
|
65
|
+
* @returns {{ thread: string, torque: number, force: number, K: number, proof: number, share: number, full: { force: number, torque: number }, rests: object[], findings: object[] }}
|
|
66
|
+
* share: the force as a share of the screw's proof load; full: the force and torque of a screw tightened to three quarters of its proof load
|
|
67
|
+
*/
|
|
68
|
+
export function preload(m: Fixing | string, o?: {
|
|
69
|
+
torque?: number;
|
|
70
|
+
force?: number;
|
|
71
|
+
K?: number;
|
|
72
|
+
screw?: "steel" | "stainless";
|
|
73
|
+
proof?: number;
|
|
74
|
+
sets?: object;
|
|
75
|
+
}): {
|
|
76
|
+
thread: string;
|
|
77
|
+
torque: number;
|
|
78
|
+
force: number;
|
|
79
|
+
K: number;
|
|
80
|
+
proof: number;
|
|
81
|
+
share: number;
|
|
82
|
+
full: {
|
|
83
|
+
force: number;
|
|
84
|
+
torque: number;
|
|
85
|
+
};
|
|
86
|
+
rests: object[];
|
|
87
|
+
findings: object[];
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* The tightening torque for a clamp force: preload the other way round.
|
|
91
|
+
* @param {Fixing | string} m @param {{ force: number, K?: number, screw?: 'steel' | 'stainless', proof?: number, sets?: object }} o
|
|
92
|
+
* @returns {{ thread: string, torque: number, force: number, K: number, proof: number, share: number, full: { force: number, torque: number }, rests: object[], findings: object[] }}
|
|
93
|
+
*/
|
|
94
|
+
export function torqueFor(m: Fixing | string, o?: {
|
|
95
|
+
force: number;
|
|
96
|
+
K?: number;
|
|
97
|
+
screw?: "steel" | "stainless";
|
|
98
|
+
proof?: number;
|
|
99
|
+
sets?: object;
|
|
100
|
+
}): {
|
|
101
|
+
thread: string;
|
|
102
|
+
torque: number;
|
|
103
|
+
force: number;
|
|
104
|
+
K: number;
|
|
105
|
+
proof: number;
|
|
106
|
+
share: number;
|
|
107
|
+
full: {
|
|
108
|
+
force: number;
|
|
109
|
+
torque: number;
|
|
110
|
+
};
|
|
111
|
+
rests: object[];
|
|
112
|
+
findings: object[];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* The pressure under a screw's head against what it sits on, and the washer that would bring it within. The head
|
|
116
|
+
* bears on the ring between its own diameter and the clearance hole as drawn; the limit is the material's strength.
|
|
117
|
+
* @param {Fixing | string} m @param {{ head?: string, material: string | object, force?: number, torque?: number, K?: number, hole?: string, printer?: object, screw?: 'steel' | 'stainless', proof?: number, sets?: object }} o
|
|
118
|
+
* head: cap, button, hex, countersunk or pan (default the model's, else cap); material: what the head sits on;
|
|
119
|
+
* force: the clamp force in N, or torque: the tightening torque in N·m (default a screw tightened fully, to three
|
|
120
|
+
* quarters of its proof load); hole: clearance (the default), close or loose
|
|
121
|
+
* @returns {{ thread: string, head: string, material: string, force: number, area: number, pressure: number, limit: number, within: boolean,
|
|
122
|
+
* washer: { diameter: number, area: number, pressure: number, within: boolean } | null, most: { force: number, torque: number, washerForce: number | null, washerTorque: number | null }, rests: object[], findings: object[] }}
|
|
123
|
+
* area: the bearing ring under the head, mm²; pressure and limit in MPa; washer: the same under the thread's plain washer;
|
|
124
|
+
* most: the greatest clamp force the seat takes and the torque for it, bare and on the washer
|
|
125
|
+
*/
|
|
126
|
+
export function seating(m: Fixing | string, o?: {
|
|
127
|
+
head?: string;
|
|
128
|
+
material: string | object;
|
|
129
|
+
force?: number;
|
|
130
|
+
torque?: number;
|
|
131
|
+
K?: number;
|
|
132
|
+
hole?: string;
|
|
133
|
+
printer?: object;
|
|
134
|
+
screw?: "steel" | "stainless";
|
|
135
|
+
proof?: number;
|
|
136
|
+
sets?: object;
|
|
137
|
+
}): {
|
|
138
|
+
thread: string;
|
|
139
|
+
head: string;
|
|
140
|
+
material: string;
|
|
141
|
+
force: number;
|
|
142
|
+
area: number;
|
|
143
|
+
pressure: number;
|
|
144
|
+
limit: number;
|
|
145
|
+
within: boolean;
|
|
146
|
+
washer: {
|
|
147
|
+
diameter: number;
|
|
148
|
+
area: number;
|
|
149
|
+
pressure: number;
|
|
150
|
+
within: boolean;
|
|
151
|
+
} | null;
|
|
152
|
+
most: {
|
|
153
|
+
force: number;
|
|
154
|
+
torque: number;
|
|
155
|
+
washerForce: number | null;
|
|
156
|
+
washerTorque: number | null;
|
|
157
|
+
};
|
|
158
|
+
rests: object[];
|
|
159
|
+
findings: object[];
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* The sold length of screw that passes through a stack of parts and engages enough at the far end, without bottoming
|
|
163
|
+
* out or standing proud: the shortest that does. Refused by name where no sold length fits, with the nearest.
|
|
164
|
+
* @param {number | number[]} stack the thicknesses the screw passes through under its head, in order, in mm (a countersunk
|
|
165
|
+
* screw's length includes its head, so its stack does too)
|
|
166
|
+
* @param {Fixing | string} m a thread or a screw ('M3', 'M3 button'): its head form is the model's, else cap
|
|
167
|
+
* @param {{ into: string | { kind: string, depth?: number, room?: number, through?: boolean, material?: string, nut?: string, length?: number }, head?: string, washer?: boolean, sunk?: number, sets?: object }} o
|
|
168
|
+
* into: what the screw ends in: 'pilot', 'tap', 'thread' (a printed one), 'insert' or 'nut', or the same with its
|
|
169
|
+
* depth (a blind hole's), room (how far the screw may go past where its thread starts), through (it may come out
|
|
170
|
+
* the far side), material (a tapped or printed thread's), nut (hex, square, lock) or length (another insert's);
|
|
171
|
+
* washer: a plain washer under the head; sunk: how far the head's seat lies under the first face (a counterbore's depth)
|
|
172
|
+
* @returns {{ name: string, thread: string, head: string, length: number, grip: number, engaged: number, need: number, room: number | null, spare: number | null, depth: number | null, into: string,
|
|
173
|
+
* lengths: { length: number, name: string, engaged: number, fits: 'short' | 'fits' | 'long' }[], rests: object[], findings: object[] }}
|
|
174
|
+
* grip: what the screw passes before its thread engages; engaged: thread in the far end; room: how far it may go (null: no limit);
|
|
175
|
+
* spare: room left past its tip; depth: for a blind hole not given a depth, the depth to draw; lengths: every sold length with its verdict
|
|
176
|
+
*/
|
|
177
|
+
export function lengthFor(stack: number | number[], m: Fixing | string, o?: {
|
|
178
|
+
into: string | {
|
|
179
|
+
kind: string;
|
|
180
|
+
depth?: number;
|
|
181
|
+
room?: number;
|
|
182
|
+
through?: boolean;
|
|
183
|
+
material?: string;
|
|
184
|
+
nut?: string;
|
|
185
|
+
length?: number;
|
|
186
|
+
};
|
|
187
|
+
head?: string;
|
|
188
|
+
washer?: boolean;
|
|
189
|
+
sunk?: number;
|
|
190
|
+
sets?: object;
|
|
191
|
+
}): {
|
|
192
|
+
name: string;
|
|
193
|
+
thread: string;
|
|
194
|
+
head: string;
|
|
195
|
+
length: number;
|
|
196
|
+
grip: number;
|
|
197
|
+
engaged: number;
|
|
198
|
+
need: number;
|
|
199
|
+
room: number | null;
|
|
200
|
+
spare: number | null;
|
|
201
|
+
depth: number | null;
|
|
202
|
+
into: string;
|
|
203
|
+
lengths: {
|
|
204
|
+
length: number;
|
|
205
|
+
name: string;
|
|
206
|
+
engaged: number;
|
|
207
|
+
fits: "short" | "fits" | "long";
|
|
208
|
+
}[];
|
|
209
|
+
rests: object[];
|
|
210
|
+
findings: object[];
|
|
211
|
+
};
|
|
212
|
+
/** The materials there are rule sets for in the kit, by name. */
|
|
213
|
+
export const MATERIALS: string[];
|
|
214
|
+
/** The classes of material the engagement rules know. */
|
|
215
|
+
export const MATERIAL_CLASSES: string[];
|
|
216
|
+
/** What a screw can end in, for lengthFor. */
|
|
217
|
+
export const ENDS: string[];
|
|
218
|
+
/**
|
|
219
|
+
* a fixing's model, as fixingModel gives it
|
|
220
|
+
*/
|
|
221
|
+
export type Fixing = import("./model.mjs").Fixing;
|