@rulecad/fixings 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +641 -2
- package/draw.d.mts +46 -0
- package/draw.mjs +85 -0
- package/fixings.d.mts +35 -0
- package/fixings.mjs +53 -0
- 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 +56 -4
- 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/strength.mjs
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// Strength and length: whether enough thread is engaged, the load that strips it, the clamp force a tightening torque
|
|
2
|
+
// gives, the pressure under a head, and the sold length that fits a stack of parts. Each returns its numbers, what
|
|
3
|
+
// they rest on, and findings in the kit's one shape. The strengths of materials come from the kit's material rule
|
|
4
|
+
// sets (pla, petg, al6061, al7075, s275, ss304), or one handed in. These are first sums for a printed joint, with
|
|
5
|
+
// their estimates named: a joint that matters is tested. Units: mm, N, N·m, MPa.
|
|
6
|
+
import pla from '@rulecad/rules/pla.json' with { type: 'json' };
|
|
7
|
+
import petg from '@rulecad/rules/petg.json' with { type: 'json' };
|
|
8
|
+
import al6061 from '@rulecad/rules/al6061.json' with { type: 'json' };
|
|
9
|
+
import al7075 from '@rulecad/rules/al7075.json' with { type: 'json' };
|
|
10
|
+
import s275 from '@rulecad/rules/s275.json' with { type: 'json' };
|
|
11
|
+
import ss304 from '@rulecad/rules/ss304.json' with { type: 'json' };
|
|
12
|
+
import { DEFAULTS, ENGAGEMENT, fixingOf, fixingModel, headOf, nutOf, screwName, figure, cite, rest, finding, positive, oneOf, isNum, shown, mm, r3, a } from './model.mjs';
|
|
13
|
+
import { holeModel } from './holes.mjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import('./model.mjs').Fixing} Fixing a fixing's model, as fixingModel gives it
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const KIT = { pla, petg, al6061, al7075, s275, ss304 };
|
|
20
|
+
/** The materials there are rule sets for in the kit, by name. */
|
|
21
|
+
export const MATERIALS = Object.keys(KIT);
|
|
22
|
+
/** The classes of material the engagement rules know. */
|
|
23
|
+
export const MATERIAL_CLASSES = ['plastic', 'aluminium', 'steel'];
|
|
24
|
+
const n1 = (x) => +x.toFixed(1), n2 = (x) => +x.toFixed(2);
|
|
25
|
+
const options = (what, o, example) => { if (o == null || typeof o !== 'object' || Array.isArray(o)) throw new Error(`${what}: the second argument is its options (${example}), not ${shown(o)}`); return o; };
|
|
26
|
+
|
|
27
|
+
// A material from what a function was handed: a kit set's name ('PLA'), the workspace's set of that name (sets), or a
|
|
28
|
+
// rule set itself. Its class is told by its stiffness: under 20 GPa a plastic, under 100 GPa an aluminium, else a steel.
|
|
29
|
+
function materialOf(what, material, sets) {
|
|
30
|
+
if (material == null) throw new Error(`${what}: give a material, what the thread is in or the head sits on: ${MATERIALS.join(', ')}, or a rule set with a strength ({ name, rules })`);
|
|
31
|
+
let set = null;
|
|
32
|
+
if (typeof material === 'object' && material.rules && typeof material.rules === 'object') set = material;
|
|
33
|
+
else if (typeof material === 'string') {
|
|
34
|
+
const key = material.trim().toLowerCase(), own = sets && typeof sets === 'object' ? (Array.isArray(sets) ? sets.find((s) => s?.name === key) : sets[key]) : null;
|
|
35
|
+
set = own?.rules ? { name: key, ...own } : KIT[key] ?? null;
|
|
36
|
+
if (!set) throw new Error(`${what}: no material "${material}". There are: ${MATERIALS.join(', ')}. For another, hand in its rule set ({ name, rules: { strength, modulus } }), or the workspace's sets with it in`);
|
|
37
|
+
} else throw new Error(`${what}: material is a material's name (${MATERIALS.join(', ')}) or its rule set ({ name, rules }), not ${shown(material)}`);
|
|
38
|
+
const name = set.name ?? 'the material', num = (k) => { const f = set.rules[k]; if (f && !(isNum(f.value) && f.value > 0)) throw new Error(`${what}: ${name}.${k} is a number above 0 (got ${shown(f.value)})`); return f ? { ...f, name: `${name}.${k}` } : null; };
|
|
39
|
+
const strength = num('strength'), across = num('strength_z'), modulus = num('modulus');
|
|
40
|
+
if (!strength) throw new Error(`${what}: ${name} has no strength in its rule set: a tensile or yield strength in MPa is needed`);
|
|
41
|
+
if (!modulus) throw new Error(`${what}: ${name} has no modulus in its rule set, which tells a plastic from a metal`);
|
|
42
|
+
return { name, cls: modulus.value < 20000 ? 'plastic' : modulus.value < 100000 ? 'aluminium' : 'steel', strength, across, modulus };
|
|
43
|
+
}
|
|
44
|
+
// The class of material an engagement rule is read by: a class by name, or a material's
|
|
45
|
+
function classOf(what, material, sets) {
|
|
46
|
+
if (typeof material === 'string' && MATERIAL_CLASSES.includes(material.trim().toLowerCase())) return { cls: material.trim().toLowerCase(), name: null };
|
|
47
|
+
if (material == null) throw new Error(`${what}: give a material: a class (${MATERIAL_CLASSES.join(', ')}) or a material (${MATERIALS.join(', ')})`);
|
|
48
|
+
return materialOf(what, material, sets);
|
|
49
|
+
}
|
|
50
|
+
// The weaker of a printed material's two strengths, with what it says about itself
|
|
51
|
+
function weakest(mat) {
|
|
52
|
+
const f = mat.across && mat.across.value < mat.strength.value ? mat.across : mat.strength;
|
|
53
|
+
const note = mat.cls !== 'plastic' ? '' : mat.across ? ` (${f.name}, the weaker way of the print)` : ` (${mat.name} has no strength across its layers, strength_z: the strength along them is used, and a screw standing across the layers may hold less)`;
|
|
54
|
+
return { f, note };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// A screw's own strength: its tensile stress area, and its proof load from its property class
|
|
58
|
+
function proofOf(what, fx, o) {
|
|
59
|
+
if (fx.form === 'plastic') throw new Error(`${what}: ${fx.thread} is a thread-forming screw for plastic, with no property class in its rule set (${fx.set}): its maker's sheet gives what it holds`);
|
|
60
|
+
const kind = oneOf(what, 'screw', o.screw ?? 'steel', ['steel', 'stainless']), name = kind === 'steel' ? 'proof_stress' : 'stainless_proof_stress';
|
|
61
|
+
if (o.proof != null) positive(what, 'proof (the screw\'s proof stress, in MPa)', o.proof);
|
|
62
|
+
const k = fx.form === 'unified' ? 0.9743 : 0.9382, area = (Math.PI / 4) * (fx.major - k * fx.pitch) ** 2, stress = o.proof ?? figure(what, fx, name);
|
|
63
|
+
const cls = o.proof != null ? 'the proof stress given' : kind === 'steel' ? (fx.figures.property_class ? `class ${fx.figures.property_class.value}` : 'alloy steel') : String(fx.figures.stainless_class?.value ?? 'stainless');
|
|
64
|
+
return { area, stress, load: area * stress, says: cls, rests: [rest(cite(fx, 'major_diameter'), fx.figures.major_diameter), rest(cite(fx, 'pitch'), fx.figures.pitch), ...(o.proof != null ? [] : [rest(cite(fx, name), fx.figures[name])])] };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Whether enough thread is engaged, against the engagement rule for what the thread is in: 1 diameter in steel, 2 in
|
|
69
|
+
* aluminium, 2.5 in plastic (the engagement rule set of @rulecad/rules).
|
|
70
|
+
* @param {Fixing | string} m a fixing's model or name @param {{ depth: number, material: string | object, sets?: object }} o
|
|
71
|
+
* depth: the length of thread engaged, in mm; material: a class (plastic, aluminium, steel), a material of the kit
|
|
72
|
+
* (pla, petg, al6061, al7075, s275, ss304) or a material's rule set
|
|
73
|
+
* @returns {{ thread: string, depth: number, need: number, turns: number, diameters: number, class: string, material: string | null, enough: boolean, rests: object[], findings: object[] }}
|
|
74
|
+
* need: the depth that would do; turns: threads engaged; diameters: the depth in diameters of the screw
|
|
75
|
+
*/
|
|
76
|
+
export function engagement(m, o = {}) {
|
|
77
|
+
const what = 'engagement';
|
|
78
|
+
options(what, o, '{ depth: 6, material: \'pla\' }');
|
|
79
|
+
const fx = fixingOf(what, m, o), depth = positive(what, 'depth', o.depth), mat = classOf(what, o.material, o.sets), rule = ENGAGEMENT[mat.cls];
|
|
80
|
+
const need = r3(rule.value * fx.major), turns = n1(depth / fx.pitch), enough = depth >= need - 1e-9, into = mat.name ? `${mat.name} (a${mat.cls === 'aluminium' ? 'n' : ''} ${mat.cls})` : mat.cls;
|
|
81
|
+
return { thread: fx.thread, depth, need, turns, diameters: n2(depth / fx.major), class: mat.cls, material: mat.name, enough, rests: [rest(`engagement.${mat.cls}`, rule), rest(cite(fx, 'major_diameter'), fx.figures.major_diameter), rest(cite(fx, 'pitch'), fx.figures.pitch)],
|
|
82
|
+
findings: [finding(enough ? 'pass' : 'warn', `${a(fx.thread)} screw ${mm(depth)} mm into ${into} engages ${mm(turns)} threads, ${mm(n2(depth / fx.major))} diameters: engagement.${mat.cls} asks ${mm(rule.value)} (${mm(need)} mm)${enough ? '' : `, so ${mm(need)} mm would do`}`,
|
|
83
|
+
'engagement.depth', { values: { depth, need, turns }, refs: { thread: fx.thread, rule: `engagement.${mat.cls}`, kind: rule.kind } })] };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The load that strips an internal thread, from its shear area and the strength of what it is cut or formed in,
|
|
88
|
+
* against the screw's own proof load. The shear area is the handbook's for a 60° thread at its basic sizes,
|
|
89
|
+
* 0.875 π d Le; the shear strength is the material's strength over √3, an estimate.
|
|
90
|
+
* @param {Fixing | string} m @param {{ depth: number, material: string | object, screw?: 'steel' | 'stainless', proof?: number, load?: number, sets?: object }} o
|
|
91
|
+
* depth: the length of thread engaged; material: what the internal thread is in; screw: steel (its property class, the
|
|
92
|
+
* default) or stainless; proof: another screw's proof stress in MPa (830 for class 10.9); load: the load the joint
|
|
93
|
+
* carries along the screw, in N, to hold with twice the margin
|
|
94
|
+
* @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[] }}
|
|
95
|
+
* area: the internal thread's shear area, mm²; shear: the shear strength taken, MPa; strip: the load that strips the thread, N;
|
|
96
|
+
* 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
|
|
97
|
+
*/
|
|
98
|
+
export function stripping(m, o = {}) {
|
|
99
|
+
const what = 'stripping';
|
|
100
|
+
options(what, o, '{ depth: 6, material: \'pla\' }');
|
|
101
|
+
const fx = fixingOf(what, m, o), depth = positive(what, 'depth', o.depth), mat = materialOf(what, o.material, o.sets), screw = proofOf(what, fx, o);
|
|
102
|
+
if (o.load != null) positive(what, 'load (in N)', o.load);
|
|
103
|
+
const { f, note } = weakest(mat), ratio = DEFAULTS.shear_ratio, shear = ratio.value * f.value, area = 0.875 * Math.PI * fx.major * depth, strip = shear * area, margin = strip / screw.load, depthFor = depth / margin;
|
|
104
|
+
const out = [finding('info', `${a(fx.thread)} screw ${mm(depth)} mm into ${mat.name} strips its thread at about ${mm(n1(strip))} N: a shear area of ${mm(n2(area))} mm² (0.875 π d Le) at ${mm(n2(shear))} MPa, ${mm(f.value)} MPa over √3${note}. The shear strength is an estimate from the tensile strength, so halve it for a load that matters, or test it`,
|
|
105
|
+
'stripping.load', { values: { strip: n1(strip), area: n2(area), shear: n2(shear) }, refs: { thread: fx.thread, material: mat.name, kind: 'estimate' } })];
|
|
106
|
+
out.push(finding(margin >= 1 ? 'pass' : 'info', margin >= 1 ? `the thread outlasts the screw: its ${mm(n1(strip))} N is ${mm(n2(margin))} times the screw's proof load of ${mm(n1(screw.load))} N (${screw.says}, ${mm(n2(screw.area))} mm² at ${mm(screw.stress)} MPa)`
|
|
107
|
+
: `the thread strips before the screw yields: ${mm(n1(strip))} N is ${mm(n2(margin))} of the screw's proof load, ${mm(n1(screw.load))} N (${screw.says}, ${mm(n2(screw.area))} mm² at ${mm(screw.stress)} MPa). ${mm(n1(depthFor))} mm of thread would match the screw`,
|
|
108
|
+
'stripping.margin', { values: { strip: n1(strip), proof: n1(screw.load), margin: n2(margin), depthFor: n1(depthFor) } }));
|
|
109
|
+
if (o.load != null) { const k = strip / o.load, want = DEFAULTS.load_margin.value; out.push(finding(k >= want ? 'pass' : k >= 1 ? 'warn' : 'fail', `a load of ${mm(o.load)} N is held ${mm(n2(k))} times over by the thread, where the kit asks ${want} times${k >= want ? '' : `: ${mm(n1(depth * (want / k)))} mm of thread would do`}`, 'stripping.held', { values: { load: o.load, margin: n2(k), want } })); }
|
|
110
|
+
return { thread: fx.thread, depth, material: mat.name, area: n2(area), shear: n2(shear), strip: n1(strip), stressArea: n2(screw.area), proof: n1(screw.load), margin: n2(margin), depthFor: n1(depthFor), load: o.load ?? null,
|
|
111
|
+
rests: [rest(f.name, f), rest('fixings.shear_ratio', ratio), ...screw.rests], findings: out };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The clamp force a tightening torque gives, or the torque for a clamp force: T = K d F, with the nut factor K an
|
|
116
|
+
* estimate (0.2 unless given). Give torque or force.
|
|
117
|
+
* @param {Fixing | string} m @param {{ torque?: number, force?: number, K?: number, screw?: 'steel' | 'stainless', proof?: number, sets?: object }} o
|
|
118
|
+
* torque: in N·m; force: the clamp force (preload) wanted, in N; K: another nut factor (a lubricated thread's is lower)
|
|
119
|
+
* @returns {{ thread: string, torque: number, force: number, K: number, proof: number, share: number, full: { force: number, torque: number }, rests: object[], findings: object[] }}
|
|
120
|
+
* 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
|
|
121
|
+
*/
|
|
122
|
+
export function preload(m, o = {}) {
|
|
123
|
+
const what = 'preload';
|
|
124
|
+
options(what, o, '{ torque: 0.5 }');
|
|
125
|
+
const fx = fixingOf(what, m, o), rule = DEFAULTS.nut_factor, K = o.K ?? rule.value;
|
|
126
|
+
if ((o.torque == null) === (o.force == null)) throw new Error(`${what}: give torque (N·m), to get the clamp force, or force (N), to get the torque for it: one of the two (got ${shown({ torque: o.torque, force: o.force })})`);
|
|
127
|
+
if (!(isNum(K) && K > 0)) throw new Error(`${what}: K is the nut factor, a number above 0 (0.2 for plain steel threads) (got ${shown(o.K)})`);
|
|
128
|
+
const screw = proofOf(what, fx, o), d = fx.major, torque = o.torque != null ? positive(what, 'torque (in N·m)', o.torque) : (K * d * positive(what, 'force (in N)', o.force)) / 1000, force = o.force ?? (torque * 1000) / (K * d), share = force / screw.load;
|
|
129
|
+
const full = DEFAULTS.preload_share.value * screw.load, out = [finding('info', `${mm(r3(torque))} N·m on ${a(fx.thread)} screw gives a clamp force of about ${mm(n1(force))} N (T = K d F, K = ${mm(K)}${o.K == null ? ', an estimate: a torque wrench scatters the force by a quarter to a third' : ', as given'})`,
|
|
130
|
+
'preload.force', { values: { torque: r3(torque), force: n1(force), K }, refs: { thread: fx.thread, kind: o.K == null ? 'estimate' : 'given' } })];
|
|
131
|
+
out.push(finding(share <= 0.9 + 1e-9 ? 'pass' : share <= 1 + 1e-9 ? 'warn' : 'fail', `that is ${mm(n1(share * 100))}% of the screw's proof load, ${mm(n1(screw.load))} N (${screw.says})${share > 1 ? ': the screw yields first' : share > 0.9 ? ': past the 90% a permanent joint is taken to' : ''}. A screw tightened fully, to ${mm(DEFAULTS.preload_share.value * 100)}% of proof, carries ${mm(n1(full))} N at ${mm(r3((K * d * full) / 1000))} N·m`,
|
|
132
|
+
'preload.proof', { values: { share: r3(share), proof: n1(screw.load) } }));
|
|
133
|
+
return { thread: fx.thread, torque: r3(torque), force: n1(force), K, proof: n1(screw.load), share: r3(share), full: { force: n1(full), torque: r3((K * d * full) / 1000) },
|
|
134
|
+
rests: [...(o.K == null ? [rest('fixings.nut_factor', rule)] : []), rest('fixings.preload_share', DEFAULTS.preload_share), ...screw.rests], findings: out };
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The tightening torque for a clamp force: preload the other way round.
|
|
138
|
+
* @param {Fixing | string} m @param {{ force: number, K?: number, screw?: 'steel' | 'stainless', proof?: number, sets?: object }} o
|
|
139
|
+
* @returns {{ thread: string, torque: number, force: number, K: number, proof: number, share: number, full: { force: number, torque: number }, rests: object[], findings: object[] }}
|
|
140
|
+
*/
|
|
141
|
+
export function torqueFor(m, o = {}) {
|
|
142
|
+
options('torqueFor', o, '{ force: 500 }');
|
|
143
|
+
if (o.torque != null) throw new Error('torqueFor: give force (N), the clamp force wanted: for the force a torque gives, use preload');
|
|
144
|
+
return preload(m, o);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The pressure under a screw's head against what it sits on, and the washer that would bring it within. The head
|
|
149
|
+
* bears on the ring between its own diameter and the clearance hole as drawn; the limit is the material's strength.
|
|
150
|
+
* @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
|
|
151
|
+
* head: cap, button, hex, countersunk or pan (default the model's, else cap); material: what the head sits on;
|
|
152
|
+
* force: the clamp force in N, or torque: the tightening torque in N·m (default a screw tightened fully, to three
|
|
153
|
+
* quarters of its proof load); hole: clearance (the default), close or loose
|
|
154
|
+
* @returns {{ thread: string, head: string, material: string, force: number, area: number, pressure: number, limit: number, within: boolean,
|
|
155
|
+
* 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[] }}
|
|
156
|
+
* area: the bearing ring under the head, mm²; pressure and limit in MPa; washer: the same under the thread's plain washer;
|
|
157
|
+
* most: the greatest clamp force the seat takes and the torque for it, bare and on the washer
|
|
158
|
+
*/
|
|
159
|
+
export function seating(m, o = {}) {
|
|
160
|
+
const what = 'seating';
|
|
161
|
+
options(what, o, '{ head: \'cap\', material: \'pla\' }');
|
|
162
|
+
const fx = fixingOf(what, m, o), form = o.head ?? fx.head?.form ?? (fx.made.heads.includes('cap') ? 'cap' : fx.made.heads[0]);
|
|
163
|
+
if (form === 'set') throw new Error(`${what}: a set screw has no head to bear on anything: it presses with its point`);
|
|
164
|
+
const head = headOf(what, fx, form), mat = materialOf(what, o.material, o.sets), kind = oneOf(what, 'hole', o.hole ?? 'clearance', ['clearance', 'close', 'loose']), h = holeModel(fx, { kind, printer: o.printer });
|
|
165
|
+
if (o.force != null && o.torque != null) throw new Error(`${what}: give force (N) or torque (N·m), not both`);
|
|
166
|
+
const K = o.K ?? DEFAULTS.nut_factor.value, screw = proofOf(what, fx, o), given = o.force != null || o.torque != null;
|
|
167
|
+
if (!(isNum(K) && K > 0)) throw new Error(`${what}: K is the nut factor, a number above 0 (got ${shown(o.K)})`);
|
|
168
|
+
const force = o.force != null ? positive(what, 'force (in N)', o.force) : o.torque != null ? (positive(what, 'torque (in N·m)', o.torque) * 1000) / (K * fx.major) : DEFAULTS.preload_share.value * screw.load;
|
|
169
|
+
const across = head.flats ?? head.diameter, ring = (D) => (Math.PI / 4) * (D * D - h.diameter ** 2), area = ring(across), { f } = weakest(mat), limit = f.value, pressure = force / area, within = pressure <= limit + 1e-9;
|
|
170
|
+
if (!(area > 0)) throw new Error(`${what}: ${a(fx.thread)} ${form} head ${mm(across)} mm across has no seat round a ${mm(h.diameter)} mm hole`);
|
|
171
|
+
const torqueOf = (F) => r3((K * fx.major * F) / 1000), w = fx.made.washer ? { diameter: figure(what, fx, 'washer_diameter') } : null;
|
|
172
|
+
if (w) { w.area = n2(ring(w.diameter)); w.pressure = n1(force / ring(w.diameter)); w.within = force / ring(w.diameter) <= limit + 1e-9; }
|
|
173
|
+
const most = { force: n1(limit * area), torque: torqueOf(limit * area), washerForce: w ? n1(limit * ring(w.diameter)) : null, washerTorque: w ? torqueOf(limit * ring(w.diameter)) : null };
|
|
174
|
+
const load = given ? `${mm(n1(force))} N` : `${mm(n1(force))} N, a screw tightened fully (${mm(DEFAULTS.preload_share.value * 100)}% of its proof load)`;
|
|
175
|
+
const text = `${a(fx.thread)} ${form} head, ${mm(across)} mm across${head.flats ? ' its flats' : ''} on a ${mm(h.diameter)} mm hole, bears on ${mm(n2(area))} mm²: at ${load}, ${mm(n1(pressure))} MPa on ${mat.name}, whose strength is ${mm(limit)} MPa (${f.name}, taken as what it bears: an estimate)`;
|
|
176
|
+
const out = [within ? finding('pass', `${text}: within`, 'seating.pressure', { values: { pressure: n1(pressure), limit, force: n1(force), area: n2(area) } })
|
|
177
|
+
: w?.within ? finding('warn', `${text}: too much for the bare seat. The ${fx.thread} washer, ${mm(w.diameter)} mm across, brings it to ${mm(w.pressure)} MPa, within`, 'seating.pressure', { values: { pressure: n1(pressure), limit, force: n1(force), area: n2(area), washer: w.pressure } })
|
|
178
|
+
: finding('fail', `${text}: too much${w ? `, and the ${fx.thread} washer, ${mm(w.diameter)} mm across, only brings it to ${mm(w.pressure)} MPa` : ', and the thread has no washer in its rule set'}. The seat takes ${mm(most.force)} N bare (${mm(most.torque)} N·m)${w ? ` and ${mm(most.washerForce)} N on the washer (${mm(most.washerTorque)} N·m)` : ''}: tighten to that, or spread the load wider`,
|
|
179
|
+
'seating.pressure', { values: { pressure: n1(pressure), limit, force: n1(force), area: n2(area), ...(w ? { washer: w.pressure } : {}) } })];
|
|
180
|
+
return { thread: fx.thread, head: form, material: mat.name, force: n1(force), area: n2(area), pressure: n1(pressure), limit, within, washer: w, most,
|
|
181
|
+
rests: [...head.figures.map((k) => rest(cite(fx, k), fx.figures[k])), ...h.rests, rest(f.name, f), ...(w ? [rest(cite(fx, 'washer_diameter'), fx.figures.washer_diameter)] : []), ...(given ? [] : [rest('fixings.preload_share', DEFAULTS.preload_share), ...screw.rests]), ...(o.torque != null && o.K == null ? [rest('fixings.nut_factor', DEFAULTS.nut_factor)] : [])], findings: out };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** What a screw can end in, for lengthFor. */
|
|
185
|
+
export const ENDS = ['pilot', 'tap', 'thread', 'insert', 'nut'];
|
|
186
|
+
// The far end of a joint: how much thread the screw must engage there, and how much room it has before it bottoms out
|
|
187
|
+
function endOf(what, fx, into, o) {
|
|
188
|
+
const e = typeof into === 'string' ? { kind: into } : into;
|
|
189
|
+
if (!e || typeof e !== 'object' || Array.isArray(e)) throw new Error(`${what}: into is what the screw ends in: ${ENDS.map((k) => `'${k}'`).join(', ')}, or { kind, depth, material } (got ${shown(into)})`);
|
|
190
|
+
const kind = oneOf(what, 'into', e.kind, ENDS), through = e.through ?? false, rests = [];
|
|
191
|
+
if (typeof through !== 'boolean') throw new Error(`${what}: into.through is true or false (got ${shown(e.through)})`);
|
|
192
|
+
if (e.depth != null) positive(what, 'into.depth', e.depth); if (e.room != null) positive(what, 'into.room', e.room);
|
|
193
|
+
const use = (m, n) => { rests.push(rest(cite(m, n), m.figures[n])); return figure(what, m, n); };
|
|
194
|
+
if (kind === 'insert') {
|
|
195
|
+
const ins = fixingModel(`${fx.thread} ${e.length != null ? `x ${positive(what, 'into.length', e.length)} mm ` : ''}insert`, {}, { sets: o.sets }), long = use(ins, 'insert_length'), rule = DEFAULTS.insert_engagement;
|
|
196
|
+
rests.push(rest('fixings.insert_engagement', rule));
|
|
197
|
+
return { kind, says: `${a(fx.thread)} insert ${mm(long)} mm long`, need: r3(Math.min(rule.value * fx.major, long)), room: through ? Infinity : e.room ?? long, tip: 0, ends: 'bottom out', why: `the insert's ${mm(long)} mm: the hole's extra millimetre under it is left for the plastic the insert pushes ahead`, rests };
|
|
198
|
+
}
|
|
199
|
+
if (kind === 'nut') {
|
|
200
|
+
const nut = nutOf(what, fx, e.nut ?? 'hex'); rests.push(...nut.figures.map((n) => rest(cite(fx, n), fx.figures[n])));
|
|
201
|
+
return { kind, says: `${a(fx.thread)} ${nut.kind === 'hex' ? '' : `${nut.kind} `}nut ${mm(nut.height)} mm high`, need: nut.height, room: e.room ?? Infinity, tip: 0, ends: 'stand proud', why: 'the room given past the nut\'s seat', rests };
|
|
202
|
+
}
|
|
203
|
+
const tip = through ? 0 : DEFAULTS.tip_room.value; let need;
|
|
204
|
+
if (kind === 'pilot' && fx.figures.pilot_depth) need = use(fx, 'pilot_depth');
|
|
205
|
+
else { const cls = kind === 'pilot' ? 'plastic' : classOf(what, e.material ?? 'plastic', o.sets).cls; rests.push(rest(`engagement.${cls}`, ENGAGEMENT[cls])); need = r3(ENGAGEMENT[cls].value * fx.major); }
|
|
206
|
+
if (!through) rests.push(rest('fixings.tip_room', DEFAULTS.tip_room));
|
|
207
|
+
const says = kind === 'pilot' ? 'a pilot it forms its own thread in' : kind === 'tap' ? 'a tapped hole' : 'a printed thread';
|
|
208
|
+
return { kind, says: `${says}${e.depth != null ? ` ${mm(e.depth)} mm deep` : ''}`, need, room: through ? Infinity : e.depth ?? Infinity, tip, ends: 'bottom out', why: `the hole's ${mm(e.depth ?? 0)} mm less ${mm(tip)} mm at its tip`, rests };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The sold length of screw that passes through a stack of parts and engages enough at the far end, without bottoming
|
|
213
|
+
* out or standing proud: the shortest that does. Refused by name where no sold length fits, with the nearest.
|
|
214
|
+
* @param {number | number[]} stack the thicknesses the screw passes through under its head, in order, in mm (a countersunk
|
|
215
|
+
* screw's length includes its head, so its stack does too)
|
|
216
|
+
* @param {Fixing | string} m a thread or a screw ('M3', 'M3 button'): its head form is the model's, else cap
|
|
217
|
+
* @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
|
|
218
|
+
* into: what the screw ends in: 'pilot', 'tap', 'thread' (a printed one), 'insert' or 'nut', or the same with its
|
|
219
|
+
* depth (a blind hole's), room (how far the screw may go past where its thread starts), through (it may come out
|
|
220
|
+
* the far side), material (a tapped or printed thread's), nut (hex, square, lock) or length (another insert's);
|
|
221
|
+
* washer: a plain washer under the head; sunk: how far the head's seat lies under the first face (a counterbore's depth)
|
|
222
|
+
* @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,
|
|
223
|
+
* lengths: { length: number, name: string, engaged: number, fits: 'short' | 'fits' | 'long' }[], rests: object[], findings: object[] }}
|
|
224
|
+
* grip: what the screw passes before its thread engages; engaged: thread in the far end; room: how far it may go (null: no limit);
|
|
225
|
+
* 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
|
|
226
|
+
*/
|
|
227
|
+
export function lengthFor(stack, m, o = {}) {
|
|
228
|
+
const what = 'lengthFor';
|
|
229
|
+
options(what, o, '{ into: \'insert\' }');
|
|
230
|
+
const parts = Array.isArray(stack) ? stack : [stack];
|
|
231
|
+
if (!parts.length || !parts.every((t) => isNum(t) && t > 0)) throw new Error(`${what}: the stack is the thicknesses the screw passes through, each above 0 mm: 6 or [3, 6] (got ${shown(stack)})`);
|
|
232
|
+
const fx = fixingOf(what, m, { ...o, anyLength: true });
|
|
233
|
+
if (!['thread', 'screw'].includes(fx.item)) throw new Error(`${what}: ${fx.name} is ${a(fx.item)}, not a screw: give the thread or the screw ('${fx.thread}', '${fx.thread} button')`);
|
|
234
|
+
const form = o.head ?? fx.head?.form ?? (fx.made.heads.includes('cap') ? 'cap' : fx.made.heads[0]);
|
|
235
|
+
if (form === 'set') throw new Error(`${what}: a set screw clamps nothing between a head and a thread: its length is the hole's`);
|
|
236
|
+
headOf(what, fx, form);
|
|
237
|
+
if (o.into == null) throw new Error(`${what}: give into, what the screw ends in: ${ENDS.map((k) => `'${k}'`).join(', ')}, or { kind, depth, material }`);
|
|
238
|
+
const end = endOf(what, fx, o.into, o), rests = [...end.rests];
|
|
239
|
+
if (o.sunk != null && !(isNum(o.sunk) && o.sunk >= 0)) throw new Error(`${what}: sunk is how far the head's seat lies under the first face, 0 mm or more (got ${shown(o.sunk)})`);
|
|
240
|
+
if (o.washer != null && typeof o.washer !== 'boolean') throw new Error(`${what}: washer is true or false (got ${shown(o.washer)})`);
|
|
241
|
+
let washer = 0; if (o.washer) { if (!fx.made.washer) throw new Error(`${what}: ${fx.thread} has no washer in its rule set (${fx.set})`); washer = figure(what, fx, 'washer_thickness'); rests.push(rest(cite(fx, 'washer_thickness'), fx.figures.washer_thickness)); }
|
|
242
|
+
const total = parts.reduce((s, t) => s + t, 0), grip = r3(total + washer - (o.sunk ?? 0));
|
|
243
|
+
if (!(grip > 0)) throw new Error(`${what}: a seat sunk ${mm(o.sunk)} mm is deeper than the ${mm(total)} mm stack it is in: nothing is left under the head`);
|
|
244
|
+
const sold = fx.figures.lengths?.value;
|
|
245
|
+
if (!Array.isArray(sold) || !sold.every(isNum)) throw new Error(`${what}: ${fx.thread} lists no lengths in its rule set (${fx.set}), so none can be chosen: the length wanted is between ${mm(r3(grip + end.need))} mm${Number.isFinite(end.room) ? ` and ${mm(r3(grip + end.room - end.tip))} mm` : ' and as long as you like'}`);
|
|
246
|
+
rests.push(rest(cite(fx, 'lengths'), fx.figures.lengths));
|
|
247
|
+
const most = end.room - end.tip, verdict = (L) => (L - grip < end.need - 1e-9 ? 'short' : L - grip > most + 1e-9 ? 'long' : 'fits'), name = (L) => screwName(fx, L, form);
|
|
248
|
+
const lengths = sold.map((L) => ({ length: L, name: name(L), engaged: r3(Math.max(L - grip, 0)), fits: verdict(L) })), pick = lengths.find((l) => l.fits === 'fits'), below = lengths.filter((l) => l.fits === 'short').at(-1), above = lengths.find((l) => l.fits === 'long');
|
|
249
|
+
if (most < end.need - 1e-9) throw new Error(`${what}: ${end.says} leaves ${mm(r3(most))} mm of room for the screw (${end.why}) where ${mm(end.need)} mm of thread is asked: no length can do both. Deepen the far end to ${mm(r3(end.need + end.tip))} mm or more`);
|
|
250
|
+
const short = (l) => (l.length <= grip ? `${l.name} does not reach through the ${mm(grip)} mm stack` : `${l.name} would engage ${mm(l.engaged)} mm where ${mm(end.need)} mm is asked`), long = (l) => `${l.name} would ${end.ends}: ${mm(l.engaged)} mm into ${mm(r3(most))} mm of room (${end.why})`;
|
|
251
|
+
const job = `${mm(grip)} mm of stack into ${end.says}`;
|
|
252
|
+
if (!pick) {
|
|
253
|
+
const miss = (l) => r3(l === below ? grip + end.need - l.length : l.length - grip - most), nearest = !below ? above : !above ? below : miss(below) <= miss(above) ? below : above;
|
|
254
|
+
throw new Error(`${what}: no ${fx.thread} ${form} screw that is sold fits ${job}: ${[below && short(below), above && long(above)].filter(Boolean).join(', and ')}. The nearest is ${nearest.name}: change the stack or the far end by ${mm(miss(nearest))} mm, or use a length of ${mm(r3(grip + end.need))} mm${Number.isFinite(most) ? ` to ${mm(r3(grip + most))} mm` : ' or more'} from another list (fixingModel's { anyLength: true })`);
|
|
255
|
+
}
|
|
256
|
+
const out = [finding('pass', `${pick.name} fits ${job}: it engages ${mm(pick.engaged)} mm where ${mm(end.need)} mm is asked${Number.isFinite(most) ? `, with ${mm(r3(most - pick.engaged))} mm to spare before it would ${end.ends}` : ''}`, 'lengthFor.chosen', { values: { length: pick.length, grip, engaged: pick.engaged, need: end.need }, refs: { thread: fx.thread, screw: pick.name, into: end.kind } })];
|
|
257
|
+
if (above) out.push(finding('info', long(above), 'lengthFor.longer', { values: { length: above.length, engaged: above.engaged, room: r3(most) } }));
|
|
258
|
+
if (below) out.push(finding('info', short(below), 'lengthFor.shorter', { values: { length: below.length, engaged: below.engaged, need: end.need } }));
|
|
259
|
+
const blind = ['pilot', 'tap', 'thread'].includes(end.kind) && !Number.isFinite(end.room) && !(typeof o.into === 'object' && o.into.through), depth = blind ? r3(pick.engaged + DEFAULTS.tip_room.value) : null;
|
|
260
|
+
if (blind) out.push(finding('info', `draw its blind hole ${mm(depth)} mm deep or more: the ${mm(pick.engaged)} mm the screw goes in and ${mm(DEFAULTS.tip_room.value)} mm at its tip`, 'lengthFor.depth', { values: { depth } }));
|
|
261
|
+
return { name: pick.name, thread: fx.thread, head: form, length: pick.length, grip, engaged: pick.engaged, need: end.need, room: Number.isFinite(most) ? r3(most) : null, spare: Number.isFinite(most) ? r3(most - pick.engaged) : null, depth, into: end.kind, lengths, rests, findings: out };
|
|
262
|
+
}
|
package/threads.d.mts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{ kind: 'thread', thread: string, form: 'metric' | 'unified' | 'trapezoidal', internal: boolean, hand: 'right' | 'left', starts: number, pitch: number, lead: number, length: number,
|
|
3
|
+
* major: number, basic: { major: number, pitch: number, minor: number }, drawn: { major: number, minor: number }, depth: number, standardDepth: number, crest: number,
|
|
4
|
+
* flank: { up: number, down: number }, overhang: { standard: number, drawn: number, limit: number }, clearance: number, gap: number, comp: number, mate: 'printed' | 'bought', overlap: number, standardOverlap: number,
|
|
5
|
+
* leadIn: number, run: number, segments: number, triangles: number, display: 'thread' | 'plain', top: '+z' | '-z', axis: 'x' | 'y' | 'z', flat: number | null, engaged: number,
|
|
6
|
+
* outline: { lo: number, hi: number, flatLo: number, rise: number, flatHi: number, fall: number }, rests: object[], findings: object[] }} Thread
|
|
7
|
+
* thread: as it is written ('M10', 'Tr8x8(P2)'); lead: the travel in one turn, pitch times starts; major: the nominal diameter;
|
|
8
|
+
* basic: the standard's basic diameters of this member; drawn: its diameters as drawn (an internal thread's are its cutter's);
|
|
9
|
+
* depth: a tooth's height as drawn, and standardDepth the standard's; crest: the flat left on a tooth;
|
|
10
|
+
* flank: each flank's angle from the axis's normal, the one facing up and the one facing down as printed;
|
|
11
|
+
* overhang: what the down-facing flank overhangs from upright, by the standard and as drawn, and the printer's limit;
|
|
12
|
+
* clearance: the gap between this thread and its mate, on the radius; gap: this member's share of it; comp: the hole compensation across an internal thread;
|
|
13
|
+
* overlap: how far its flanks overlap its mate's, on the radius, and standardOverlap the standard's; leadIn: the lead-in's size on the radius, run: its length along the axis;
|
|
14
|
+
* triangles: the most the solid has; flat: on its side, how far from the axis its flat lies; engaged: the share of a turn left with thread
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* A thread to print, as numbers: its profile as drawn, the clearance to its mate, how its flanks print, and what each
|
|
18
|
+
* figure rests on. Refused by name where the printer cannot resolve the pitch (with the smallest thread that would
|
|
19
|
+
* print), and where it is asked for lying on its side without a flat.
|
|
20
|
+
* @param {Fixing | string | object} spec a fixing's name or model ('M10', '1/4-20'), a trapezoidal thread ('Tr8x2', 'Tr8x8(P2)',
|
|
21
|
+
* 'T8' for the catalogue's lead screw), a lead screw's or its nut's rule set, or { form, diameter, pitch, starts }
|
|
22
|
+
* @param {{ length: number, internal?: boolean, printer?: object, starts?: number, hand?: 'right' | 'left', pitch?: number, mate?: 'printed' | 'bought', gap?: number,
|
|
23
|
+
* flanks?: 'printed' | 'standard', leadIn?: number, segments?: number, display?: 'thread' | 'plain', top?: '+z' | '-z', axis?: 'x' | 'y' | 'z', flat?: boolean, variant?: string, sets?: object }} o
|
|
24
|
+
* length: of the thread, along its axis; internal: the thread of a nut or a threaded hole (the solid is then its cutter);
|
|
25
|
+
* starts: how many threads run side by side (default 1, or what the designation says); hand: right (the default) or left;
|
|
26
|
+
* pitch: another pitch on a fixing's diameter (a fine thread); mate: what it screws into, printed (each takes half the
|
|
27
|
+
* gap) or bought (this one takes all of it); gap: the gap on the radius, in place of the printer's thread_gap;
|
|
28
|
+
* flanks: printed (the down-facing flank laid back to the printer's overhang, the default) or standard (the standard's
|
|
29
|
+
* own form); leadIn: the size of the lead-in at each end, on the radius (default a tooth's height); segments: faces
|
|
30
|
+
* round, a multiple of 4 from 12 to 144 (default 48): it bounds the triangle count; display: thread, or plain for a
|
|
31
|
+
* plain cylinder; top: which end is up when it prints, +z (as drawn, the default) or -z; axis: z standing up (the
|
|
32
|
+
* default), x or y lying on its side, which needs flat: true (a flat to lie on, or a pointed roof in a hole)
|
|
33
|
+
* @returns {Thread}
|
|
34
|
+
*/
|
|
35
|
+
export function threadModel(spec: Fixing | string | object, o?: {
|
|
36
|
+
length: number;
|
|
37
|
+
internal?: boolean;
|
|
38
|
+
printer?: object;
|
|
39
|
+
starts?: number;
|
|
40
|
+
hand?: "right" | "left";
|
|
41
|
+
pitch?: number;
|
|
42
|
+
mate?: "printed" | "bought";
|
|
43
|
+
gap?: number;
|
|
44
|
+
flanks?: "printed" | "standard";
|
|
45
|
+
leadIn?: number;
|
|
46
|
+
segments?: number;
|
|
47
|
+
display?: "thread" | "plain";
|
|
48
|
+
top?: "+z" | "-z";
|
|
49
|
+
axis?: "x" | "y" | "z";
|
|
50
|
+
flat?: boolean;
|
|
51
|
+
variant?: string;
|
|
52
|
+
sets?: object;
|
|
53
|
+
}): Thread;
|
|
54
|
+
/**
|
|
55
|
+
* A thread's surface between two heights, for a solid that carries a thread as part of itself (a threaded screw, a
|
|
56
|
+
* threaded nut): its triangles and its two end rings, to be joined to the rest.
|
|
57
|
+
* @param {Thread} t @param {{ z0: number, z1: number, low?: string, high?: string, inside?: boolean, caps?: boolean | 'low' | 'high' }} o
|
|
58
|
+
* low, high: how each end is finished: chamfer or plain on a screw, flare on a nut; inside: faces turned inwards (a nut's bore);
|
|
59
|
+
* caps: close both ends (the default), one, or neither
|
|
60
|
+
* @returns {{ tris: number[][][], lo: number[][], hi: number[][] }}
|
|
61
|
+
*/
|
|
62
|
+
export function threadSurface(t: Thread, o: {
|
|
63
|
+
z0: number;
|
|
64
|
+
z1: number;
|
|
65
|
+
low?: string;
|
|
66
|
+
high?: string;
|
|
67
|
+
inside?: boolean;
|
|
68
|
+
caps?: boolean | "low" | "high";
|
|
69
|
+
}): {
|
|
70
|
+
tris: number[][][];
|
|
71
|
+
lo: number[][];
|
|
72
|
+
hi: number[][];
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* A thread to print: an external thread as a solid to add, standing on z from 0 to its length, or (internal: true)
|
|
76
|
+
* the cutter of an internal thread to subtract, which runs a little past both faces of a part as thick as the thread
|
|
77
|
+
* is long. Each end has its lead-in. With display: 'plain' it is a plain cylinder: a screw's at its crests, a hole's at
|
|
78
|
+
* its crests too (the bore you would see).
|
|
79
|
+
* @param {Fixing | string | object} spec as threadModel
|
|
80
|
+
* @param {{ length: number, internal?: boolean, printer?: object, starts?: number, hand?: 'right' | 'left', pitch?: number, mate?: 'printed' | 'bought', gap?: number,
|
|
81
|
+
* flanks?: 'printed' | 'standard', leadIn?: number, segments?: number, display?: 'thread' | 'plain', top?: '+z' | '-z', axis?: 'x' | 'y' | 'z', flat?: boolean, variant?: string, sets?: object }} o as threadModel
|
|
82
|
+
* @returns {object} a JSCAD geom3, with .model holding threadModel's numbers. Lying on its side (axis x or y) it runs
|
|
83
|
+
* along that axis from the origin, its flat facing down (a screw's) or its roof up (a hole's)
|
|
84
|
+
*/
|
|
85
|
+
export function thread(spec: Fixing | string | object, o?: {
|
|
86
|
+
length: number;
|
|
87
|
+
internal?: boolean;
|
|
88
|
+
printer?: object;
|
|
89
|
+
starts?: number;
|
|
90
|
+
hand?: "right" | "left";
|
|
91
|
+
pitch?: number;
|
|
92
|
+
mate?: "printed" | "bought";
|
|
93
|
+
gap?: number;
|
|
94
|
+
flanks?: "printed" | "standard";
|
|
95
|
+
leadIn?: number;
|
|
96
|
+
segments?: number;
|
|
97
|
+
display?: "thread" | "plain";
|
|
98
|
+
top?: "+z" | "-z";
|
|
99
|
+
axis?: "x" | "y" | "z";
|
|
100
|
+
flat?: boolean;
|
|
101
|
+
variant?: string;
|
|
102
|
+
sets?: object;
|
|
103
|
+
}): object;
|
|
104
|
+
/**
|
|
105
|
+
* A threaded hole, as numbers in a hole's shape: hole(m, { kind: 'thread' }) is this. The thread is modelled, so a
|
|
106
|
+
* printed part takes a screw with no tap, no insert and no nut.
|
|
107
|
+
* @param {string} what @param {Fixing} fx @param {object} o hole's options, and a thread's (mate, gap, flanks, hand, starts, segments, display, flat)
|
|
108
|
+
* @param {{ into: string, axis: 'x' | 'y' | 'z', across: boolean }} dir
|
|
109
|
+
* @returns {object} a Hole, with thread holding threadModel's numbers
|
|
110
|
+
*/
|
|
111
|
+
export function threadedHoleModel(what: string, fx: Fixing, o: object, dir: {
|
|
112
|
+
into: string;
|
|
113
|
+
axis: "x" | "y" | "z";
|
|
114
|
+
across: boolean;
|
|
115
|
+
}): object;
|
|
116
|
+
/** A threaded hole's cutter, from its model: drawn going down from the face, then turned to go along `into` from `at`. */
|
|
117
|
+
export function threadedHole(h: any, at: any): any;
|
|
118
|
+
/**
|
|
119
|
+
* A screw with its thread drawn, as one closed solid, in a screw's own place: the face its head seats on at z = 0, the
|
|
120
|
+
* thread down to z = -length. It prints standing on its head, so the model it is given is a thread with top: '-z'.
|
|
121
|
+
* @param {{ head: string, length: number, headDiameter: number, headHeight: number, flats?: number, sink?: number }} s a screw's numbers @param {Thread} t
|
|
122
|
+
* @returns {object} a JSCAD geom3
|
|
123
|
+
*/
|
|
124
|
+
export function threadedScrew(s: {
|
|
125
|
+
head: string;
|
|
126
|
+
length: number;
|
|
127
|
+
headDiameter: number;
|
|
128
|
+
headHeight: number;
|
|
129
|
+
flats?: number;
|
|
130
|
+
sink?: number;
|
|
131
|
+
}, t: Thread): object;
|
|
132
|
+
/**
|
|
133
|
+
* A nut with its thread drawn, as one closed solid in a nut's own place: on z from 0 to its height, a hexagon's
|
|
134
|
+
* corner on x. It prints as it stands.
|
|
135
|
+
* @param {{ kind: string, across: number, height: number }} nut a nut's numbers @param {Thread} t an internal thread as long as the nut is high
|
|
136
|
+
* @returns {object} a JSCAD geom3
|
|
137
|
+
*/
|
|
138
|
+
export function threadedNut(nut: {
|
|
139
|
+
kind: string;
|
|
140
|
+
across: number;
|
|
141
|
+
height: number;
|
|
142
|
+
}, t: Thread): object;
|
|
143
|
+
/** The forms of thread there are profiles for. */
|
|
144
|
+
export const THREAD_FORMS: string[];
|
|
145
|
+
/**
|
|
146
|
+
* thread: as it is written ('M10', 'Tr8x8(P2)'); lead: the travel in one turn, pitch times starts; major: the nominal diameter;
|
|
147
|
+
* basic: the standard's basic diameters of this member; drawn: its diameters as drawn (an internal thread's are its cutter's);
|
|
148
|
+
* depth: a tooth's height as drawn, and standardDepth the standard's; crest: the flat left on a tooth;
|
|
149
|
+
* flank: each flank's angle from the axis's normal, the one facing up and the one facing down as printed;
|
|
150
|
+
* overhang: what the down-facing flank overhangs from upright, by the standard and as drawn, and the printer's limit;
|
|
151
|
+
* clearance: the gap between this thread and its mate, on the radius; gap: this member's share of it; comp: the hole compensation across an internal thread;
|
|
152
|
+
* overlap: how far its flanks overlap its mate's, on the radius, and standardOverlap the standard's; leadIn: the lead-in's size on the radius, run: its length along the axis;
|
|
153
|
+
* triangles: the most the solid has; flat: on its side, how far from the axis its flat lies; engaged: the share of a turn left with thread
|
|
154
|
+
*/
|
|
155
|
+
export type Thread = {
|
|
156
|
+
kind: "thread";
|
|
157
|
+
thread: string;
|
|
158
|
+
form: "metric" | "unified" | "trapezoidal";
|
|
159
|
+
internal: boolean;
|
|
160
|
+
hand: "right" | "left";
|
|
161
|
+
starts: number;
|
|
162
|
+
pitch: number;
|
|
163
|
+
lead: number;
|
|
164
|
+
length: number;
|
|
165
|
+
major: number;
|
|
166
|
+
basic: {
|
|
167
|
+
major: number;
|
|
168
|
+
pitch: number;
|
|
169
|
+
minor: number;
|
|
170
|
+
};
|
|
171
|
+
drawn: {
|
|
172
|
+
major: number;
|
|
173
|
+
minor: number;
|
|
174
|
+
};
|
|
175
|
+
depth: number;
|
|
176
|
+
standardDepth: number;
|
|
177
|
+
crest: number;
|
|
178
|
+
flank: {
|
|
179
|
+
up: number;
|
|
180
|
+
down: number;
|
|
181
|
+
};
|
|
182
|
+
overhang: {
|
|
183
|
+
standard: number;
|
|
184
|
+
drawn: number;
|
|
185
|
+
limit: number;
|
|
186
|
+
};
|
|
187
|
+
clearance: number;
|
|
188
|
+
gap: number;
|
|
189
|
+
comp: number;
|
|
190
|
+
mate: "printed" | "bought";
|
|
191
|
+
overlap: number;
|
|
192
|
+
standardOverlap: number;
|
|
193
|
+
leadIn: number;
|
|
194
|
+
run: number;
|
|
195
|
+
segments: number;
|
|
196
|
+
triangles: number;
|
|
197
|
+
display: "thread" | "plain";
|
|
198
|
+
top: "+z" | "-z";
|
|
199
|
+
axis: "x" | "y" | "z";
|
|
200
|
+
flat: number | null;
|
|
201
|
+
engaged: number;
|
|
202
|
+
outline: {
|
|
203
|
+
lo: number;
|
|
204
|
+
hi: number;
|
|
205
|
+
flatLo: number;
|
|
206
|
+
rise: number;
|
|
207
|
+
flatHi: number;
|
|
208
|
+
fall: number;
|
|
209
|
+
};
|
|
210
|
+
rests: object[];
|
|
211
|
+
findings: object[];
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* a fixing's model, as fixingModel gives it
|
|
215
|
+
*/
|
|
216
|
+
export type Fixing = import("./model.mjs").Fixing;
|