@rulecad/fixings 0.1.4 → 0.1.5
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 +50 -0
- package/README.md +251 -6
- package/bolts.d.mts +85 -0
- package/bolts.mjs +106 -0
- package/fixings.d.mts +3 -0
- package/fixings.mjs +14 -3
- package/hardware.d.mts +8 -4
- package/hardware.mjs +15 -7
- package/magnets.d.mts +188 -0
- package/magnets.mjs +279 -0
- package/model.d.mts +4 -3
- package/model.mjs +16 -10
- package/package.json +8 -2
- package/pins.d.mts +220 -0
- package/pins.mjs +300 -0
- package/seats.mjs +2 -0
- package/strength.d.mts +13 -0
- package/strength.mjs +17 -9
package/fixings.mjs
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
// nutTrap, squareNutSlot, captiveNut, insertBoss), and light solids of the hardware for an assembly (screw, nut,
|
|
5
5
|
// washer, insert), a real thread to print where one is wanted (thread), and first sums for a joint: thread engaged,
|
|
6
6
|
// the load that strips it, clamp force from torque, pressure under a head, and the sold length that fits a stack
|
|
7
|
-
// (engagement, stripping, preload, seating, lengthFor)
|
|
7
|
+
// (engagement, stripping, preload, seating, lengthFor), and pins that hold two parts with no thread: a printed snap pin, a
|
|
8
|
+
// steel dowel, a length of filament or a printed peg, each with its hole's fit from the printer's rules (pinModel, pinHole,
|
|
9
|
+
// pin), and magnets pressed, glued or held by crush ribs in a pocket from the printer's rules, with their pull (magnetModel,
|
|
10
|
+
// magnetSeatModel, magnetSeat, magnet), and printed bolts with their own strength (printedBoltModel, printedBolt). Where it applies each comes as a pair: one function gives the
|
|
8
11
|
// numbers with findings (holeModel), its twin the solid (hole). Every thread's figures live in @rulecad/rules as open data: this package holds no
|
|
9
12
|
// screw's numbers of its own. Units: mm, degrees, grams. The plan is https://github.com/JoniBach/rulecad/issues/212.
|
|
10
13
|
import { fixingModel } from './model.mjs';
|
|
@@ -13,6 +16,9 @@ import { counterboreModel, counterbore, countersinkModel, countersink, nutPocket
|
|
|
13
16
|
import { screwModel, screw, nutModel, nut, washerModel, washer, insertModel, insert } from './hardware.mjs';
|
|
14
17
|
import { threadModel, thread } from './threads.mjs';
|
|
15
18
|
import { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGroup, screwLoad } from './strength.mjs';
|
|
19
|
+
import { pinModel, pinHole, pin, snapPin, snapSocket, snapPinModel, parsePin, isPinName } from './pins.mjs';
|
|
20
|
+
import { printedBoltModel, printedBolt } from './bolts.mjs';
|
|
21
|
+
import { magnetModel, magnetSeatModel, magnetSeat, magnet, parseMagnet, isMagnetName, fieldShare } from './magnets.mjs';
|
|
16
22
|
|
|
17
23
|
export { fixingModel, parseName, threads, GRAMMAR, HEADS, NUTS, DEFAULTS } from './model.mjs';
|
|
18
24
|
export { holeModel, hole, HOLE_KINDS } from './holes.mjs';
|
|
@@ -20,6 +26,9 @@ export { counterboreModel, counterbore, countersinkModel, countersink, nutPocket
|
|
|
20
26
|
export { screwModel, screw, nutModel, nut, washerModel, washer, insertModel, insert } from './hardware.mjs';
|
|
21
27
|
export { threadModel, thread, THREAD_FORMS } from './threads.mjs';
|
|
22
28
|
export { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGroup, screwLoad, MATERIALS, MATERIAL_CLASSES, ENDS } from './strength.mjs';
|
|
29
|
+
export { pinModel, pinHole, pin, snapPin, snapSocket, snapPinModel, parsePin, isPinName, PIN_KINDS, PIN_FITS, PIN_GRAMMAR } from './pins.mjs';
|
|
30
|
+
export { printedBoltModel, printedBolt, BOLT_NUTS } from './bolts.mjs';
|
|
31
|
+
export { magnetModel, magnetSeatModel, magnetSeat, magnet, parseMagnet, isMagnetName, fieldShare, MAGNET_GRADES, MAGNET_FITS, MAGNET_SIZES, MAGNET_GRAMMAR } from './magnets.mjs';
|
|
23
32
|
|
|
24
33
|
/**
|
|
25
34
|
* What this release is. `release` is `'placeholder'` until the package has functions to call (0.1.0), then `'ready'`:
|
|
@@ -28,8 +37,8 @@ export { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGro
|
|
|
28
37
|
*/
|
|
29
38
|
export const status = Object.freeze({ release: 'ready', plan: 'https://github.com/JoniBach/rulecad/issues/212' });
|
|
30
39
|
|
|
31
|
-
const MODELS = { engagement, stripping, preload, torqueFor, seating, screwLoad, threadModel, holeModel, counterboreModel, countersinkModel, nutPocketModel, nutTrapModel, squareNutSlotModel, captiveNutModel, insertBossModel, screwModel, nutModel, washerModel, insertModel };
|
|
32
|
-
const SOLIDS = { thread, hole, counterbore, countersink, nutPocket, nutTrap, squareNutSlot, captiveNut, insertBoss, nut, washer, insert }, JOINED = { screw };
|
|
40
|
+
const MODELS = { engagement, stripping, preload, torqueFor, seating, screwLoad, threadModel, holeModel, counterboreModel, countersinkModel, nutPocketModel, nutTrapModel, squareNutSlotModel, captiveNutModel, insertBossModel, screwModel, nutModel, washerModel, insertModel, pinModel, magnetModel, magnetSeatModel, printedBoltModel };
|
|
41
|
+
const SOLIDS = { thread, hole, counterbore, countersink, nutPocket, nutTrap, squareNutSlot, captiveNut, insertBoss, nut, washer, insert, pinHole, magnetSeat, magnet }, JOINED = { screw, pin, printedBolt };
|
|
33
42
|
|
|
34
43
|
/**
|
|
35
44
|
* Every function of this package with a workspace's rule sets and printer already in hand, so a design writes
|
|
@@ -49,6 +58,8 @@ export function fixingsFor({ sets, printer, ops, display } = {}) {
|
|
|
49
58
|
for (const [k, f] of Object.entries({ ...MODELS, ...SOLIDS })) out[k] = (m, o = {}) => f(m, with_(as(k, o)));
|
|
50
59
|
out.lengthFor = (stack, m, o = {}) => lengthFor(stack, m, with_(o));
|
|
51
60
|
out.screwGroup = screwGroup;
|
|
61
|
+
// (a snap pin from plain figures, as @rulecad/flexures draws it, built with the design's booleans)
|
|
62
|
+
Object.assign(out, { snapPin: (p, o) => snapPin(p, o ?? ops ?? undefined), snapSocket, snapPinModel, parsePin, isPinName, parseMagnet, isMagnetName, fieldShare });
|
|
52
63
|
for (const [k, f] of Object.entries(JOINED)) out[k] = (m, o = {}) => (ops ? f(m, with_(o), ops) : f(m, with_(o)));
|
|
53
64
|
return out;
|
|
54
65
|
}
|
package/hardware.d.mts
CHANGED
|
@@ -5,13 +5,16 @@
|
|
|
5
5
|
* A screw as numbers: its outline, the anchors an assembly places it by, and its mass.
|
|
6
6
|
* It stands on the z axis with its head up: the face its head seats on is at z = 0 and its thread runs down to
|
|
7
7
|
* z = -length. A countersunk screw and a set screw are measured overall, so their top is at z = 0.
|
|
8
|
+
* A printed bolt ('M8x20 hex printed') keeps the word printed in its name and is weighed in its plastic; its strength
|
|
9
|
+
* is printedBoltModel's.
|
|
8
10
|
* @param {Fixing | string} m a screw's model or name ('M3x12 cap'), or a thread with { length, head }
|
|
9
|
-
* @param {{ length?: number, head?: string, material?:
|
|
11
|
+
* @param {{ length?: number, head?: string, material?: string | object, anyLength?: boolean, sets?: object, display?: 'plain' | 'thread', printer?: object,
|
|
10
12
|
* mate?: 'printed' | 'bought', gap?: number, flanks?: 'printed' | 'standard', hand?: 'right' | 'left', segments?: number }} [o]
|
|
11
|
-
* length, head: where the model has none, or to change them; material: for its mass (default
|
|
13
|
+
* length, head: where the model has none, or to change them; material: for its mass, steel (the default) or
|
|
14
|
+
* stainless, or for a printed bolt its plastic (default PLA); display: plain
|
|
12
15
|
* (the light solid, the default) or thread (its thread drawn, to print it standing on its head: then printer, mate,
|
|
13
16
|
* gap, flanks, hand and segments are threadModel's)
|
|
14
|
-
* @returns {{ item: 'screw', name: string, thread: string, head: string, length: number, sold: boolean | null, major: number, headDiameter: number, headHeight: number, sink: number, top: number, key: number | null,
|
|
17
|
+
* @returns {{ item: 'screw', name: string, printed?: boolean, thread: string, head: string, length: number, sold: boolean | null, major: number, headDiameter: number, headHeight: number, sink: number, top: number, key: number | null,
|
|
15
18
|
* mass: number, material: string, display: 'plain' | 'thread', threaded: object | null, anchors: { seat: Anchor, tip: Anchor, axis: Anchor, top: Anchor }, profile: number[][], rests: object[], findings: object[] }}
|
|
16
19
|
* sink: how deep a countersunk head's cone goes; top: the z of the head's top; mass: grams; threaded: threadModel's numbers where its thread is drawn;
|
|
17
20
|
* anchors: seat (under the head, or the flush face of a countersunk screw), tip, axis (the thread's, at the seat) and top (where a key goes in)
|
|
@@ -19,7 +22,7 @@
|
|
|
19
22
|
export function screwModel(m: Fixing | string, o?: {
|
|
20
23
|
length?: number;
|
|
21
24
|
head?: string;
|
|
22
|
-
material?:
|
|
25
|
+
material?: string | object;
|
|
23
26
|
anyLength?: boolean;
|
|
24
27
|
sets?: object;
|
|
25
28
|
display?: "plain" | "thread";
|
|
@@ -32,6 +35,7 @@ export function screwModel(m: Fixing | string, o?: {
|
|
|
32
35
|
}): {
|
|
33
36
|
item: "screw";
|
|
34
37
|
name: string;
|
|
38
|
+
printed?: boolean;
|
|
35
39
|
thread: string;
|
|
36
40
|
head: string;
|
|
37
41
|
length: number;
|
package/hardware.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { DEFAULTS, fixingOf, headOf, nutOf, lengthOf, screwName, figure, cite, r
|
|
|
7
7
|
import { optionsOf } from './holes.mjs';
|
|
8
8
|
import { lathe, turnedVolume, booleans, LIGHT } from './draw.mjs';
|
|
9
9
|
import { threadModel, threadedScrew, threadedNut } from './threads.mjs';
|
|
10
|
+
import { materialOf } from './strength.mjs';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @typedef {import('./model.mjs').Fixing} Fixing a fixing's model, as fixingModel gives it
|
|
@@ -41,13 +42,16 @@ const weighed = (name, mass, material, how) => finding('info', `${name}: ${mm(ma
|
|
|
41
42
|
* A screw as numbers: its outline, the anchors an assembly places it by, and its mass.
|
|
42
43
|
* It stands on the z axis with its head up: the face its head seats on is at z = 0 and its thread runs down to
|
|
43
44
|
* z = -length. A countersunk screw and a set screw are measured overall, so their top is at z = 0.
|
|
45
|
+
* A printed bolt ('M8x20 hex printed') keeps the word printed in its name and is weighed in its plastic; its strength
|
|
46
|
+
* is printedBoltModel's.
|
|
44
47
|
* @param {Fixing | string} m a screw's model or name ('M3x12 cap'), or a thread with { length, head }
|
|
45
|
-
* @param {{ length?: number, head?: string, material?:
|
|
48
|
+
* @param {{ length?: number, head?: string, material?: string | object, anyLength?: boolean, sets?: object, display?: 'plain' | 'thread', printer?: object,
|
|
46
49
|
* mate?: 'printed' | 'bought', gap?: number, flanks?: 'printed' | 'standard', hand?: 'right' | 'left', segments?: number }} [o]
|
|
47
|
-
* length, head: where the model has none, or to change them; material: for its mass (default
|
|
50
|
+
* length, head: where the model has none, or to change them; material: for its mass, steel (the default) or
|
|
51
|
+
* stainless, or for a printed bolt its plastic (default PLA); display: plain
|
|
48
52
|
* (the light solid, the default) or thread (its thread drawn, to print it standing on its head: then printer, mate,
|
|
49
53
|
* gap, flanks, hand and segments are threadModel's)
|
|
50
|
-
* @returns {{ item: 'screw', name: string, thread: string, head: string, length: number, sold: boolean | null, major: number, headDiameter: number, headHeight: number, sink: number, top: number, key: number | null,
|
|
54
|
+
* @returns {{ item: 'screw', name: string, printed?: boolean, thread: string, head: string, length: number, sold: boolean | null, major: number, headDiameter: number, headHeight: number, sink: number, top: number, key: number | null,
|
|
51
55
|
* mass: number, material: string, display: 'plain' | 'thread', threaded: object | null, anchors: { seat: Anchor, tip: Anchor, axis: Anchor, top: Anchor }, profile: number[][], rests: object[], findings: object[] }}
|
|
52
56
|
* sink: how deep a countersunk head's cone goes; top: the z of the head's top; mass: grams; threaded: threadModel's numbers where its thread is drawn;
|
|
53
57
|
* anchors: seat (under the head, or the flush face of a countersunk screw), tip, axis (the thread's, at the seat) and top (where a key goes in)
|
|
@@ -59,7 +63,7 @@ export function screwModel(m, o = {}) {
|
|
|
59
63
|
if (!['screw', 'thread'].includes(fx.item)) throw new Error(`${what}: ${fx.name} is ${a(fx.item)}, not a screw: use ${fx.item}()`);
|
|
60
64
|
const form = o.head ?? fx.head?.form ?? (fx.made.heads.includes('cap') ? 'cap' : fx.made.heads[0]), head = headOf(what, fx, form);
|
|
61
65
|
if (o.length == null && fx.length == null) throw new Error(`${what}: give a length, in the name ('${fx.thread}x12 ${form}') or as { length: 12 }`);
|
|
62
|
-
const { length, sold } = o.length == null ? fx : form === 'set' ? { length: positive(what, 'length', o.length), sold: null } : lengthOf(what, fx, o.length, !!o.anyLength);
|
|
66
|
+
const { length, sold } = o.length == null ? fx : form === 'set' ? { length: positive(what, 'length', o.length), sold: null } : lengthOf(what, fx, o.length, !!o.anyLength || !!fx.printed); // (a printed screw is printed at any length)
|
|
63
67
|
const r = fx.major / 2, R = head.across / 2, k = head.height, L = length;
|
|
64
68
|
// The outline, turned about z: from the tip up the thread, out under the head and over it
|
|
65
69
|
const sink = form === 'countersunk' ? Math.min(r3((R - r) / Math.tan((((head.angle ?? 90) / 2) * Math.PI) / 180)), L) : 0;
|
|
@@ -70,12 +74,16 @@ export function screwModel(m, o = {}) {
|
|
|
70
74
|
const top = form === 'set' || form === 'countersunk' ? 0 : k, shank = L - sink;
|
|
71
75
|
const headProfile = form === 'countersunk' ? [[0, -sink], [r, -sink], [R, 0], [0, 0]] : profile.filter(([, z]) => z >= 0).map((p, i) => (i === 0 ? [0, 0] : p));
|
|
72
76
|
const headVolume = form === 'set' ? 0 : form === 'hex' ? (Math.sqrt(3) / 2) * head.flats ** 2 * k : turnedVolume(headProfile);
|
|
73
|
-
|
|
77
|
+
// a printed bolt ('M8x20 hex printed') is named as printed and weighed in its plastic (PLA unless material names another): its strength is printedBoltModel's
|
|
78
|
+
const volume = threadArea(what, fx) * shank + headVolume, plastic = fx.printed ? materialOf(what, o.material ?? 'pla', o.sets) : null;
|
|
79
|
+
if (plastic && plastic.cls !== 'plastic') throw new Error(`${what}: ${fx.name} is printed, and ${plastic.name} is no plastic: give a plastic as its material (pla, petg), or name a bought screw ('${screwName(fx, L, form)}'). printedBoltModel('${fx.name}') gives its strength`);
|
|
80
|
+
if (plastic && !plastic.density) throw new Error(`${what}: ${plastic.name} has no density in its rule set, so ${fx.name} cannot be weighed`);
|
|
81
|
+
const material = plastic ? plastic.name : o.material ?? 'steel', w = plastic ? { mass: r3((volume * plastic.density.value) / 1000), density: rest(plastic.density.name, plastic.density) } : massOf(what, volume, material), name = `${screwName(fx, L, form)}${fx.printed ? ' printed' : ''}`;
|
|
74
82
|
const threaded = drawnThread(what, fx, o, { length: shank, top: '-z' }); // (it prints standing on its head, so its tip is up)
|
|
75
|
-
return { item: 'screw', name, thread: fx.thread, head: form, length: L, sold, major: fx.major, headDiameter: head.across, headHeight: k, sink, top, key: head.key ?? null, mass: w.mass, material,
|
|
83
|
+
return { item: 'screw', name, ...(fx.printed ? { printed: true } : {}), thread: fx.thread, head: form, length: L, sold, major: fx.major, headDiameter: head.across, headHeight: k, sink, top, key: head.key ?? null, mass: w.mass, material,
|
|
76
84
|
display: threaded ? 'thread' : 'plain', threaded, anchors: { seat: anchor(0), tip: anchor(-L, -1), axis: anchor(0), top: anchor(top) }, profile,
|
|
77
85
|
rests: [rest(cite(fx, 'major_diameter'), fx.figures.major_diameter), rest(cite(fx, 'pitch'), fx.figures.pitch), ...head.figures.map((n) => rest(cite(fx, n), fx.figures[n])), w.density, ...(threaded ? threaded.rests : [])],
|
|
78
|
-
findings: [weighed(name, w.mass, material, 'the thread at its pitch diameter, the head with no socket'), ...(threaded ? threaded.findings : [])] };
|
|
86
|
+
findings: [weighed(name, w.mass, material, 'the thread at its pitch diameter, the head with no socket'), ...(fx.printed ? [finding('info', `${name} is printed in ${material}, not bought: printedBoltModel('${name}', { material: '${material}' }) gives its strength`, 'fixing.printed', { values: { grams: w.mass }, refs: { material } })] : []), ...(threaded ? threaded.findings : [])] };
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
/**
|
package/magnets.d.mts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A magnet's name read by the grammar.
|
|
3
|
+
* @param {string} name 'disc magnet 8x3', 'magnet 6x2 N52', 'block magnet 10x5x2 N45'
|
|
4
|
+
* @returns {{ shape: 'disc' | 'block', diameter: number | null, length: number | null, width: number | null, thickness: number, grade: string | null }}
|
|
5
|
+
*/
|
|
6
|
+
export function parseMagnet(name: string): {
|
|
7
|
+
shape: "disc" | "block";
|
|
8
|
+
diameter: number | null;
|
|
9
|
+
length: number | null;
|
|
10
|
+
width: number | null;
|
|
11
|
+
thickness: number;
|
|
12
|
+
grade: string | null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The flux density on a magnet's axis at a distance from its face, over the density at its face: the formulas of
|
|
16
|
+
* magnets.field_formula. A pull across a gap is taken as the pull touching times this squared, an estimate.
|
|
17
|
+
* @param {{ shape: 'disc' | 'block', diameter?: number | null, length?: number | null, width?: number | null, thickness: number }} p @param {number} z mm
|
|
18
|
+
* @returns {number} B(z) / B(0)
|
|
19
|
+
*/
|
|
20
|
+
export function fieldShare(p: {
|
|
21
|
+
shape: "disc" | "block";
|
|
22
|
+
diameter?: number | null;
|
|
23
|
+
length?: number | null;
|
|
24
|
+
width?: number | null;
|
|
25
|
+
thickness: number;
|
|
26
|
+
}, z: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {{ kind: 'magnet', shape: 'disc' | 'block', name: string, said: string, diameter: number | null, length: number | null, width: number | null, thickness: number,
|
|
29
|
+
* grade: string, made: 'bought', touching: number, gap: number, pull: number, count: number, total: number, load: number | null, margin: number | null,
|
|
30
|
+
* grams: number, volume: number, rests: object[], findings: object[] }} Magnet
|
|
31
|
+
* touching: its pull straight off thick steel it touches, N; gap: what lies between it and the steel, mm; pull: across that gap, N;
|
|
32
|
+
* count: how many share the load; total: their pull together; load and margin: the pull asked of them all, and total over it
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* A magnet as a model by name: its pull straight off steel, from its seller's figure (magnets.<size>_pull) scaled to
|
|
36
|
+
* its grade by the square of the remanence, then across a gap by the square of the field on its axis; its mass.
|
|
37
|
+
* Refused by name where its size has no seller's figure, unless the pull is given.
|
|
38
|
+
* @param {string | Magnet} p a magnet's name (see MAGNET_GRAMMAR) or its model (given back as it is, or with options
|
|
39
|
+
* built again from its name, its own grade, gap, count, load and given pull where the options say none)
|
|
40
|
+
* @param {{ grade?: string, gap?: number, count?: number, load?: number, pull?: number }} [o]
|
|
41
|
+
* grade: in place of the name's; gap: plastic, paint or air between it and the steel, mm (default 0); count: magnets
|
|
42
|
+
* sharing the load (default 1); load: the pull asked of them, N, held to fixings.load_margin; pull: a magnet's own
|
|
43
|
+
* pull touching steel, N, from its maker, for a size the kit holds no figure for
|
|
44
|
+
* @returns {Magnet}
|
|
45
|
+
*/
|
|
46
|
+
export function magnetModel(p: string | Magnet, o?: {
|
|
47
|
+
grade?: string;
|
|
48
|
+
gap?: number;
|
|
49
|
+
count?: number;
|
|
50
|
+
load?: number;
|
|
51
|
+
pull?: number;
|
|
52
|
+
}): Magnet;
|
|
53
|
+
/**
|
|
54
|
+
* @typedef {{ kind: 'magnet-seat', magnet: Magnet, fit: 'press' | 'glue' | 'ribs', facing: 'open' | 'floor',
|
|
55
|
+
* pocket: { shape: 'round' | 'rect', diameter: number | null, size: number[] | null, nominal: number[], comp: number, clearance: number, depth: number, lead: number,
|
|
56
|
+
* into: string, axis: 'x' | 'y' | 'z', teardrop: boolean, ribs: { count: number, tips: number, radius: number, protrude: number } | null, relief: number | null, rules: string[] },
|
|
57
|
+
* floor: number | null, thickness: number | null, hold: number | null, holdMargin: number | null, rests: object[], findings: object[] }} MagnetSeat
|
|
58
|
+
* pocket: what to draw (diameter of a round pocket, or [length, width] of a block's, as drawn; nominal: the magnet's;
|
|
59
|
+
* comp: hole compensation added; clearance: added across past that, under 0 for a press; lead: the chamfer at its
|
|
60
|
+
* mouth; ribs: crush ribs, their tips on a circle `tips` across; relief: a block pocket's corner reliefs' radius);
|
|
61
|
+
* floor: what is left under it in a part `thickness` thick; hold: what the fit grips the magnet with against its pull out, N
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* A magnet's pocket as a model: its size from the printer's rules for the fit (press: the magnet plus hole_comp less
|
|
65
|
+
* x1c.magnet_press; glue: plus x1c.magnet_glue; ribs: a glue pocket with three crush ribs whose tips stand
|
|
66
|
+
* x1c.magnet_crush inside the magnet), its depth (the magnet's thickness, and any recess), the floor left under it held
|
|
67
|
+
* to fixings.magnet_floor, and the magnet's pull out of it against what the fit grips with. Refused by name where it
|
|
68
|
+
* would not print: a pocket opening on the bed wider than the printer bridges, a block's pocket or crush ribs lying on
|
|
69
|
+
* their side, a floor too thin.
|
|
70
|
+
* @param {string | Magnet} p a magnet's name or model
|
|
71
|
+
* @param {{ fit?: 'press' | 'glue' | 'ribs', printer?: object, material?: string | object, sets?: object, into?: string, axis?: 'x' | 'y' | 'z',
|
|
72
|
+
* recess?: number, thickness?: number, facing?: 'open' | 'floor', grade?: string, gap?: number, count?: number, load?: number, pull?: number }} [o]
|
|
73
|
+
* fit: press, glue or ribs (the default: ribs for a disc standing in its pocket; glue for a disc lying on its side,
|
|
74
|
+
* where ribs would hang from the roof, and for a block, whose press splits its wall); material: the part's plastic (default PLA); into or axis: the pocket's way
|
|
75
|
+
* (default down from a top face); recess: how far under the face the magnet sits, mm; thickness: the part's along
|
|
76
|
+
* the pocket, for its floor; facing: where the magnet's steel is, past the pocket's open face (the default) or
|
|
77
|
+
* through its floor, which is then the gap; grade, gap, count, load, pull: magnetModel's
|
|
78
|
+
* @returns {MagnetSeat}
|
|
79
|
+
*/
|
|
80
|
+
export function magnetSeatModel(p: string | Magnet, o?: {
|
|
81
|
+
fit?: "press" | "glue" | "ribs";
|
|
82
|
+
printer?: object;
|
|
83
|
+
material?: string | object;
|
|
84
|
+
sets?: object;
|
|
85
|
+
into?: string;
|
|
86
|
+
axis?: "x" | "y" | "z";
|
|
87
|
+
recess?: number;
|
|
88
|
+
thickness?: number;
|
|
89
|
+
facing?: "open" | "floor";
|
|
90
|
+
grade?: string;
|
|
91
|
+
gap?: number;
|
|
92
|
+
count?: number;
|
|
93
|
+
load?: number;
|
|
94
|
+
pull?: number;
|
|
95
|
+
}): MagnetSeat;
|
|
96
|
+
/**
|
|
97
|
+
* A magnet's pocket, to subtract: round (a teardrop lying on its side) with crush ribs where asked, or a block's with
|
|
98
|
+
* its corners relieved, the size magnetSeatModel gives it, from the point at on the face going into the part.
|
|
99
|
+
* @param {string | Magnet} p @param {object} [o] as magnetSeatModel, and at: the point on the face where the pocket starts
|
|
100
|
+
* @returns {object} a JSCAD geom3 with .model holding magnetSeatModel's numbers
|
|
101
|
+
*/
|
|
102
|
+
export function magnetSeat(p: string | Magnet, o?: object): object;
|
|
103
|
+
/**
|
|
104
|
+
* A magnet's solid, standing on z = 0, for an assembly: a disc or a block. @param {string | Magnet} p @param {object} [o] as magnetModel
|
|
105
|
+
* @returns {object} a JSCAD geom3 with .model
|
|
106
|
+
*/
|
|
107
|
+
export function magnet(p: string | Magnet, o?: object): object;
|
|
108
|
+
/** The grades of NdFeB magnet there is a remanence for, weakest first. */
|
|
109
|
+
export const MAGNET_GRADES: string[];
|
|
110
|
+
/** The fits a magnet takes in its pocket: press (it grips), glue (room for a film of glue), ribs (crush ribs grip it). */
|
|
111
|
+
export const MAGNET_FITS: string[];
|
|
112
|
+
/** The sizes there is a seller's pull for: discs as diameter x thickness, blocks as length x width x thickness. */
|
|
113
|
+
export const MAGNET_SIZES: Readonly<{
|
|
114
|
+
disc: string[];
|
|
115
|
+
block: string[];
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* The grammar a magnet's name is read by. parseMagnet reads it and nothing else does.
|
|
119
|
+
* @type {string}
|
|
120
|
+
*/
|
|
121
|
+
export const MAGNET_GRAMMAR: string;
|
|
122
|
+
export function isMagnetName(name: unknown): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* touching: its pull straight off thick steel it touches, N; gap: what lies between it and the steel, mm; pull: across that gap, N;
|
|
125
|
+
* count: how many share the load; total: their pull together; load and margin: the pull asked of them all, and total over it
|
|
126
|
+
*/
|
|
127
|
+
export type Magnet = {
|
|
128
|
+
kind: "magnet";
|
|
129
|
+
shape: "disc" | "block";
|
|
130
|
+
name: string;
|
|
131
|
+
said: string;
|
|
132
|
+
diameter: number | null;
|
|
133
|
+
length: number | null;
|
|
134
|
+
width: number | null;
|
|
135
|
+
thickness: number;
|
|
136
|
+
grade: string;
|
|
137
|
+
made: "bought";
|
|
138
|
+
touching: number;
|
|
139
|
+
gap: number;
|
|
140
|
+
pull: number;
|
|
141
|
+
count: number;
|
|
142
|
+
total: number;
|
|
143
|
+
load: number | null;
|
|
144
|
+
margin: number | null;
|
|
145
|
+
grams: number;
|
|
146
|
+
volume: number;
|
|
147
|
+
rests: object[];
|
|
148
|
+
findings: object[];
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* pocket: what to draw (diameter of a round pocket, or [length, width] of a block's, as drawn; nominal: the magnet's;
|
|
152
|
+
* comp: hole compensation added; clearance: added across past that, under 0 for a press; lead: the chamfer at its
|
|
153
|
+
* mouth; ribs: crush ribs, their tips on a circle `tips` across; relief: a block pocket's corner reliefs' radius);
|
|
154
|
+
* floor: what is left under it in a part `thickness` thick; hold: what the fit grips the magnet with against its pull out, N
|
|
155
|
+
*/
|
|
156
|
+
export type MagnetSeat = {
|
|
157
|
+
kind: "magnet-seat";
|
|
158
|
+
magnet: Magnet;
|
|
159
|
+
fit: "press" | "glue" | "ribs";
|
|
160
|
+
facing: "open" | "floor";
|
|
161
|
+
pocket: {
|
|
162
|
+
shape: "round" | "rect";
|
|
163
|
+
diameter: number | null;
|
|
164
|
+
size: number[] | null;
|
|
165
|
+
nominal: number[];
|
|
166
|
+
comp: number;
|
|
167
|
+
clearance: number;
|
|
168
|
+
depth: number;
|
|
169
|
+
lead: number;
|
|
170
|
+
into: string;
|
|
171
|
+
axis: "x" | "y" | "z";
|
|
172
|
+
teardrop: boolean;
|
|
173
|
+
ribs: {
|
|
174
|
+
count: number;
|
|
175
|
+
tips: number;
|
|
176
|
+
radius: number;
|
|
177
|
+
protrude: number;
|
|
178
|
+
} | null;
|
|
179
|
+
relief: number | null;
|
|
180
|
+
rules: string[];
|
|
181
|
+
};
|
|
182
|
+
floor: number | null;
|
|
183
|
+
thickness: number | null;
|
|
184
|
+
hold: number | null;
|
|
185
|
+
holdMargin: number | null;
|
|
186
|
+
rests: object[];
|
|
187
|
+
findings: object[];
|
|
188
|
+
};
|