@rulecad/fixings 0.1.1 → 0.1.4
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/CHANGELOG.md +32 -0
- package/README.md +12 -4
- package/fixings.d.mts +1 -1
- package/fixings.mjs +4 -3
- package/holes.d.mts +2 -1
- package/holes.mjs +5 -4
- package/model.mjs +1 -0
- package/package.json +2 -1
- package/seats.d.mts +6 -4
- package/seats.mjs +12 -9
- package/strength.d.mts +85 -0
- package/strength.mjs +93 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog: @rulecad/fixings
|
|
2
|
+
|
|
3
|
+
What changed in each release, for someone upgrading a workspace. A **printed size** is a dimension of a part you
|
|
4
|
+
print (a hole's diameter, a seat's depth, a part's outline). Each release says whether any printed size moved, and
|
|
5
|
+
why.
|
|
6
|
+
|
|
7
|
+
## 0.1.4: the kit reads its screws from fixings (Fixings 3)
|
|
8
|
+
|
|
9
|
+
### What reads fixings now
|
|
10
|
+
|
|
11
|
+
This package is now where every screw size in the kit comes from:
|
|
12
|
+
- `@rulecad/cad`: `v.fixings` in a design, and the `fasten` relation in an assembly, which follows a screw through the
|
|
13
|
+
parts, chooses its sold length and counts it in `cad list`.
|
|
14
|
+
- `@rulecad/motors`: a motor's mounting screws, their clearance holes and counterbores.
|
|
15
|
+
- `@rulecad/pcb`: a board's mounting holes, named by their thread (`mount('M2', x, y)`).
|
|
16
|
+
- `@rulecad/shapes` does not import this package (that would make a cycle, since this package draws with shapes'
|
|
17
|
+
seats). Its seats take the screw's figures from here as plain numbers.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- `screwGroup(places, o).turns` is `null` when the twist about a single screw rounds to 0 N m at the thousandth it is
|
|
22
|
+
given in. It used to be `0`, and cad then warned "a twist of 0 N m about the one screw is held by friction alone"
|
|
23
|
+
on a part held by one screw whose own weight sits a hair off the screw's axis. A test holds this.
|
|
24
|
+
|
|
25
|
+
### Printed sizes that moved
|
|
26
|
+
|
|
27
|
+
None. No hole, seat or piece of hardware this package draws changed size or shape.
|
|
28
|
+
|
|
29
|
+
### What a workspace should change
|
|
30
|
+
|
|
31
|
+
Nothing is required. Code that tested `screwGroup(...).turns > 0` keeps working; code that tested `turns !== null`
|
|
32
|
+
to mean "a twist" now skips a twist that rounds to nothing, which is the intent.
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ and stresses in MPa.
|
|
|
64
64
|
| [Seats](#seats) | `counterbore`, `countersink`, `nutPocket`, `nutTrap`, `squareNutSlot`, `captiveNut`, `insertBoss` |
|
|
65
65
|
| [Reference hardware](#reference-hardware) | `screw`, `nut`, `washer`, `insert` |
|
|
66
66
|
| [Threads cut for printing](#threads-cut-for-printing) | `thread`, `threadModel` |
|
|
67
|
-
| [Strength and length](#strength-and-length) | `engagement`, `stripping`, `preload`, `torqueFor`, `seating`, `lengthFor` |
|
|
67
|
+
| [Strength and length](#strength-and-length) | `engagement`, `stripping`, `preload`, `torqueFor`, `seating`, `lengthFor`, `screwGroup`, `screwLoad` |
|
|
68
68
|
| [Refusals and printability](#refusals-and-printability) | `printable` |
|
|
69
69
|
|
|
70
70
|
## Start here: a plate with four counterbored holes and an insert boss
|
|
@@ -214,7 +214,7 @@ insert hole are figures for the hole as drawn, already sized for printing, and t
|
|
|
214
214
|
|
|
215
215
|
**A pilot says what it rests on.** A pilot depends on the printer and the plastic as well as the screw. The printer's
|
|
216
216
|
own measured rule comes first: `pilot_m3` on the X1C's rule set, or `pilot_m3_petg` for one plastic when you pass
|
|
217
|
-
`material: 'PETG'`. Without one, the thread's starting figure is used (`m3.pilot`, a community figure, or an estimate
|
|
217
|
+
`material: 'PETG'`. An insert hole reads the printer's `insert_m3` the same way. Without one, the thread's starting figure is used (`m3.pilot`, a community figure, or an estimate
|
|
218
218
|
for the sizes nobody has published), and the finding says to measure it. A measurement made on one printer is never
|
|
219
219
|
borrowed for another.
|
|
220
220
|
|
|
@@ -271,7 +271,8 @@ Each has a twin with `Model` on its name (`counterboreModel`) that gives the num
|
|
|
271
271
|
form, since shapes' helper takes no angle. The seat is as wide as the head's theoretical sharp edge, so any head
|
|
272
272
|
made to the standard sits flush.
|
|
273
273
|
- **Nut pocket.** `fit` is `snug` by default (no clearance once printed, so the nut cannot turn), or `slip`, `press`,
|
|
274
|
-
or a clearance in mm.
|
|
274
|
+
or a clearance in mm. Where the printer has a measured `nut_fit`, snug is that clearance; a slot's and a closed
|
|
275
|
+
pocket's slip is the printer's `nut_slip` where it has one. A hexagon goes through shapes' `nutPocket`: open from above, with a 45° roof going up from
|
|
275
276
|
the bed, and with a flat on top across a part. A square pocket is drawn here, turned corner up across a part.
|
|
276
277
|
- **Nut slot.** `depth` is from the face to the screw's axis, and `at` is the point on the face level with the nut's
|
|
277
278
|
middle. From the side of a screw standing up (`axis: 'z'`), the slot goes through shapes' `wallOpening`: its roof
|
|
@@ -431,6 +432,8 @@ or a rule set with a `strength` and a `modulus`. Its class (plastic, aluminium o
|
|
|
431
432
|
| `preload(m, { torque })`, `preload(m, { force })`, `torqueFor(m, { force })` | The clamp force a tightening torque gives, and the torque for a force. `K` for another nut factor |
|
|
432
433
|
| `seating(m, { head, material, force })` | The pressure under the head, the plain washer that would bring it within, and the most the seat takes. `torque` in place of `force`; with neither, a screw tightened fully |
|
|
433
434
|
| `lengthFor(stack, m, { into })` | The shortest sold length that passes the stack and engages enough at the far end without bottoming out or standing proud |
|
|
435
|
+
| `screwGroup(places, { force, moment, at, pivot })` | A load on a joint shared between its screws: each one's shear across the joint and pull along it. `places` are the screws' `[x, y]` across the joint; `force` and `moment` are on the part they hold, `z` along the screws and positive pulling it off |
|
|
436
|
+
| `screwLoad(m, { tension, shear, depth, material, torque })` | One screw under its share: how many times that load it holds before the screw yields and the thread strips at its preload, and whether the parts slip. With no `torque`, the preload that leaves the thread twice the pull, within `most` (what the seat takes), and the torque for it |
|
|
434
437
|
|
|
435
438
|
The screw is class 8.8 steel as its rule set gives it. `screw: 'stainless'` takes the A2-70 figure, and
|
|
436
439
|
`proof: 830` any other class by its proof stress in MPa (830 is class 10.9). A fixing's name carries no property
|
|
@@ -545,7 +548,8 @@ hole: depth is a number above 0, in mm (got -2)
|
|
|
545
548
|
- **Standards** (`spec`): threads, clearance holes, heads, nuts, washers, lengths and proof stresses, each from its
|
|
546
549
|
standard as tabulated on the pages its rule names. The thread profiles are ISO 68-1's and ISO 2904's formulas.
|
|
547
550
|
- **Measured**: the X1C's M3 pilot (`x1c.pilot_m3`, 2.9 mm, from the kit's fit bar). It is the only measured figure
|
|
548
|
-
so far. The fixings coupon
|
|
551
|
+
so far. The fixings coupon (`examples/bench/projects/benchmarks/objects/fixings-coupon`) measures the rest, per
|
|
552
|
+
printer and plastic, and `cad measured` writes each result to the printer's rule set.
|
|
549
553
|
- **Community**: heat-set inserts (CNC Kitchen's sheet), pilots for M2 to M4 (Bambu Lab's figures for PLA) and for
|
|
550
554
|
the PT screws (the maker's factor for ABS), the engagement rules, the printer's `hole_comp`, `fit` and `bridge`,
|
|
551
555
|
the two layers a nut pocket is sunk, and the three quarters of proof load a fully tightened screw is taken to carry.
|
|
@@ -589,6 +593,9 @@ with its `rule`, `kind` and `source`.
|
|
|
589
593
|
| Clamp force from torque | T = K d F, with K = 0.2 | The short form of the torque relation, as at Wikipedia, Bolted joint. VDI 2230 splits K into thread friction, head friction and pitch: that fuller form is not applied here |
|
|
590
594
|
| A screw tightened fully | F = 0.75 × proof load | Wikipedia, Bolted joint |
|
|
591
595
|
| Pressure under a head | p = F / (π/4 (D² - dh²)), D the head (a hexagon's flats) or the washer, dh the hole as drawn | Geometry; the limit is the material's strength, an estimate |
|
|
596
|
+
| Shear on each screw of a group | S = F / n + M d / Σd², the second across the line from the centroid, the two added as vectors | The elastic method for eccentrically loaded bolt groups, as at steelcalculator.pages.dev (Bolt group capacity) |
|
|
597
|
+
| Pull on each screw of a group | P = Fz / n + b x + c y, with Σ P y = Mx and Σ P x = -My about the centroid; screws in a line tip about the clamped face's edge, P = M / (n × pivot) | An estimate of this package: the plane through the centroid holds while the parts stay pressed together. No source was read for it |
|
|
598
|
+
| A screw under its load | the screw: (Fp + k P)² + 3 (k S)² = proof load²; the thread: Fp + k P = strip load; the clamp: μ (Fp - k P) = k S; the margin is the least k of the first two | Von Mises on the stress area; the screw takes the whole pull and the clamp loses the whole pull, each the safe side for a part far softer than the screw. μ is `fixings.clamp_friction`, an estimate |
|
|
592
599
|
| A screw's length | grip = stack + washer - sunk; engaged = length - grip; fits where need ≤ engaged ≤ room | Geometry, with the rules for need and room in the table under `lengthFor` |
|
|
593
600
|
|
|
594
601
|
VDI 2230 and Machinery's Handbook are named because the plan asked for them. Neither was read at first hand for
|
|
@@ -631,6 +638,7 @@ Each figure's own source is in its rule (`m.figures.<name>.source`, and `DEFAULT
|
|
|
631
638
|
- [Thread shear area](https://engineersedge.com/calculators/thread_shear_area_15876.htm), Engineers Edge, and [Thread calcs](https://roymech.org/Useful_Tables/Screws/Thread_Calcs.html), Roymech: the thread shear areas of Machinery's Handbook and FED-STD-H28/2B.
|
|
632
639
|
- [Tensile stress area of bolt](https://help.solidworks.com/2014/English/SolidWorks/cworks/r_Tensile_Stress_Area_Bolt.htm), SolidWorks help, citing Machinery's Handbook.
|
|
633
640
|
- [Bolted joint](https://en.wikipedia.org/wiki/Bolted_joint), Wikipedia: torque and preload, the nut factor, and how tightening methods scatter.
|
|
641
|
+
- [Bolt group capacity](https://steelcalculator.pages.dev/reference/bolt-group-capacity/), the elastic method: direct and torsional shear in a group.
|
|
634
642
|
- [Von Mises yield criterion](https://en.wikipedia.org/wiki/Von_Mises_yield_criterion), Wikipedia: shear yield from tensile yield.
|
|
635
643
|
|
|
636
644
|
All were read on 2026-11-15. The plan for this package is [issue 212](https://github.com/JoniBach/rulecad/issues/212),
|
package/fixings.d.mts
CHANGED
|
@@ -32,4 +32,4 @@ export { holeModel, hole, HOLE_KINDS } from "./holes.mjs";
|
|
|
32
32
|
export { counterboreModel, counterbore, countersinkModel, countersink, nutPocketModel, nutPocket, nutTrapModel, nutTrap, squareNutSlotModel, squareNutSlot, captiveNutModel, captiveNut, insertBossModel, insertBoss, printable } from "./seats.mjs";
|
|
33
33
|
export { screwModel, screw, nutModel, nut, washerModel, washer, insertModel, insert } from "./hardware.mjs";
|
|
34
34
|
export { threadModel, thread, THREAD_FORMS } from "./threads.mjs";
|
|
35
|
-
export { engagement, stripping, preload, torqueFor, seating, lengthFor, MATERIALS, MATERIAL_CLASSES, ENDS } from "./strength.mjs";
|
|
35
|
+
export { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGroup, screwLoad, MATERIALS, MATERIAL_CLASSES, ENDS } from "./strength.mjs";
|
package/fixings.mjs
CHANGED
|
@@ -12,14 +12,14 @@ import { holeModel, hole } from './holes.mjs';
|
|
|
12
12
|
import { counterboreModel, counterbore, countersinkModel, countersink, nutPocketModel, nutPocket, nutTrapModel, nutTrap, squareNutSlotModel, squareNutSlot, captiveNutModel, captiveNut, insertBossModel, insertBoss, printable } from './seats.mjs';
|
|
13
13
|
import { screwModel, screw, nutModel, nut, washerModel, washer, insertModel, insert } from './hardware.mjs';
|
|
14
14
|
import { threadModel, thread } from './threads.mjs';
|
|
15
|
-
import { engagement, stripping, preload, torqueFor, seating, lengthFor } from './strength.mjs';
|
|
15
|
+
import { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGroup, screwLoad } from './strength.mjs';
|
|
16
16
|
|
|
17
17
|
export { fixingModel, parseName, threads, GRAMMAR, HEADS, NUTS, DEFAULTS } from './model.mjs';
|
|
18
18
|
export { holeModel, hole, HOLE_KINDS } from './holes.mjs';
|
|
19
19
|
export { counterboreModel, counterbore, countersinkModel, countersink, nutPocketModel, nutPocket, nutTrapModel, nutTrap, squareNutSlotModel, squareNutSlot, captiveNutModel, captiveNut, insertBossModel, insertBoss, printable } from './seats.mjs';
|
|
20
20
|
export { screwModel, screw, nutModel, nut, washerModel, washer, insertModel, insert } from './hardware.mjs';
|
|
21
21
|
export { threadModel, thread, THREAD_FORMS } from './threads.mjs';
|
|
22
|
-
export { engagement, stripping, preload, torqueFor, seating, lengthFor, MATERIALS, MATERIAL_CLASSES, ENDS } from './strength.mjs';
|
|
22
|
+
export { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGroup, screwLoad, MATERIALS, MATERIAL_CLASSES, ENDS } from './strength.mjs';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* What this release is. `release` is `'placeholder'` until the package has functions to call (0.1.0), then `'ready'`:
|
|
@@ -28,7 +28,7 @@ export { engagement, stripping, preload, torqueFor, seating, lengthFor, MATERIAL
|
|
|
28
28
|
*/
|
|
29
29
|
export const status = Object.freeze({ release: 'ready', plan: 'https://github.com/JoniBach/rulecad/issues/212' });
|
|
30
30
|
|
|
31
|
-
const MODELS = { engagement, stripping, preload, torqueFor, seating, threadModel, holeModel, counterboreModel, countersinkModel, nutPocketModel, nutTrapModel, squareNutSlotModel, captiveNutModel, insertBossModel, screwModel, nutModel, washerModel, insertModel };
|
|
31
|
+
const MODELS = { engagement, stripping, preload, torqueFor, seating, screwLoad, threadModel, holeModel, counterboreModel, countersinkModel, nutPocketModel, nutTrapModel, squareNutSlotModel, captiveNutModel, insertBossModel, screwModel, nutModel, washerModel, insertModel };
|
|
32
32
|
const SOLIDS = { thread, hole, counterbore, countersink, nutPocket, nutTrap, squareNutSlot, captiveNut, insertBoss, nut, washer, insert }, JOINED = { screw };
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -48,6 +48,7 @@ export function fixingsFor({ sets, printer, ops, display } = {}) {
|
|
|
48
48
|
const drawn = ['threadModel', 'thread', 'holeModel', 'hole'], as = (k, o) => (display && drawn.includes(k) && o && typeof o === 'object' && !Array.isArray(o) ? { display, ...o } : o);
|
|
49
49
|
for (const [k, f] of Object.entries({ ...MODELS, ...SOLIDS })) out[k] = (m, o = {}) => f(m, with_(as(k, o)));
|
|
50
50
|
out.lengthFor = (stack, m, o = {}) => lengthFor(stack, m, with_(o));
|
|
51
|
+
out.screwGroup = screwGroup;
|
|
51
52
|
for (const [k, f] of Object.entries(JOINED)) out[k] = (m, o = {}) => (ops ? f(m, with_(o), ops) : f(m, with_(o)));
|
|
52
53
|
return out;
|
|
53
54
|
}
|
package/holes.d.mts
CHANGED
|
@@ -38,7 +38,8 @@ export function inPart(what: string, o: {
|
|
|
38
38
|
* @param {{ kind?: string, depth?: number, through?: boolean, thickness?: number, printer?: object, material?: string, axis?: 'x' | 'y' | 'z', into?: string, lead?: number, sets?: object,
|
|
39
39
|
* mate?: 'printed' | 'bought', gap?: number, flanks?: 'printed' | 'standard', hand?: 'right' | 'left', starts?: number, pitch?: number, segments?: number, display?: 'thread' | 'plain', flat?: boolean }} [o]
|
|
40
40
|
* kind: clearance (the normal hole a screw passes through, the default), close, loose, pilot (the screw forms its own
|
|
41
|
-
* thread in the plastic), tap (the tap drill), insert (a heat-set insert
|
|
41
|
+
* thread in the plastic), tap (the tap drill), insert (a heat-set insert; a pilot and an insert read the
|
|
42
|
+
* printer's measured pilot_<set> or insert_<set>, as x1c.pilot_m3, before the thread's starting figure), or thread (a thread modelled to print, which
|
|
42
43
|
* also takes threadModel's mate, gap, flanks, hand, starts, pitch, segments, display and flat);
|
|
43
44
|
* depth: how deep, or the thickness passed through; through: out of the far face (the default for the clearances);
|
|
44
45
|
* thickness: the part's, along the hole: a hole through it is that deep, and a blind one deeper than it is refused;
|
package/holes.mjs
CHANGED
|
@@ -78,7 +78,8 @@ export const said = (into) => HOW[into];
|
|
|
78
78
|
* @param {{ kind?: string, depth?: number, through?: boolean, thickness?: number, printer?: object, material?: string, axis?: 'x' | 'y' | 'z', into?: string, lead?: number, sets?: object,
|
|
79
79
|
* mate?: 'printed' | 'bought', gap?: number, flanks?: 'printed' | 'standard', hand?: 'right' | 'left', starts?: number, pitch?: number, segments?: number, display?: 'thread' | 'plain', flat?: boolean }} [o]
|
|
80
80
|
* kind: clearance (the normal hole a screw passes through, the default), close, loose, pilot (the screw forms its own
|
|
81
|
-
* thread in the plastic), tap (the tap drill), insert (a heat-set insert
|
|
81
|
+
* thread in the plastic), tap (the tap drill), insert (a heat-set insert; a pilot and an insert read the
|
|
82
|
+
* printer's measured pilot_<set> or insert_<set>, as x1c.pilot_m3, before the thread's starting figure), or thread (a thread modelled to print, which
|
|
82
83
|
* also takes threadModel's mate, gap, flanks, hand, starts, pitch, segments, display and flat);
|
|
83
84
|
* depth: how deep, or the thickness passed through; through: out of the far face (the default for the clearances);
|
|
84
85
|
* thickness: the part's, along the hole: a hole through it is that deep, and a blind one deeper than it is refused;
|
|
@@ -93,10 +94,10 @@ export function holeModel(m, o = {}) {
|
|
|
93
94
|
const fx = fixingOf(what, m, o), kind = oneOf(what, 'kind', o.kind ?? 'clearance', HOLE_KINDS);
|
|
94
95
|
if (kind === 'thread') return threadedHoleModel(what, fx, o, directionOf(what, o));
|
|
95
96
|
const spec = HOLES[kind], pr = printerOf(what, o.printer), dir = directionOf(what, o), out = [], rests = [];
|
|
96
|
-
// The figure the diameter rests on: for a pilot, the printer's measured rule for this thread (and plastic) before the thread's starting figure
|
|
97
|
+
// The figure the diameter rests on: for a pilot or an insert, the printer's measured rule for this thread (and plastic) before the thread's starting figure
|
|
97
98
|
let basis = null;
|
|
98
99
|
const plastic = o.material == null ? null : String(o.material).toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
99
|
-
if (kind === 'pilot') basis = [plastic &&
|
|
100
|
+
if (kind === 'pilot' || kind === 'insert') basis = [plastic && `${kind}_${fx.set}_${plastic}`, `${kind}_${fx.set}`].filter(Boolean).map((k) => pr.figure(k)).find(Boolean) ?? null;
|
|
100
101
|
const own = !!basis;
|
|
101
102
|
if (!basis) {
|
|
102
103
|
if (!fx.figures[spec.figure]) throw new Error(`${what}: ${fx.thread} has no ${spec.figure} in its rule set (${fx.set}), so no ${kind} hole: it has figures for ${Object.keys(HOLES).filter((k) => fx.figures[HOLES[k].figure]).join(', ') || 'none'}`);
|
|
@@ -109,7 +110,7 @@ export function holeModel(m, o = {}) {
|
|
|
109
110
|
const trust = { measured: 'a measured rule', spec: 'a standard\'s figure', community: 'a community figure', estimate: 'an estimate', given: 'a figure given by hand', default: 'a default', derived: 'a derived figure' }[basis.kind] ?? `a ${basis.kind} figure`;
|
|
110
111
|
let text = `${a(fx.thread)} ${spec.says} drawn ${mm(diameter)} mm: it rests on ${basis.name} (${mm(nominal)} mm), ${trust}`;
|
|
111
112
|
text += spec.printed ? `, plus ${pr.cite('hole_comp')} ${mm(comp)} mm across, since a printed hole comes out small` : ', as drawn (the figure is already sized for printing, so no hole compensation is added)';
|
|
112
|
-
if (kind === 'pilot' && !own) text += `. That is the thread's starting figure: ${pr.name} has no measured
|
|
113
|
+
if ((kind === 'pilot' || kind === 'insert') && !own) text += `. That is the thread's starting figure: ${pr.name} has no measured ${kind}_${fx.set}, so measure it on this printer`;
|
|
113
114
|
out.push(finding('info', text, 'hole.drawn', { values: { diameter, nominal, comp }, refs: { thread: fx.thread, set: fx.set, rule: basis.name, kind: basis.kind } }));
|
|
114
115
|
if (comp && pr.rest('hole_comp').borrowed) out.push(finding('info', `${pr.name} has no hole_comp: the X1C's ${mm(comp)} mm is used`, 'hole.printer', { values: { comp } }));
|
|
115
116
|
// a figure that names one plastic, asked for another
|
package/model.mjs
CHANGED
|
@@ -53,6 +53,7 @@ export const DEFAULTS = {
|
|
|
53
53
|
insert_engagement: { value: 1, unit: '× diameter', rule: 'A screw engages a brass heat-set insert by at least its own diameter, or the whole insert where that is shorter: an estimate, the figure the engagement rules give for steel', kind: 'estimate', source: 'A working figure of this package, after engagement.steel in @rulecad/rules; no insert maker\'s figure was found', checked: '2026-11-15' },
|
|
54
54
|
tip_room: { value: 1, unit: 'mm', rule: 'A screw\'s tip stops at least this far short of the bottom of a blind hole, so it tightens on its head and not on its tip: an estimate, the millimetre an insert\'s blind hole is given past the insert', kind: 'estimate', source: 'A working figure of this package, after insert_depth in the thread rule sets (the insert\'s length and 1 mm)', checked: '2026-11-15' },
|
|
55
55
|
load_margin: { value: 2, unit: '× load', rule: 'A printed joint is sized to hold about twice the load it is given', kind: 'default', source: 'The kit\'s standard for printed parts: sized from the load with about twice the margin', checked: '2026-11-15' },
|
|
56
|
+
clamp_friction: { value: 0.3, unit: '× clamp force', rule: 'The friction between two printed parts clamped by screws, for whether a joint slips before its screws bear on their holes: an estimate. No measured figure for PLA on PLA at rest was found; the figures found are for printed PLA sliding on steel, about 0.38 to 0.57, and 0.3 is taken under them', kind: 'estimate', source: 'Sliding friction of printed PLA on steel: Pawlak, kinetic 0.49 (https://yadda.icm.edu.pl/baztech/element/bwmeta1.element.baztech-f7c60c77-2f7e-4c4f-8d4e-f962d0c503e7/c/pawlak.pdf), and Sirin et al., Rapid Prototyping Journal 2023, 0.38 to 0.57 pin on disc (https://www.emerald.com/insight/content/doi/10.1108/RPJ-03-2022-0081/full/html); to be measured on the fixings coupon', checked: '2026-11-15' },
|
|
56
57
|
brass_density: { value: 8.47, unit: 'g/cm³', rule: 'Density of free-machining brass CW614N (CuZn39Pb3), taken for a heat-set insert. The insert maker\'s sheet names no alloy, so the alloy is assumed', kind: 'estimate', source: 'Aalco, CW614N brass rod datasheet, https://www.aalco.co.uk/datasheets/Copper-and-Copper-Alloys-CW614N-Brass-Rod_31.ashx', checked: '2026-11-15' }
|
|
57
58
|
};
|
|
58
59
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/fixings",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Screws, nuts, washers and inserts from rule sets, and the holes and seats they need in printed parts: a fixing as a model with sourced figures, holes sized by what they are for, counterbores, countersinks, nut pockets and insert bosses that print without supports, light solids of the hardware for an assembly, threads cut for printing, and first sums for a joint (engagement, stripping, preload, seating, the sold length that fits).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"strength.d.mts",
|
|
29
29
|
"draw.d.mts",
|
|
30
30
|
"README.md",
|
|
31
|
+
"CHANGELOG.md",
|
|
31
32
|
"LICENSE"
|
|
32
33
|
],
|
|
33
34
|
"license": "MIT",
|
package/seats.d.mts
CHANGED
|
@@ -103,7 +103,7 @@ export function countersink(m: Fixing | string, o?: {
|
|
|
103
103
|
* @param {Fixing | string} m
|
|
104
104
|
* @param {{ kind?: string, depth?: number, thickness?: number, fit?: string | number, hole?: string, printer?: object, into?: string, axis?: string, sets?: object }} [o]
|
|
105
105
|
* kind: hex, square or lock (default the model's, else hex); depth: of the pocket (default the nut's height and two
|
|
106
|
-
* 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
|
|
106
|
+
* layers); thickness: the part's there (a pocket deeper than the part is refused); fit: snug (the default: the printer's measured nut_fit where it has one, else no clearance once printed, so the nut cannot turn), slip, press, or a clearance in mm
|
|
107
107
|
* @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[] }}
|
|
108
108
|
* 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
|
|
109
109
|
*/
|
|
@@ -156,9 +156,9 @@ export function nutPocket(m: Fixing | string, o?: {
|
|
|
156
156
|
* @param {{ kind?: string, axis?: 'x' | 'y' | 'z', into?: string, depth: number, fit?: string | number, hole?: string, printer?: object, sets?: object }} o
|
|
157
157
|
* axis: the screw's (default z, standing up); into: the way the nut slides in, square to the axis (default +x for a
|
|
158
158
|
* screw standing up, -z, dropped in from the top, for one lying down); depth: from the face to the screw's axis;
|
|
159
|
-
* fit: slip (the default: the nut slides in by hand), snug, press, or a clearance in mm
|
|
160
|
-
* @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[] }}
|
|
161
|
-
* width: across the nut's flats, as drawn; gap: along the screw, for the nut's height; reach: how far the slot goes
|
|
159
|
+
* fit: slip (the default: the nut slides in by hand; the printer's measured nut_slip where it has one, else its slip), snug, press, or a clearance in mm
|
|
160
|
+
* @returns {{ thread: string, kind: string, width: number, gap: number, depth: number, reach: number, hole: number, clearance: number, axis: string, into: string, span: number, rise: number, rests: object[], findings: object[] }}
|
|
161
|
+
* width: across the nut's flats, as drawn; clearance: the fit's, across the flats; gap: along the screw, for the nut's height; reach: how far the slot goes
|
|
162
162
|
* 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
|
|
163
163
|
*/
|
|
164
164
|
export function nutTrapModel(m: Fixing | string, o?: {
|
|
@@ -178,6 +178,7 @@ export function nutTrapModel(m: Fixing | string, o?: {
|
|
|
178
178
|
depth: number;
|
|
179
179
|
reach: number;
|
|
180
180
|
hole: number;
|
|
181
|
+
clearance: number;
|
|
181
182
|
axis: string;
|
|
182
183
|
into: string;
|
|
183
184
|
span: number;
|
|
@@ -213,6 +214,7 @@ export function squareNutSlotModel(m: any, o?: {}): {
|
|
|
213
214
|
depth: number;
|
|
214
215
|
reach: number;
|
|
215
216
|
hole: number;
|
|
217
|
+
clearance: number;
|
|
216
218
|
axis: string;
|
|
217
219
|
into: string;
|
|
218
220
|
span: number;
|
package/seats.mjs
CHANGED
|
@@ -22,10 +22,13 @@ function through(what, fx, o) {
|
|
|
22
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
23
|
return holeModel(fx, { kind, printer: o.printer });
|
|
24
24
|
}
|
|
25
|
-
// A fit by name, from the printer's rules, or a clearance in mm as printed
|
|
26
|
-
|
|
25
|
+
// A fit by name, from the printer's rules, or a clearance in mm as printed. For a nut (nut: true), snug and slip read
|
|
26
|
+
// the printer's measured nut_fit and nut_slip first, where it has them (the fixings coupon measures both)
|
|
27
|
+
function fitOf(what, fit, pr, nut = false) {
|
|
27
28
|
if (isNum(fit)) return { name: fit, clearance: fit, rests: [] };
|
|
28
29
|
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)})`);
|
|
30
|
+
const own = nut && fit !== 'press' ? pr.figure(fit === 'snug' ? 'nut_fit' : 'nut_slip') : null;
|
|
31
|
+
if (own) { if (!isNum(own.value)) throw new Error(`${what}: ${own.name} is a clearance in mm (got ${shown(own.value)})`); return { name: own.name.slice(own.name.lastIndexOf('.') + 1), clearance: own.value, rests: [rest(own.name, own)] }; }
|
|
29
32
|
return fit === 'snug' ? { name: fit, clearance: 0, rests: [] } : { name: fit, clearance: fit === 'slip' ? pr.n('slip') : -pr.n('press'), rests: [pr.rest(fit)] };
|
|
30
33
|
}
|
|
31
34
|
const figures = (fx, names) => names.map((n) => rest(cite(fx, n), fx.figures[n]));
|
|
@@ -129,7 +132,7 @@ export function countersink(m, o = {}) {
|
|
|
129
132
|
// What every nut seat starts from: the nut, the fit, the drawn size across its flats and the screw's hole
|
|
130
133
|
function nutSeat(what, m, o, fit) {
|
|
131
134
|
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);
|
|
135
|
+
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, true), comp = pr.n('hole_comp'), h = through(what, fx, o);
|
|
133
136
|
const flats = r3(nut.flats + comp + f.clearance), corner = r3(nut.kind === 'square' ? flats * Math.SQRT2 : flats / COS30);
|
|
134
137
|
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
138
|
return { fx, pr, nut, f, comp, h, flats, corner, how, rests: [...figures(fx, nut.figures), pr.rest('hole_comp'), ...f.rests, ...h.rests] };
|
|
@@ -151,7 +154,7 @@ function pocket(s, flats, depth, hole, at, into) {
|
|
|
151
154
|
* @param {Fixing | string} m
|
|
152
155
|
* @param {{ kind?: string, depth?: number, thickness?: number, fit?: string | number, hole?: string, printer?: object, into?: string, axis?: string, sets?: object }} [o]
|
|
153
156
|
* 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
|
|
157
|
+
* layers); thickness: the part's there (a pocket deeper than the part is refused); fit: snug (the default: the printer's measured nut_fit where it has one, else no clearance once printed, so the nut cannot turn), slip, press, or a clearance in mm
|
|
155
158
|
* @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
159
|
* 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
160
|
*/
|
|
@@ -187,9 +190,9 @@ export function nutPocket(m, o = {}) {
|
|
|
187
190
|
* @param {{ kind?: string, axis?: 'x' | 'y' | 'z', into?: string, depth: number, fit?: string | number, hole?: string, printer?: object, sets?: object }} o
|
|
188
191
|
* axis: the screw's (default z, standing up); into: the way the nut slides in, square to the axis (default +x for a
|
|
189
192
|
* 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
|
+
* fit: slip (the default: the nut slides in by hand; the printer's measured nut_slip where it has one, else its slip), snug, press, or a clearance in mm
|
|
194
|
+
* @returns {{ thread: string, kind: string, width: number, gap: number, depth: number, reach: number, hole: number, clearance: number, axis: string, into: string, span: number, rise: number, rests: object[], findings: object[] }}
|
|
195
|
+
* width: across the nut's flats, as drawn; clearance: the fit's, across the flats; gap: along the screw, for the nut's height; reach: how far the slot goes
|
|
193
196
|
* 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
197
|
*/
|
|
195
198
|
export function nutTrapModel(m, o = {}) {
|
|
@@ -204,7 +207,7 @@ export function nutTrapModel(m, o = {}) {
|
|
|
204
207
|
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
208
|
: `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
209
|
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 };
|
|
210
|
+
return { thread: fx.thread, kind: nut.kind, width: s.flats, gap, depth, reach, hole: h.diameter, clearance: s.f.clearance, axis, into, span, rise, rests: [...s.rests, pr.rest('layer'), pr.rest('bridge')], findings: out };
|
|
208
211
|
}
|
|
209
212
|
|
|
210
213
|
/**
|
|
@@ -296,7 +299,7 @@ export function insertBossModel(m, o = {}) {
|
|
|
296
299
|
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
300
|
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
301
|
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`}: ${
|
|
302
|
+
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`}: ${h.basis.rule}, as drawn (no hole compensation), with ${mm(wall)} mm of wall where ${cite(fx, 'insert_wall')} asks ${mm(least)} mm`,
|
|
300
303
|
'insertBoss.drawn', { values: { hole: h.diameter, depth, outer, wall, least, height }, refs: { thread: fx.thread, set: fx.set } }));
|
|
301
304
|
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
305
|
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' } }));
|
package/strength.d.mts
CHANGED
|
@@ -209,6 +209,91 @@ export function lengthFor(stack: number | number[], m: Fixing | string, o?: {
|
|
|
209
209
|
rests: object[];
|
|
210
210
|
findings: object[];
|
|
211
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* A load shared between a group of screws that stand side by side, by the elastic method about the group's centroid:
|
|
214
|
+
* the force across the joint shared equally, a twist about the screws' axis shared in proportion to each screw's
|
|
215
|
+
* distance from the centroid, the pull along the screws shared equally, and a moment that tips the joint by tension
|
|
216
|
+
* growing with the distance from the centroid. Screws in one line (or one alone) cannot share a moment about that line
|
|
217
|
+
* by tension: the part tips about the edge of the face it is clamped by, `pivot` from the line, and the screws hold it.
|
|
218
|
+
* @param {number[][]} places each screw's place across the joint, [x, y] in mm; the screws stand along z
|
|
219
|
+
* @param {{ force?: number[], moment?: number[], at?: number[], pivot?: number }} [o]
|
|
220
|
+
* force: [x, y, z] in N on the part the screws hold, z along the screws, positive pulling it off the joint;
|
|
221
|
+
* moment: [x, y, z] in N·m on that part, about `at`; at: where the force acts, [x, y] or [x, y, z] in mm, z the
|
|
222
|
+
* height off the joint's face (default the centroid); pivot: for screws in a line, how far the clamped face
|
|
223
|
+
* reaches past the line, in mm
|
|
224
|
+
* @returns {{ count: number, centroid: number[], polar: number, line: boolean, screws: { at: number[], shear: number, tension: number, across: number[] }[], turns: number | null, rests: object[] }}
|
|
225
|
+
* polar: the sum of the squared distances from the centroid, mm²; screws: each one's shear (N, across the joint) and
|
|
226
|
+
* tension (N, along it: under 0, the load presses that screw's parts together); turns: a twist one screw alone
|
|
227
|
+
* cannot hold by shear, in N·m (it holds by friction only), null when it rounds to 0 at the thousandth
|
|
228
|
+
*/
|
|
229
|
+
export function screwGroup(places: number[][], o?: {
|
|
230
|
+
force?: number[];
|
|
231
|
+
moment?: number[];
|
|
232
|
+
at?: number[];
|
|
233
|
+
pivot?: number;
|
|
234
|
+
}): {
|
|
235
|
+
count: number;
|
|
236
|
+
centroid: number[];
|
|
237
|
+
polar: number;
|
|
238
|
+
line: boolean;
|
|
239
|
+
screws: {
|
|
240
|
+
at: number[];
|
|
241
|
+
shear: number;
|
|
242
|
+
tension: number;
|
|
243
|
+
across: number[];
|
|
244
|
+
}[];
|
|
245
|
+
turns: number | null;
|
|
246
|
+
rests: object[];
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* One screw of a joint under its share of a load: how many times that load it holds before the screw yields, the
|
|
250
|
+
* internal thread strips, and the clamped parts slip, at its preload. The screw takes its preload and the whole pull
|
|
251
|
+
* on it (a printed part is far softer than a steel screw, so little of the pull goes into easing the clamp), with
|
|
252
|
+
* its shear, against its proof load; the thread takes the same pull and preload against its stripping load; the clamp
|
|
253
|
+
* is eased by the whole pull for slipping, the safe side each time. With no torque given, the preload is the most that
|
|
254
|
+
* leaves the thread twice the pull, within the seat and three quarters of the proof load, and the torque for it is said.
|
|
255
|
+
* @param {Fixing | string} m @param {{ tension?: number, shear?: number, depth?: number, material?: string | object, end?: string, torque?: number, most?: number, K?: number, friction?: number, screw?: 'steel' | 'stainless', proof?: number, sets?: object }} o
|
|
256
|
+
* tension, shear: the screw's share, in N; depth and material: the thread engaged and what it is in (a pilot, tap or
|
|
257
|
+
* printed thread), or end: 'insert' or 'nut' where the thread is metal; torque: the tightening torque given, N·m;
|
|
258
|
+
* most: the most clamp force the seat under the head takes, N; friction: between the clamped parts (default fixings.clamp_friction)
|
|
259
|
+
* @returns {{ thread: string, tension: number, shear: number, preload: { force: number, torque: number, given: boolean }, proof: number, strip: number | null,
|
|
260
|
+
* margins: { screw: number, thread: number | null, slip: number | null }, margin: number, governs: string, rests: object[], findings: object[] }}
|
|
261
|
+
* margins: how many times the load each holds (null: not checked); margin: the least of the screw's and the thread's
|
|
262
|
+
*/
|
|
263
|
+
export function screwLoad(m: Fixing | string, o?: {
|
|
264
|
+
tension?: number;
|
|
265
|
+
shear?: number;
|
|
266
|
+
depth?: number;
|
|
267
|
+
material?: string | object;
|
|
268
|
+
end?: string;
|
|
269
|
+
torque?: number;
|
|
270
|
+
most?: number;
|
|
271
|
+
K?: number;
|
|
272
|
+
friction?: number;
|
|
273
|
+
screw?: "steel" | "stainless";
|
|
274
|
+
proof?: number;
|
|
275
|
+
sets?: object;
|
|
276
|
+
}): {
|
|
277
|
+
thread: string;
|
|
278
|
+
tension: number;
|
|
279
|
+
shear: number;
|
|
280
|
+
preload: {
|
|
281
|
+
force: number;
|
|
282
|
+
torque: number;
|
|
283
|
+
given: boolean;
|
|
284
|
+
};
|
|
285
|
+
proof: number;
|
|
286
|
+
strip: number | null;
|
|
287
|
+
margins: {
|
|
288
|
+
screw: number;
|
|
289
|
+
thread: number | null;
|
|
290
|
+
slip: number | null;
|
|
291
|
+
};
|
|
292
|
+
margin: number;
|
|
293
|
+
governs: string;
|
|
294
|
+
rests: object[];
|
|
295
|
+
findings: object[];
|
|
296
|
+
};
|
|
212
297
|
/** The materials there are rule sets for in the kit, by name. */
|
|
213
298
|
export const MATERIALS: string[];
|
|
214
299
|
/** The classes of material the engagement rules know. */
|
package/strength.mjs
CHANGED
|
@@ -260,3 +260,96 @@ export function lengthFor(stack, m, o = {}) {
|
|
|
260
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
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
262
|
}
|
|
263
|
+
|
|
264
|
+
// ---------- screws as a group, under a load ----------
|
|
265
|
+
const xyz = (what, k, v, n) => { if (!(Array.isArray(v) && v.length >= 2 && v.length <= n && v.every(isNum))) throw new Error(`${what}: ${k} is ${n === 3 ? '[x, y, z]' : '[x, y]'} in numbers (got ${shown(v)})`); return [v[0], v[1], v[2] ?? 0]; };
|
|
266
|
+
const crossed = (p, q) => [p[1] * q[2] - p[2] * q[1], p[2] * q[0] - p[0] * q[2], p[0] * q[1] - p[1] * q[0]];
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* A load shared between a group of screws that stand side by side, by the elastic method about the group's centroid:
|
|
270
|
+
* the force across the joint shared equally, a twist about the screws' axis shared in proportion to each screw's
|
|
271
|
+
* distance from the centroid, the pull along the screws shared equally, and a moment that tips the joint by tension
|
|
272
|
+
* growing with the distance from the centroid. Screws in one line (or one alone) cannot share a moment about that line
|
|
273
|
+
* by tension: the part tips about the edge of the face it is clamped by, `pivot` from the line, and the screws hold it.
|
|
274
|
+
* @param {number[][]} places each screw's place across the joint, [x, y] in mm; the screws stand along z
|
|
275
|
+
* @param {{ force?: number[], moment?: number[], at?: number[], pivot?: number }} [o]
|
|
276
|
+
* force: [x, y, z] in N on the part the screws hold, z along the screws, positive pulling it off the joint;
|
|
277
|
+
* moment: [x, y, z] in N·m on that part, about `at`; at: where the force acts, [x, y] or [x, y, z] in mm, z the
|
|
278
|
+
* height off the joint's face (default the centroid); pivot: for screws in a line, how far the clamped face
|
|
279
|
+
* reaches past the line, in mm
|
|
280
|
+
* @returns {{ count: number, centroid: number[], polar: number, line: boolean, screws: { at: number[], shear: number, tension: number, across: number[] }[], turns: number | null, rests: object[] }}
|
|
281
|
+
* polar: the sum of the squared distances from the centroid, mm²; screws: each one's shear (N, across the joint) and
|
|
282
|
+
* tension (N, along it: under 0, the load presses that screw's parts together); turns: a twist one screw alone
|
|
283
|
+
* cannot hold by shear, in N·m (it holds by friction only), null when it rounds to 0 at the thousandth
|
|
284
|
+
*/
|
|
285
|
+
export function screwGroup(places, o = {}) {
|
|
286
|
+
const what = 'screwGroup';
|
|
287
|
+
if (!Array.isArray(places) || !places.length) throw new Error(`${what}: places lists each screw's [x, y] across the joint, in mm (got ${shown(places)})`);
|
|
288
|
+
options(what, o, '{ force: [0, 0, 20], at: [12, 0] }');
|
|
289
|
+
const P = places.map((p, i) => xyz(what, `places[${i}]`, p, 2)), n = P.length, c = [P.reduce((t, p) => t + p[0], 0) / n, P.reduce((t, p) => t + p[1], 0) / n, 0];
|
|
290
|
+
const F = o.force != null ? xyz(what, 'force', o.force, 3) : [0, 0, 0], M0 = o.moment != null ? xyz(what, 'moment', o.moment, 3).map((m) => m * 1000) : [0, 0, 0], A = o.at != null ? xyz(what, 'at', o.at, 3) : c;
|
|
291
|
+
if (o.pivot != null) positive(what, 'pivot (how far the clamped face reaches past the line of screws, in mm)', o.pivot);
|
|
292
|
+
const M = crossed([A[0] - c[0], A[1] - c[1], A[2]], F).map((m, k) => m + M0[k]); // N mm about the centroid
|
|
293
|
+
const r = P.map((p) => [p[0] - c[0], p[1] - c[1]]), Sxx = r.reduce((t, q) => t + q[0] * q[0], 0), Syy = r.reduce((t, q) => t + q[1] * q[1], 0), Sxy = r.reduce((t, q) => t + q[0] * q[1], 0), polar = Sxx + Syy;
|
|
294
|
+
const det = Sxx * Syy - Sxy * Sxy, line = det <= 1e-9 * Math.max(polar * polar, 1);
|
|
295
|
+
// tension: the pull shared, and Σ P (y, -x) = (Mx, My) taken by a plane of tension through the centroid
|
|
296
|
+
let tension;
|
|
297
|
+
if (!line) { const b = (-M[1] * Syy - M[0] * Sxy) / det, cc = (M[0] * Sxx + M[1] * Sxy) / det; tension = r.map(([x, y]) => F[2] / n + b * x + cc * y); }
|
|
298
|
+
else {
|
|
299
|
+
const far = r.reduce((m, q) => (Math.hypot(...q) > Math.hypot(...m) ? q : m), [0, 0]), l = Math.hypot(...far), u = l > 1e-9 ? [far[0] / l, far[1] / l] : [1, 0], w = [u[1], -u[0]];
|
|
300
|
+
const s = r.map((q) => q[0] * u[0] + q[1] * u[1]), S2 = s.reduce((t, x) => t + x * x, 0), along = M[0] * w[0] + M[1] * w[1], about = l > 1e-9 ? M[0] * u[0] + M[1] * u[1] : Math.hypot(M[0], M[1]);
|
|
301
|
+
if (Math.abs(about) > 1e-9 && o.pivot == null) throw new Error(`${what}: the screws stand in one line${n === 1 ? ' (there is one)' : ''}, and ${mm(n1(Math.abs(about) / 1000))} N·m tips the part about it: give pivot, how far the clamped face reaches past the line in mm`);
|
|
302
|
+
tension = s.map((x) => F[2] / n + (S2 > 1e-9 ? (along * x) / S2 : 0) + (Math.abs(about) > 1e-9 ? Math.abs(about) / (n * o.pivot) : 0));
|
|
303
|
+
}
|
|
304
|
+
const screws = r.map(([x, y], i) => { const across = polar > 1e-9 ? [F[0] / n - (M[2] * y) / polar, F[1] / n + (M[2] * x) / polar] : [F[0] / n, F[1] / n]; return { at: [P[i][0], P[i][1]], shear: Math.hypot(...across), tension: tension[i], across }; }); // (not rounded: a check rounds what it prints)
|
|
305
|
+
const twist = r3(Math.abs(M[2]) / 1000); // N·m, as said: a twist that rounds to nothing is none
|
|
306
|
+
return { count: n, centroid: [r3(c[0]), r3(c[1])], polar: r3(polar), line, screws, turns: polar > 1e-9 || !twist ? null : twist,
|
|
307
|
+
rests: [{ name: 'the elastic method, in shear', value: 'P/n and M d / Σd² about the centroid', kind: 'spec', source: 'Eccentrically loaded bolt groups, the elastic method: https://steelcalculator.pages.dev/reference/bolt-group-capacity/ (read 2026-11-15)' },
|
|
308
|
+
{ name: 'the elastic method, in tension', value: 'a plane of tension through the centroid', kind: 'estimate', source: 'No source read: a moment shared as the shear is, each screw\'s pull growing with its distance from the centroid, which holds while the clamped parts stay pressed together. A joint that opens tips about its edge and loads its far screws more' }] };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* One screw of a joint under its share of a load: how many times that load it holds before the screw yields, the
|
|
313
|
+
* internal thread strips, and the clamped parts slip, at its preload. The screw takes its preload and the whole pull
|
|
314
|
+
* on it (a printed part is far softer than a steel screw, so little of the pull goes into easing the clamp), with
|
|
315
|
+
* its shear, against its proof load; the thread takes the same pull and preload against its stripping load; the clamp
|
|
316
|
+
* is eased by the whole pull for slipping, the safe side each time. With no torque given, the preload is the most that
|
|
317
|
+
* leaves the thread twice the pull, within the seat and three quarters of the proof load, and the torque for it is said.
|
|
318
|
+
* @param {Fixing | string} m @param {{ tension?: number, shear?: number, depth?: number, material?: string | object, end?: string, torque?: number, most?: number, K?: number, friction?: number, screw?: 'steel' | 'stainless', proof?: number, sets?: object }} o
|
|
319
|
+
* tension, shear: the screw's share, in N; depth and material: the thread engaged and what it is in (a pilot, tap or
|
|
320
|
+
* printed thread), or end: 'insert' or 'nut' where the thread is metal; torque: the tightening torque given, N·m;
|
|
321
|
+
* most: the most clamp force the seat under the head takes, N; friction: between the clamped parts (default fixings.clamp_friction)
|
|
322
|
+
* @returns {{ thread: string, tension: number, shear: number, preload: { force: number, torque: number, given: boolean }, proof: number, strip: number | null,
|
|
323
|
+
* margins: { screw: number, thread: number | null, slip: number | null }, margin: number, governs: string, rests: object[], findings: object[] }}
|
|
324
|
+
* margins: how many times the load each holds (null: not checked); margin: the least of the screw's and the thread's
|
|
325
|
+
*/
|
|
326
|
+
export function screwLoad(m, o = {}) {
|
|
327
|
+
const what = 'screwLoad';
|
|
328
|
+
options(what, o, '{ tension: 20, depth: 5, material: \'pla\' }');
|
|
329
|
+
const fx = fixingOf(what, m, o), num = (k, v) => { if (v != null && !(isNum(v) && v >= 0)) throw new Error(`${what}: ${k} is a number of N, 0 or more (got ${shown(v)})`); return v ?? 0; };
|
|
330
|
+
const T = Math.max(0, isNum(o.tension) ? o.tension : num('tension', o.tension)), S = num('shear', o.shear), mu = o.friction ?? DEFAULTS.clamp_friction.value;
|
|
331
|
+
if (!(isNum(mu) && mu > 0)) throw new Error(`${what}: friction is a number above 0 (got ${shown(o.friction)})`);
|
|
332
|
+
if (o.most != null) positive(what, 'most (the clamp force the seat takes, in N)', o.most);
|
|
333
|
+
const threaded = o.material != null, st = threaded ? stripping(fx, { depth: o.depth, material: o.material, sets: o.sets, screw: o.screw, proof: o.proof }) : null;
|
|
334
|
+
if (!threaded && o.end != null) oneOf(what, 'end', o.end, ['insert', 'nut']);
|
|
335
|
+
const pr0 = preload(fx, { force: 1, K: o.K, screw: o.screw, proof: o.proof, sets: o.sets }), P = pr0.proof, K = pr0.K, d = fx.major, want = DEFAULTS.load_margin.value;
|
|
336
|
+
let pre;
|
|
337
|
+
if (o.torque != null) { const p = preload(fx, { torque: positive(what, 'torque (in N·m)', o.torque), K: o.K, screw: o.screw, proof: o.proof, sets: o.sets }); pre = { force: p.force, torque: p.torque, given: true }; }
|
|
338
|
+
else {
|
|
339
|
+
const F = Math.max(0, Math.min(o.most ?? Infinity, DEFAULTS.preload_share.value * P, st ? st.strip - want * T : Infinity)), t = Math.floor((K * d * F) / 1000 * 100 + 1e-9) / 100;
|
|
340
|
+
pre = { force: n1((t * 1000) / (K * d)), torque: t, given: false };
|
|
341
|
+
}
|
|
342
|
+
const Fp = pre.force, a2 = T * T + 3 * S * S, b2 = 2 * Fp * T, c2 = Fp * Fp - P * P;
|
|
343
|
+
const screwK = Fp >= P ? 0 : a2 > 0 ? (-b2 + Math.sqrt(b2 * b2 - 4 * a2 * c2)) / (2 * a2) : Infinity;
|
|
344
|
+
const threadK = !st ? null : Fp >= st.strip ? 0 : T > 0 ? (st.strip - Fp) / T : Infinity, slipK = S > 0 ? (mu * Fp) / (S + mu * T) : null;
|
|
345
|
+
const margin = Math.min(screwK, threadK ?? Infinity), governs = threadK != null && threadK <= screwK ? 'thread' : 'screw', k2 = (x) => (x === Infinity ? 'any number of' : mm(n2(x)));
|
|
346
|
+
const level = margin < 1 ? 'fail' : margin < want ? 'warn' : 'pass', load = `${mm(n1(T))} N of pull and ${mm(n1(S))} N of shear`;
|
|
347
|
+
const clamp = `clamped with ${mm(Fp)} N (${mm(pre.torque)} N·m${pre.given ? '' : ', the torque to tighten to'}, T = K d F with K = ${mm(K)}${o.K == null ? ', an estimate' : ''})`;
|
|
348
|
+
const threadSays = st ? `its thread in ${st.material} strips at about ${mm(st.strip)} N (an estimate: ${st.shear} MPa in shear), ${Fp >= st.strip ? 'under the preload alone' : `${k2(threadK)} times this pull over the preload`}`
|
|
349
|
+
: o.end === 'insert' ? 'its thread is in a brass insert, whose hold in the plastic is its maker\'s figure and not checked here' : o.end === 'nut' ? 'its thread is in a steel nut, not checked here: the screw\'s proof load stands for it' : 'nothing says what its thread is in, so the thread is not checked';
|
|
350
|
+
const out = [finding(level, `${a(fx.thread)} screw with ${load}, ${clamp}: ${threadSays}; the screw yields at ${k2(screwK)} times it (proof load ${mm(P)} N). ${margin === Infinity ? 'Nothing pulls on it' : `It holds ${k2(margin)} times the load, the ${governs} first`}${level === 'pass' ? '' : `, where the kit asks ${want} times`}`,
|
|
351
|
+
'screwLoad.margin', { values: { tension: n1(T), shear: n1(S), preload: Fp, torque: pre.torque, proof: P, strip: st?.strip ?? null, screw: screwK === Infinity ? null : n2(screwK), thread: threadK == null || threadK === Infinity ? null : n2(threadK), margin: margin === Infinity ? null : n2(margin) } })];
|
|
352
|
+
if (slipK != null) out.push(finding(slipK >= want ? 'pass' : 'warn', `the clamp of ${mm(Fp)} N, eased by the pull, holds the ${mm(n1(S))} N of shear by friction ${mm(n2(slipK))} times over (fixings.clamp_friction ${mm(mu)}, an estimate)${slipK >= want ? '' : `: under ${want} times the parts may slip until the screw bears on its hole`}`, 'screwLoad.slip', { values: { slip: n2(slipK), friction: mu } }));
|
|
353
|
+
return { thread: fx.thread, tension: n1(T), shear: n1(S), preload: pre, proof: P, strip: st?.strip ?? null, margins: { screw: screwK === Infinity ? Infinity : n2(screwK), thread: threadK == null ? null : threadK === Infinity ? Infinity : n2(threadK), slip: slipK == null ? null : n2(slipK) }, margin: margin === Infinity ? Infinity : n2(margin), governs,
|
|
354
|
+
rests: [...(st ? st.rests : []), ...pr0.rests, ...(slipK != null && o.friction == null ? [rest('fixings.clamp_friction', DEFAULTS.clamp_friction)] : []), rest('fixings.load_margin', DEFAULTS.load_margin)], findings: out };
|
|
355
|
+
}
|