@rulecad/frames 0.1.7 → 0.1.8
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 +23 -0
- package/README.md +640 -13
- package/beam.d.mts +5 -2
- package/beam.mjs +22 -3
- package/bought.d.mts +60 -0
- package/bought.mjs +195 -0
- package/catalogue.mjs +32 -3
- package/door.d.mts +127 -0
- package/door.mjs +254 -0
- package/ends.d.mts +130 -0
- package/ends.mjs +290 -0
- package/fitting.d.mts +262 -0
- package/fitting.mjs +535 -0
- package/frames.d.mts +13 -1
- package/frames.mjs +31 -4
- package/guide.d.mts +140 -0
- package/guide.mjs +269 -0
- package/jig.d.mts +146 -0
- package/jig.mjs +332 -0
- package/join.d.mts +244 -0
- package/join.mjs +257 -0
- package/ops.mjs +12 -7
- package/package.json +40 -6
- package/panel.d.mts +225 -0
- package/panel.mjs +374 -0
- package/rods.d.mts +195 -0
- package/rods.mjs +475 -0
- package/services.d.mts +335 -0
- package/services.mjs +486 -0
- package/slotnut.d.mts +4 -1
- package/slotnut.mjs +9 -4
- package/square.d.mts +23 -0
- package/square.mjs +42 -0
- package/wheels.d.mts +141 -0
- package/wheels.mjs +337 -0
package/ends.mjs
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// Printed parts for a beam's end: an end cap pushed into the slots and the bore, a foot and a stacking foot screwed into
|
|
2
|
+
// the end's tapped bore, a levelling foot whose pad screws up and down a printed thread (or holds a bought foot's stud
|
|
3
|
+
// in a nut), and a castor plate that carries a castor's top plate under the end. Each is drawn from the profile's, the
|
|
4
|
+
// thread's and the printer's rules, prints without supports with a plain first layer, and reports its grams and its
|
|
5
|
+
// margin at a named load.
|
|
6
|
+
//
|
|
7
|
+
// The frame of each (its fitted pose) is the end's address frame on the beam (x1.a, x1.b): z out of the end, the
|
|
8
|
+
// part on +z from the end's face at z = 0, x along the beam's top (its section's y), y = z × x. Seen from outside end
|
|
9
|
+
// a the section lies mirrored, so a section's point (sx, sy) is at (sy, sx) at end a and (sy, -sx) at end b. Units: mm,
|
|
10
|
+
// N, grams.
|
|
11
|
+
import jscad from '@jscad/modeling';
|
|
12
|
+
import { hole, counterbore, nutPocket, thread as printedThread, fixingModel, engagement, DEFAULTS as FIX, nutModel } from '@rulecad/fixings';
|
|
13
|
+
import { FITTING_DEFAULTS, options, profileOf, roundConcave, ccw, combine, screwOf } from './fitting.mjs';
|
|
14
|
+
import { partSetup, loadOk, weigh, closingFindings, bendMargin } from './panel.mjs';
|
|
15
|
+
import { JOIN_TAP } from './join.mjs';
|
|
16
|
+
|
|
17
|
+
const { polygon, cylinder } = jscad.primitives, { extrudeLinear } = jscad.extrusions, { union } = jscad.booleans, { hull } = jscad.hulls;
|
|
18
|
+
const { translate, transform } = jscad.transforms, { offset } = jscad.expansions;
|
|
19
|
+
const CHECKED = '2026-11-17';
|
|
20
|
+
const isNum = (x) => typeof x === 'number' && Number.isFinite(x);
|
|
21
|
+
const shown = (v) => { const s = v === undefined ? 'nothing' : JSON.stringify(v) ?? String(v); return s.length > 80 ? `${s.slice(0, 77)}...` : s; };
|
|
22
|
+
const mm = (x) => String(+Number(x).toFixed(2));
|
|
23
|
+
const r3 = (x) => +x.toFixed(3);
|
|
24
|
+
const an = (t) => `${/^(M|[aeiou8])/i.test(String(t)) ? 'an' : 'a'} ${t}`; // (an M5, a 6-32)
|
|
25
|
+
const up = (x, step) => Math.ceil(x / step - 1e-9) * step;
|
|
26
|
+
const finding = (level, text, code, extra = {}) => ({ level, text, code, ...extra });
|
|
27
|
+
const rule = (value, unit, text, kind, source) => ({ value, ...(unit ? { unit } : {}), rule: text, kind, source, checked: CHECKED });
|
|
28
|
+
const prism = (loop, h) => extrudeLinear({ height: h }, polygon({ points: ccw(loop) }));
|
|
29
|
+
const short = (p) => p.name.replace(/^profile-/, '');
|
|
30
|
+
|
|
31
|
+
/** The working figures of the end parts, each with what it rests on. */
|
|
32
|
+
export const END_DEFAULTS = {
|
|
33
|
+
cap: rule(2, 'mm', 'An end cap\'s plate is this thick', 'default', 'A working figure of @rulecad/frames: ten layers, stiff enough to push on by hand'),
|
|
34
|
+
plug: rule(5, 'mm', 'How far an end cap\'s pegs reach into the slots and the bore', 'estimate', 'A working figure of @rulecad/frames, to be checked by a test print'),
|
|
35
|
+
root: rule(0.4, 'mm', 'A peg\'s root is chamfered this much at 45°, so it has no square inside corner', 'default', 'A working figure of @rulecad/frames: the printer\'s chamfer (x1c.chamfer)'),
|
|
36
|
+
rim: rule(2, 'mm', 'A foot reaches this far past the beam\'s outline each way', 'default', 'A working figure of @rulecad/frames'),
|
|
37
|
+
load: rule(250, 'N', 'The design load on one foot or castor where none is given: a quarter of a 100 kg machine with some over', 'default', 'A working figure of @rulecad/frames, so every foot is sized and compared at one named load'),
|
|
38
|
+
stud: rule('M12', '', 'A printed levelling foot\'s thread: coarse enough to print well and to turn by hand', 'default', 'A working figure of @rulecad/frames: @rulecad/fixings prints threads of M6 and over'),
|
|
39
|
+
range: rule(10, 'mm', 'How far a levelling foot\'s pad screws in and out', 'default', 'A working figure of @rulecad/frames'),
|
|
40
|
+
engage: rule(1, '× diameter', 'A levelling foot\'s pad keeps at least this much of its thread engaged at its lowest', 'estimate', 'A working figure of @rulecad/frames: a printed thread\'s engagement'),
|
|
41
|
+
socket: rule(5, 'mm', 'How deep a stacking foot\'s socket goes over the end of the beam below', 'default', 'A working figure of @rulecad/frames'),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// The end's place of a section's point
|
|
45
|
+
const toEnd = (end) => (end === 'b' ? ([sx, sy]) => [sy, -sx] : ([sx, sy]) => [sy, sx]);
|
|
46
|
+
function endSetup(what, profile, o, keys) {
|
|
47
|
+
options(what, o ?? {}, keys);
|
|
48
|
+
const end = o.end ?? 'a';
|
|
49
|
+
if (!['a', 'b'].includes(end)) throw new Error(`${what}: end is a or b, the beam's end it goes on (got ${shown(o.end)})`);
|
|
50
|
+
const p = profileOf(what, profile, o.given ?? {}), k = partSetup(what, o);
|
|
51
|
+
const rect = (m, rad) => { const hw = p.width / 2 + m, hh = p.height / 2 + m, map = toEnd(end); return roundRect([[-hw, -hh], [hw, hh]], rad).map(map); };
|
|
52
|
+
return { end, p, k, rect, map: toEnd(end) };
|
|
53
|
+
}
|
|
54
|
+
// A rectangle [lo, hi] with its corners rounded r, as a loop
|
|
55
|
+
function roundRect([[x0, y0], [x1, y1]], r, n = 6) {
|
|
56
|
+
if (!(r > 0)) return [[x0, y0], [x1, y0], [x1, y1], [x0, y1]];
|
|
57
|
+
const out = [], cs = [[x1 - r, y0 + r, -Math.PI / 2], [x1 - r, y1 - r, 0], [x0 + r, y1 - r, Math.PI / 2], [x0 + r, y0 + r, Math.PI]];
|
|
58
|
+
for (const [cx, cy, a0] of cs) for (let i = 0; i <= n; i++) { const a = a0 + (i / n) * (Math.PI / 2); out.push([cx + r * Math.cos(a), cy + r * Math.sin(a)]); }
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
// The end's tapped bore: refused by name where the profile has none
|
|
62
|
+
function boreOf(what, p) {
|
|
63
|
+
const b = (p.bores ?? []).find((x) => x.thread);
|
|
64
|
+
if (!b) throw new Error(`${what}: ${p.name} has no bore with a thread in its end, so nothing screws into it: an end cap pushes in, or a bracket holds the end`);
|
|
65
|
+
if ((p.bores ?? []).filter((x) => x.thread).length > 1) throw new Error(`${what}: ${p.name} has ${p.bores.length} end bores: a foot is drawn for one in the middle`);
|
|
66
|
+
return b;
|
|
67
|
+
}
|
|
68
|
+
// The screw into the end's bore through a floor f thick: the shortest sold that engages the aluminium as fixings asks
|
|
69
|
+
// and stops short of a tap as deep as a join's (JOIN_TAP)
|
|
70
|
+
function endScrew(thread, f) {
|
|
71
|
+
const fx = fixingModel(thread), need = engagement(thread, { depth: 1, material: 'aluminium' }).need, tap = r3(need + FIX.tip_room.value + JOIN_TAP.value * fx.major);
|
|
72
|
+
const L = [...(fx.figures.lengths?.value ?? [])].sort((a, b) => a - b).find((x) => x >= f + need - 1e-9 && x <= f + tap + 1e-9) ?? null;
|
|
73
|
+
return { thread: fx.thread, need: r3(need), tap, length: L };
|
|
74
|
+
}
|
|
75
|
+
// A peg's root: a 45° chamfer r round its foot (a hull of the peg's outline grown by r at z0 and the outline at z0 + r)
|
|
76
|
+
function rooted(loop, h, r, z0 = 0) {
|
|
77
|
+
const g = polygon({ points: ccw(loop) }), wide = offset({ delta: r, corners: 'chamfer' }, g);
|
|
78
|
+
const slab = (s, z) => translate([0, 0, z], extrudeLinear({ height: 0.01 }, s));
|
|
79
|
+
return union(translate([0, 0, z0], extrudeLinear({ height: h }, g)), hull(slab(wide, z0), slab(g, z0 + r)));
|
|
80
|
+
}
|
|
81
|
+
function ending(m, k, fits) {
|
|
82
|
+
if (fits) m.findings.unshift(finding(fits.length ? 'pass' : 'warn', fits.length ? `${fits.thread}x${fits.length} cap into the end's tapped bore: through ${mm(fits.floor)} mm of floor, ${mm(fits.need)} mm or more into the aluminium, inside a tap ${mm(fits.tap)} mm deep (the beam's end is tapped ${fits.thread} that deep: a tap op at its bore)` : `no ${fits.thread} cap screw sold reaches ${mm(fits.need)} mm into the tapped end and stops inside a ${mm(fits.tap)} mm tap: the fasten check chooses`, 'fitting.screw', { values: { length: fits.length, need: fits.need, tap: fits.tap, floor: fits.floor } }));
|
|
83
|
+
void k;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ---------- an end cap ----------
|
|
87
|
+
/**
|
|
88
|
+
* A printed end cap: a plate the size of the beam's outline, pegs pushed into each slot's opening and into the end's
|
|
89
|
+
* bore, their roots chamfered. It prints plate down, pegs up. @param {string | object} profile
|
|
90
|
+
* @param {{ end?: 'a' | 'b', thickness?: number, printer?: object, material?: string | object, given?: object }} [o]
|
|
91
|
+
* @returns {object} its model
|
|
92
|
+
*/
|
|
93
|
+
export function endCapModel(profile, o = {}) {
|
|
94
|
+
const what = 'endCapModel', { end, p, k, rect, map } = endSetup(what, profile, o, ['end', 'thickness', 'printer', 'material', 'given']);
|
|
95
|
+
const t = o.thickness ?? END_DEFAULTS.cap.value;
|
|
96
|
+
if (!(isNum(t) && t >= 2 * k.layer)) throw new Error(`${what}: thickness is the plate's, in mm, two layers or more (got ${shown(o.thickness)})`);
|
|
97
|
+
const pegs = [];
|
|
98
|
+
for (const face of ['top', 'bottom', 'front', 'back']) for (const pl of p.faces[face] ?? []) {
|
|
99
|
+
if (!pl.slot) continue;
|
|
100
|
+
const s = p.slots[pl.slot], a = s.opening / 2 - k.fit, n0 = -(s.lip), n1 = -k.fit, P = (u, v) => [pl.at[0] + pl.along[0] * u + pl.normal[0] * v, pl.at[1] + pl.along[1] * u + pl.normal[1] * v];
|
|
101
|
+
if (a > k.line && s.lip > 2 * k.fit) pegs.push({ slot: pl.slot, loop: [P(-a, n0), P(a, n0), P(a, n1), P(-a, n1)].map(map) });
|
|
102
|
+
}
|
|
103
|
+
for (const b of p.bores ?? []) pegs.push({ bore: true, loop: Array.from({ length: 24 }, (_, i) => { const r = b.diameter / 2 - k.fit / 2, q = (i / 24) * 2 * Math.PI; return [b.at[0] + r * Math.cos(q), b.at[1] + r * Math.sin(q)]; }).map(map) });
|
|
104
|
+
const m = { kind: 'fitting', fitting: 'end-cap', name: `end-cap-${short(p)}`, title: `printed end cap for ${short(p)}`, profile: p.name, end, thickness: t, plug: END_DEFAULTS.plug.value, outline: rect(-k.fit / 2, Math.max(0, (p.cornerRadius ?? 0))), pegs,
|
|
105
|
+
screws: [], load: { force: 0, what: 'none: it is pushed on' }, stress: 0, margin: Infinity, size: { thickness: t, pegs: pegs.length, plug: END_DEFAULTS.plug.value }, volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [],
|
|
106
|
+
rests: ['cap', 'plug', 'root'].map((x) => ({ name: `END_DEFAULTS.${x}`, value: END_DEFAULTS[x].value, kind: END_DEFAULTS[x].kind })) };
|
|
107
|
+
weigh(m, endCap(m), k.density);
|
|
108
|
+
m.findings.push(finding('info', `${m.title}: a ${mm(t)} mm plate the beam's outline less half the fit, ${pegs.filter((x) => x.slot).length} pegs ${mm(m.plug)} mm into the slots' openings and ${pegs.some((x) => x.bore) ? 'one into the bore' : 'no bore'}, each the opening less the fit (an estimate of a push fit: try one)`, 'fitting.size', { values: { ...m.size } }));
|
|
109
|
+
m.findings.push(finding('info', 'it is drawn to print plate down, its pegs up, their roots chamfered 45°: a plain first layer, no supports', 'fitting.printable', { values: { pose: 'plate down' } }));
|
|
110
|
+
m.findings.push(finding('info', `it weighs ${mm(m.grams)} g of ${m.material} (${mm(m.volume)} mm³)`, 'fitting.mass', { values: { grams: m.grams, volume: m.volume } }));
|
|
111
|
+
return m;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* An end cap's solid: plate down, pegs up to print (pose 'print'), or fitted on the end (pose 'fit'), its pegs into
|
|
115
|
+
* the beam; `tongues: false` leaves the pegs off (the plate alone, as an overlap check measures it, since the pegs
|
|
116
|
+
* stand inside the beam's envelope). @param {object} m @param {{ pose?: 'print' | 'fit', tongues?: boolean }} [o] @returns {object}
|
|
117
|
+
*/
|
|
118
|
+
export function endCap(m, o = {}) {
|
|
119
|
+
if (m?.fitting !== 'end-cap') throw new Error(`endCap: give an end cap's model (endCapModel), not ${shown(m)}`);
|
|
120
|
+
const t = m.thickness, flip = (pts) => pts.map(([x, y]) => [x, -y]), pegs = o.tongues === false ? [] : m.pegs;
|
|
121
|
+
const g = union(prism(flip(m.outline), t), ...pegs.map((q) => rooted(flip(q.loop), m.plug, END_DEFAULTS.root.value, t)));
|
|
122
|
+
return Object.assign(o.pose === 'fit' ? transform([1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, t, 1], g) : g, { model: m });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ---------- feet ----------
|
|
126
|
+
// A pad on the end: the outline grown by rim, a counterbore for the screw into the end's bore from its far side
|
|
127
|
+
function padModel(what, kind, profile, o, keys) {
|
|
128
|
+
const { end, p, k, rect, map } = endSetup(what, profile, o, keys), b = boreOf(what, p);
|
|
129
|
+
loadOk(what, o.load, 'the force on the foot, down the beam');
|
|
130
|
+
const F = o.load ?? END_DEFAULTS.load.value, sc = screwOf(what, b.thread, 'cap', k.pr), rim = END_DEFAULTS.rim.value;
|
|
131
|
+
return { end, p, k, rect, map, b, F, sc, rim };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A printed foot under a beam's end: a pad the beam's outline and a rim wider, screwed into the end's tapped bore
|
|
136
|
+
* through a counterbore in its underside. It prints as it stands, the beam's side down. Its margin is the plastic's
|
|
137
|
+
* strength over the bearing stress under the named load.
|
|
138
|
+
* @param {string | object} profile @param {{ end?: 'a' | 'b', load?: number, printer?: object, material?: string | object, given?: object }} [o]
|
|
139
|
+
* @returns {object} its model: screws (into the bore), ops (the tap the beam's end needs)
|
|
140
|
+
*/
|
|
141
|
+
export function footModel(profile, o = {}) {
|
|
142
|
+
const what = 'footModel', s = padModel(what, 'foot', profile, o, ['end', 'load', 'printer', 'material', 'given']), { p, k, b, F, sc, rim } = s;
|
|
143
|
+
const floor = Math.max(up(FITTING_DEFAULTS.least.value * sc.major, k.layer), up(4 * k.layer, k.layer)), sink = up((fixingModel(b.thread).figures.head_height?.value ?? sc.major) + 0.5, k.layer), t = r3(floor + sink);
|
|
144
|
+
const area = (p.width + 2 * rim) * (p.height + 2 * rim) - (Math.PI * (sc.dk + 1) ** 2) / 4, stress = r3(F / area), margin = r3(k.S / stress), fits = { ...endScrew(b.thread, floor), floor };
|
|
145
|
+
const at = s.map(b.at);
|
|
146
|
+
const m = { kind: 'fitting', fitting: 'foot', name: `foot-${short(p)}`, title: `printed foot for ${short(p)}`, profile: p.name, end: s.end, thread: b.thread, thickness: t, floor, sink, rim, outline: s.rect(rim, rim + (p.cornerRadius ?? 0)), bore: at,
|
|
147
|
+
screws: [{ thread: b.thread, head: 'cap', grip: floor, at: [at[0], at[1], floor], axis: [0, 0, -1], into: 'bore', length: fits.length }], ops: [{ op: 'tap', at: s.end, thread: b.thread, depth: fits.tap }],
|
|
148
|
+
load: { force: F, what: `${F} N down the beam onto the floor` }, stress, margin, size: { thickness: t, floor, rim }, volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [],
|
|
149
|
+
rests: [{ name: `${k.mat.name}.strength`, value: k.S }, ...['rim', 'load'].map((x) => ({ name: `END_DEFAULTS.${x}`, value: END_DEFAULTS[x].value, kind: END_DEFAULTS[x].kind }))] };
|
|
150
|
+
weigh(m, foot(m, { printer: k.pr }), k.density);
|
|
151
|
+
ending(m, k, fits);
|
|
152
|
+
closingFindings(m, { S: k.S, sizeText: `${mm(t)} mm thick (a ${mm(floor)} mm floor under a ${mm(sink)} mm counterbore for the head), ${mm(rim)} mm past the beam each way`, marginText: `under ${m.load.what}, it bears at ${mm(stress)} MPa`, pose: 'as it stands, the beam\'s side down, its counterbore opening up' });
|
|
153
|
+
return m;
|
|
154
|
+
}
|
|
155
|
+
/** A foot's solid, as it prints and as it is fitted (the same pose). @param {object} m @param {{ printer?: object, pose?: string }} [o] @returns {object} */
|
|
156
|
+
export function foot(m, o = {}) {
|
|
157
|
+
if (m?.fitting !== 'foot') throw new Error(`foot: give a foot's model (footModel), not ${shown(m)}`);
|
|
158
|
+
const pr = o.printer, cb = counterbore(m.thread, { head: 'cap', depth: m.sink + 0.01, length: m.thickness + 2, into: '-z', at: [m.bore[0], m.bore[1], m.thickness], ...(pr ? { printer: pr } : {}) });
|
|
159
|
+
return Object.assign(combine([prism(m.outline, m.thickness)], [cb], o.ops), { model: m });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A printed levelling foot: a body screwed to the end's tapped bore, and a pad that screws up and down in it, on a
|
|
164
|
+
* printed thread (stud 'printed', default, M12 from @rulecad/fixings' threads) or a bought levelling foot's stud held
|
|
165
|
+
* in a hex nut sunk in the body (stud: its thread, as 'M8'). The body's screw goes in first, through the stud's bore.
|
|
166
|
+
* Both parts print as they stand, threads upright.
|
|
167
|
+
* @param {string | object} profile @param {{ end?: 'a' | 'b', stud?: string, range?: number, load?: number, printer?: object, material?: string | object, given?: object }} [o]
|
|
168
|
+
* @returns {object} its model: parts body and pad (or the bought stud), range, screws, ops
|
|
169
|
+
*/
|
|
170
|
+
export function levellingFootModel(profile, o = {}) {
|
|
171
|
+
const what = 'levellingFootModel', s = padModel(what, 'levelling', profile, o, ['end', 'stud', 'range', 'load', 'printer', 'material', 'given']), { p, k, b, F, sc } = s;
|
|
172
|
+
const printed = o.stud == null || o.stud === 'printed', stud = printed ? END_DEFAULTS.stud.value : o.stud, range = o.range ?? END_DEFAULTS.range.value;
|
|
173
|
+
if (!(isNum(range) && range > 0 && range <= 40)) throw new Error(`${what}: range is how far the pad screws in and out, in mm, above 0 and up to 40 (got ${shown(o.range)})`);
|
|
174
|
+
let st; try { st = fixingModel(stud); } catch (e) { throw new Error(`${what}: stud is 'printed' or a bought foot's thread, as 'M8' (got ${shown(o.stud)}): ${String(e.message).replace(/^\w+: /, '')}`); }
|
|
175
|
+
const head = fixingModel(b.thread).figures.head_height?.value ?? sc.major;
|
|
176
|
+
if (st.major * 0.8 < sc.dk + 2 * k.fit && printed) throw new Error(`${what}: an ${stud} stud's bore is too small for ${b.thread}'s ${mm(sc.dk)} mm head to pass: a coarser stud`);
|
|
177
|
+
const floor = up(Math.max(FITTING_DEFAULTS.least.value * sc.major, 4 * k.layer), k.layer), well = up(head + 0.5, k.layer), engage = r3(END_DEFAULTS.engage.value * st.major);
|
|
178
|
+
const nutH = printed ? 0 : nutModel(stud).height, threadLen = r3(engage + range), height = r3(floor + well + threadLen + (printed ? 0 : 0)), wall = up(3 * k.line, 0.1) * 2;
|
|
179
|
+
const across = r3(Math.max(Math.min(p.width, p.height), st.major + 2 * wall + (printed ? 0 : st.major * 0.8))), pad = r3(across + 2 * s.rim);
|
|
180
|
+
const fits = { ...endScrew(b.thread, floor), floor }, at = s.map(b.at);
|
|
181
|
+
// the pad's stem in bending at its root under a side push of a tenth of the load, as on uneven ground
|
|
182
|
+
// printed: the pad's stem bent at its root by a side push of a tenth of the load, as on uneven ground; bought (a steel
|
|
183
|
+
// stud): the body's floor bearing the load
|
|
184
|
+
const side = F / 10, root = st.major * 0.8, stress = r3(printed ? (32 * side * threadLen) / (Math.PI * root ** 3) : F / ((Math.PI / 4) * (across ** 2 - (st.major + 0.6) ** 2))), margin = r3(k.S / stress);
|
|
185
|
+
const m = { kind: 'fitting', fitting: 'levelling-foot', name: `levelling-foot-${short(p)}-${printed ? `printed-${stud.toLowerCase()}` : stud.toLowerCase()}`, title: `printed levelling foot for ${short(p)}, ${printed ? `a printed ${stud} thread` : `a bought ${stud} stud`}`,
|
|
186
|
+
profile: p.name, end: s.end, thread: b.thread, stud, printed, range, engage, floor, well, height: r3(floor + well + threadLen + (printed ? 0 : nutH)), across, pad, bore: at, nut: printed ? null : nutModel(stud).name,
|
|
187
|
+
parts: printed ? ['body', 'pad'] : ['body'], screws: [{ thread: b.thread, head: 'cap', grip: floor, at: [at[0], at[1], floor], axis: [0, 0, -1], into: 'bore', length: fits.length }], ops: [{ op: 'tap', at: s.end, thread: b.thread, depth: fits.tap }],
|
|
188
|
+
hardware: printed ? [] : [{ kind: 'nut', name: nutModel(stud).name, thread: stud, count: 1 }, { kind: 'foot', name: `a levelling foot on an ${stud} stud`, thread: stud, count: 1 }],
|
|
189
|
+
load: { force: F, what: printed ? `${F} N down the foot, and a tenth of it across the pad's stem` : `${F} N down the stud's nut onto the body` }, stress, margin, size: { height: r3(floor + well + threadLen + nutH), range, across }, volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [],
|
|
190
|
+
rests: [{ name: `${k.mat.name}.strength`, value: k.S }, ...['stud', 'range', 'engage', 'load'].map((x) => ({ name: `END_DEFAULTS.${x}`, value: END_DEFAULTS[x].value, kind: END_DEFAULTS[x].kind }))] };
|
|
191
|
+
weigh(m, levellingFoot(m, { printer: k.pr }), k.density);
|
|
192
|
+
if (printed) { const pg = levellingFoot(m, { part: 'pad', printer: k.pr }); m.padGrams = r3((jscad.measurements.measureVolume(pg) * k.density) / 1000); m.grams = r3(m.grams + m.padGrams); }
|
|
193
|
+
ending(m, k, fits);
|
|
194
|
+
closingFindings(m, { S: k.S, sizeText: `a body ${mm(across)} mm across and ${mm(floor + well + (printed ? threadLen : nutH + range))} mm high, ${printed ? `its ${stud} thread printed, the pad's stem ${mm(threadLen)} mm: ${mm(range)} mm of travel with ${mm(engage)} mm always engaged` : `an ${stud} nut sunk in its top for the bought foot's stud`}`, marginText: `under ${m.load.what}, ${printed ? 'the stem bends' : 'the body bears'} to ${mm(stress)} MPa`, pose: `as they stand, threads upright${printed ? ', the pad on its foot' : ''}` });
|
|
195
|
+
return m;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A levelling foot's solid: the body (part 'body', default) or the pad (part 'pad'), each as it prints; fitted, the
|
|
199
|
+
* pad sits screwed in at the middle of its range. @param {object} m @param {{ part?: 'body' | 'pad', pose?: 'print' | 'fit', printer?: object }} [o] @returns {object}
|
|
200
|
+
*/
|
|
201
|
+
export function levellingFoot(m, o = {}) {
|
|
202
|
+
if (m?.fitting !== 'levelling-foot') throw new Error(`levellingFoot: give a levelling foot's model (levellingFootModel), not ${shown(m)}`);
|
|
203
|
+
const part = o.part ?? 'body', pr = o.printer, fx = pr ? { printer: pr } : {}, [cx, cy] = m.bore, R = m.across / 2;
|
|
204
|
+
if (!['body', 'pad'].includes(part) || (part === 'pad' && !m.printed)) throw new Error(`levellingFoot: part is body${m.printed ? ' or pad' : ''} (got ${shown(o.part)})`);
|
|
205
|
+
const st = fixingModel(m.stud), body = m.floor + m.well + (m.printed ? m.engage + m.range : nutModel(m.stud).height + m.range);
|
|
206
|
+
if (part === 'body') {
|
|
207
|
+
const outer = translate([cx, cy, 0], cylinder({ radius: R, height: body, center: [0, 0, body / 2], segments: 48 }));
|
|
208
|
+
const cuts = [counterbore(m.thread, { head: 'cap', depth: m.well + 0.01, diameter: st.major * 0.8, length: m.floor + m.well + 2, into: '-z', at: [cx, cy, m.floor + m.well], ...fx })];
|
|
209
|
+
if (m.printed) cuts.push(translate([cx, cy, m.floor + m.well], printedThread(m.stud, { length: body - m.floor - m.well, internal: true, ...fx })));
|
|
210
|
+
else cuts.push(nutPocket(m.stud, { at: [cx, cy, body], into: '-z', ...fx }), translate([cx, cy, m.floor + m.well - 0.01], cylinder({ radius: st.major / 2 + 0.3, height: body, center: [0, 0, body / 2], segments: 32 })));
|
|
211
|
+
return Object.assign(combine([outer], cuts, o.ops), { model: m });
|
|
212
|
+
}
|
|
213
|
+
const foot = cylinder({ radius: m.pad / 2, height: 4, center: [0, 0, 2], segments: 48 }), chamfer = hull(translate([0, 0, 4], cylinder({ radius: m.pad / 2, height: 0.01, segments: 48 })), translate([0, 0, 4 + (m.pad - st.major) / 2 * 0.5], cylinder({ radius: st.major / 2, height: 0.01, segments: 48 })));
|
|
214
|
+
const stem = translate([0, 0, 4], printedThread(m.stud, { length: m.engage + m.range, ...fx }));
|
|
215
|
+
const g = union(foot, chamfer, stem);
|
|
216
|
+
return Object.assign(o.pose === 'fit' ? transform([1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, cx, cy, body + m.range / 2 + 4, 1], g) : g, { model: m });
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* A printed castor plate: a plate under a beam's end that a castor's top plate bolts to, screwed into the end's tapped
|
|
221
|
+
* bore through a counterbore on its castor side. The castor's holes are given (its maker's drawing): they must lie
|
|
222
|
+
* outside the beam's outline by a head, so the bolts' heads sit on the plate's top beside the beam and the nuts under
|
|
223
|
+
* the castor's plate. Sized from the named load, half of it on each pair of bolts, bending the plate from the beam's
|
|
224
|
+
* edge. It prints its beam side down.
|
|
225
|
+
* @param {string | object} profile @param {{ holes: number[], thread: string, end?: 'a' | 'b', load?: number, printer?: object, material?: string | object, given?: object }} o
|
|
226
|
+
* holes: [x, y] the castor's hole spacing, from its maker's drawing; thread: its bolts'
|
|
227
|
+
* @returns {object} its model
|
|
228
|
+
*/
|
|
229
|
+
export function castorPlateModel(profile, o = {}) {
|
|
230
|
+
const what = 'castorPlateModel', s = padModel(what, 'castor', profile, o ?? {}, ['holes', 'thread', 'end', 'load', 'printer', 'material', 'given']), { p, k, b, F, sc } = s;
|
|
231
|
+
if (!(Array.isArray(o.holes) && o.holes.length === 2 && o.holes.every((x) => isNum(x) && x > 0))) throw new Error(`${what}: holes is the castor's hole spacing [x, y] in mm, from its maker's drawing (got ${shown(o.holes)})`);
|
|
232
|
+
if (typeof o.thread !== 'string') throw new Error(`${what}: thread is the castor's bolts', as 'M6' (got ${shown(o.thread)})`);
|
|
233
|
+
const bolt = screwOf(what, o.thread, 'cap', k.pr), [hx, hy] = o.holes.map((x) => x / 2), half = Math.max(p.width, p.height) / 2;
|
|
234
|
+
const need = half + bolt.dk / 2 + FITTING_DEFAULTS.reach.value;
|
|
235
|
+
if (Math.min(hx, hy) < need - 1e-9) throw new Error(`${what}: the castor's holes ${mm(o.holes[0])} x ${mm(o.holes[1])} mm apart lie ${mm(Math.min(hx, hy))} mm from the middle, under the beam's outline and ${an(o.thread)} head (${mm(need)} mm): its bolts' heads would sit under the beam. A castor with wider holes, or a plate between`);
|
|
236
|
+
const endBy = Math.max(FITTING_DEFAULTS.end.value * bolt.hd, bolt.dk / 2 + FITTING_DEFAULTS.reach.value), X = r3(hx + endBy), Y = r3(hy + endBy);
|
|
237
|
+
const M = (F / 2) * (Math.min(hx, hy) - half), width = 2 * Math.max(X, Y), head = fixingModel(b.thread).figures.head_height?.value ?? sc.major;
|
|
238
|
+
const sink = up(head + 0.5, k.layer), floor = Math.max(up(FITTING_DEFAULTS.least.value * sc.major, k.layer), up(Math.sqrt((6 * M * FITTING_DEFAULTS.margin.value) / (width * k.S)), k.layer));
|
|
239
|
+
const t = r3(floor + sink), stress = r3((6 * M) / (width * t * t)), margin = r3(bendMargin(M, width, t, k.S)), fits = { ...endScrew(b.thread, floor), floor }, at = s.map(b.at);
|
|
240
|
+
const corners = [[hx, hy], [-hx, hy], [-hx, -hy], [hx, -hy]];
|
|
241
|
+
const m = { kind: 'fitting', fitting: 'castor-plate', name: `castor-plate-${short(p)}-${mm(o.holes[0])}x${mm(o.holes[1])}-${o.thread.toLowerCase()}`, title: `printed castor plate for ${short(p)}, castor holes ${mm(o.holes[0])} x ${mm(o.holes[1])} mm, ${o.thread}`,
|
|
242
|
+
profile: p.name, end: s.end, thread: b.thread, bolt: o.thread, holes: o.holes, thickness: t, floor, sink, outline: roundRect([[-X, -Y], [X, Y]], 2), bore: at,
|
|
243
|
+
screws: [{ thread: b.thread, head: 'cap', grip: floor, at: [at[0], at[1], 0], axis: [0, 0, 1], into: 'bore', length: fits.length }, ...corners.map(([x, y]) => ({ thread: o.thread, head: 'cap', grip: t, at: [x, y, 0], axis: [0, 0, 1], into: 'castor' }))],
|
|
244
|
+
ops: [{ op: 'tap', at: s.end, thread: b.thread, depth: fits.tap }], load: { force: F, what: `${F} N up the castor, half on each pair of its bolts, ${mm(Math.min(hx, hy) - half)} mm past the beam's edge` }, stress, margin, size: { thickness: t, x: 2 * X, y: 2 * Y },
|
|
245
|
+
volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [], rests: [{ name: `${k.mat.name}.strength`, value: k.S }, { name: 'END_DEFAULTS.load', value: END_DEFAULTS.load.value, kind: END_DEFAULTS.load.kind }] };
|
|
246
|
+
weigh(m, castorPlate(m, { printer: k.pr }), k.density);
|
|
247
|
+
// (its screw into the end goes in from the castor's side, before the castor)
|
|
248
|
+
ending(m, k, fits);
|
|
249
|
+
closingFindings(m, { S: k.S, sizeText: `${mm(2 * X)} x ${mm(2 * Y)} mm, ${mm(t)} mm thick, a counterbore ${mm(sink)} mm deep on its castor side for the screw into the end, four ${o.thread} holes for the castor`, marginText: `under ${m.load.what}, it bends at the beam's edge to ${mm(stress)} MPa`, pose: 'its beam side down, the counterbore opening up' });
|
|
250
|
+
return m;
|
|
251
|
+
}
|
|
252
|
+
/** A castor plate's solid: beam side down to print; fitted, on the end with its castor side out. @param {object} m @param {{ pose?: 'print' | 'fit', printer?: object }} [o] @returns {object} */
|
|
253
|
+
export function castorPlate(m, o = {}) {
|
|
254
|
+
if (m?.fitting !== 'castor-plate') throw new Error(`castorPlate: give a castor plate's model (castorPlateModel), not ${shown(m)}`);
|
|
255
|
+
const pr = o.printer ? { printer: o.printer } : {}, t = m.thickness, [hx, hy] = m.holes.map((x) => x / 2);
|
|
256
|
+
const cuts = [counterbore(m.thread, { head: 'cap', depth: m.sink + 0.01, length: t + 2, into: '-z', at: [m.bore[0], m.bore[1], t], ...pr }), ...[[hx, hy], [-hx, hy], [-hx, -hy], [hx, -hy]].map(([x, y]) => hole(m.bolt, { kind: 'clearance', into: '-z', depth: t + 2, at: [x, y, t + 1], ...pr }))];
|
|
257
|
+
return Object.assign(combine([prism(m.outline, t)], cuts, o.ops), { model: m });
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* A printed stacking foot: a plate on a beam's end, screwed into its tapped bore, with a socket under it that fits
|
|
262
|
+
* over the end of a beam of the same profile below, so one frame stands on another. Its socket's corners are rounded
|
|
263
|
+
* as the beam's, with the fit. It prints its beam side down, the socket up.
|
|
264
|
+
* @param {string | object} profile @param {{ end?: 'a' | 'b', depth?: number, load?: number, printer?: object, material?: string | object, given?: object }} [o]
|
|
265
|
+
* @returns {object} its model
|
|
266
|
+
*/
|
|
267
|
+
export function stackingFootModel(profile, o = {}) {
|
|
268
|
+
const what = 'stackingFootModel', s = padModel(what, 'stacking', profile, o ?? {}, ['end', 'depth', 'load', 'printer', 'material', 'given']), { p, k, b, F, sc } = s;
|
|
269
|
+
const depth = o.depth ?? END_DEFAULTS.socket.value;
|
|
270
|
+
if (!(isNum(depth) && depth > 0)) throw new Error(`${what}: depth is the socket's, in mm, above 0 (got ${shown(o.depth)})`);
|
|
271
|
+
const head = fixingModel(b.thread).figures.head_height?.value ?? sc.major, wall = up(3 * k.line, 0.1), floor = up(Math.max(FITTING_DEFAULTS.least.value * sc.major, 4 * k.layer), k.layer), sink = up(head + 0.5, k.layer);
|
|
272
|
+
const t = r3(floor + sink + depth), fits = { ...endScrew(b.thread, floor), floor }, at = s.map(b.at);
|
|
273
|
+
const area = 2 * (p.width + p.height + 4 * k.fit) * wall, stress = r3(F / ((p.width + 2 * wall) * (p.height + 2 * wall) - Math.PI * (sc.dk / 2 + 0.5) ** 2)), margin = r3(k.S / stress);
|
|
274
|
+
const m = { kind: 'fitting', fitting: 'stacking-foot', name: `stacking-foot-${short(p)}`, title: `printed stacking foot for ${short(p)}`, profile: p.name, end: s.end, thread: b.thread, thickness: t, floor, sink, depth, wall,
|
|
275
|
+
outline: s.rect(k.fit + wall, (p.cornerRadius ?? 0) + k.fit + wall), socket: s.rect(k.fit, (p.cornerRadius ?? 0) + k.fit), bore: at, wallArea: r3(area),
|
|
276
|
+
screws: [{ thread: b.thread, head: 'cap', grip: floor, at: [at[0], at[1], floor], axis: [0, 0, -1], into: 'bore', length: fits.length }], ops: [{ op: 'tap', at: s.end, thread: b.thread, depth: fits.tap }],
|
|
277
|
+
load: { force: F, what: `${F} N of the frame above on the beam below, through the floor` }, stress, margin, size: { thickness: t, depth, wall }, volume: 0, grams: 0, material: k.mat.name, printer: k.pr.name, findings: [],
|
|
278
|
+
rests: [{ name: `${k.mat.name}.strength`, value: k.S }, ...['socket', 'load'].map((x) => ({ name: `END_DEFAULTS.${x}`, value: END_DEFAULTS[x].value, kind: END_DEFAULTS[x].kind }))] };
|
|
279
|
+
weigh(m, stackingFoot(m, { printer: k.pr }), k.density);
|
|
280
|
+
ending(m, k, fits);
|
|
281
|
+
closingFindings(m, { S: k.S, sizeText: `${mm(t)} mm thick: a ${mm(floor)} mm floor, a ${mm(sink)} mm counterbore for the head, a socket ${mm(depth)} mm deep the beam's outline and the fit, its wall ${mm(wall)} mm`, marginText: `under ${m.load.what}, it bears at ${mm(stress)} MPa`, pose: 'its beam side down, the socket up' });
|
|
282
|
+
return m;
|
|
283
|
+
}
|
|
284
|
+
/** A stacking foot's solid: beam side down to print, as it is fitted. @param {object} m @param {{ printer?: object }} [o] @returns {object} */
|
|
285
|
+
export function stackingFoot(m, o = {}) {
|
|
286
|
+
if (m?.fitting !== 'stacking-foot') throw new Error(`stackingFoot: give a stacking foot's model (stackingFootModel), not ${shown(m)}`);
|
|
287
|
+
const pr = o.printer ? { printer: o.printer } : {}, t = m.thickness;
|
|
288
|
+
const cuts = [translate([0, 0, t - m.depth], prism(m.socket, m.depth + 1)), counterbore(m.thread, { head: 'cap', depth: m.sink + 0.01, length: m.floor + m.sink + 2, into: '-z', at: [m.bore[0], m.bore[1], m.floor + m.sink], ...pr })];
|
|
289
|
+
return Object.assign(combine([prism(m.outline, t)], cuts, o.ops), { model: m });
|
|
290
|
+
}
|
package/fitting.d.mts
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/** @internal A face's slot, its cell, its nuts' thread and a tongue's room. @param {string} what @param {any} p @param {any} face @param {any} thread @param {any} nut @param {number} fit @param {any} given @returns {any} */
|
|
2
|
+
export function slotSide(what: string, p: any, face: any, thread: any, nut: any, fit: number, given: any): any;
|
|
3
|
+
/** @internal A loop's concave corners rounded by r. @param {number[][]} loop @param {number} r @param {any} [only] @param {number} [steps] @returns {number[][]} */
|
|
4
|
+
export function roundConcave(loop: number[][], r: number, only?: any, steps?: number): number[][];
|
|
5
|
+
/** @internal A tongue's section. @param {number} a0 @param {number} a1 @param {number} depth @param {boolean} lean @param {number} root @param {number} [sink] @returns {number[][]} */
|
|
6
|
+
export function tongueLoop(a0: number, a1: number, depth: number, lean: boolean, root: number, sink?: number): number[][];
|
|
7
|
+
/**
|
|
8
|
+
* A fitting bent by its load, by finite elements on cubes (@rulecad/fea): cells in the part where inside() holds at
|
|
9
|
+
* their sample points, held where held() holds, the force shared over the nodes where loaded() holds. Read: the
|
|
10
|
+
* loaded nodes' mean movement along the force, and the peak von Mises stress away from the screws (the clamp's own
|
|
11
|
+
* edge is where the model, not the part, is stiff), lifted from a cell's centre to the surface.
|
|
12
|
+
* @param {{ box: { lo: number[], hi: number[] }, inside: (p: number[]) => boolean, held: (p: number[]) => boolean, loaded: (p: number[]) => boolean, near: (p: number[]) => boolean,
|
|
13
|
+
* force: number[], thin: number, E: number, nu: number, key: string, budget?: number, cache?: { get: (k: string) => any, set: (k: string, v: any) => void } }} o
|
|
14
|
+
* @returns {{ deflection: number, stress: number, cell: number, across: number, cells: number }}
|
|
15
|
+
*/
|
|
16
|
+
export function fittingFE(o: {
|
|
17
|
+
box: {
|
|
18
|
+
lo: number[];
|
|
19
|
+
hi: number[];
|
|
20
|
+
};
|
|
21
|
+
inside: (p: number[]) => boolean;
|
|
22
|
+
held: (p: number[]) => boolean;
|
|
23
|
+
loaded: (p: number[]) => boolean;
|
|
24
|
+
near: (p: number[]) => boolean;
|
|
25
|
+
force: number[];
|
|
26
|
+
thin: number;
|
|
27
|
+
E: number;
|
|
28
|
+
nu: number;
|
|
29
|
+
key: string;
|
|
30
|
+
budget?: number;
|
|
31
|
+
cache?: {
|
|
32
|
+
get: (k: string) => any;
|
|
33
|
+
set: (k: string, v: any) => void;
|
|
34
|
+
};
|
|
35
|
+
}): {
|
|
36
|
+
deflection: number;
|
|
37
|
+
stress: number;
|
|
38
|
+
cell: number;
|
|
39
|
+
across: number;
|
|
40
|
+
cells: number;
|
|
41
|
+
};
|
|
42
|
+
/** @internal The least thickness from t at which every side takes a sold screw. @param {number} t @param {number} step @param {any[]} sides @param {string} thread @returns {any} */
|
|
43
|
+
export function sold(t: number, step: number, sides: any[], thread: string): any;
|
|
44
|
+
/** @internal A screw's head and hole figures. @param {string} what @param {string} thread @param {string} head @param {any} pr @returns {any} */
|
|
45
|
+
export function screwOf(what: string, thread: string, head: string, pr: any): any;
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {{ kind: 'fitting', fitting: 'bracket', name: string, title: string, profile: string, other: string, faces: { b: string, a: string }, thread: string, head: string,
|
|
48
|
+
* brace: boolean, width: number, thickness: number, leg: number, screwAt: number, round: number, braceSize: number, hole: number, tongues: { b: object, a: object },
|
|
49
|
+
* screws: { leg: 'b' | 'a', thread: string, head: string, grip: number, at: number[], axis: number[], nut: string }[], load: { force: number, what: string, at: number[], direction: number[] },
|
|
50
|
+
* stiffness: { linear: number, bending: number, kind: string, rule: string }, stress: number, margin: number, deflection: number, fe: object,
|
|
51
|
+
* volume: number, grams: number, material: string, printer: string, section: number[][], findings: object[], rests: object[] }} Bracket
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* A printed corner bracket for a profile, from its rules: the width of the face's cell, the thread its slot nuts are
|
|
55
|
+
* made for, a tongue on each leg that keys into the slot, and legs sized from a named load by finite elements to about
|
|
56
|
+
* twice the margin. Laid on its side it prints without supports, its first layer the whole L.
|
|
57
|
+
* @param {string | object} profile b's profile (the beam whose face the base leg lies on), by name or model
|
|
58
|
+
* @param {{ other?: string | object, face?: string, otherFace?: string, thread?: string, head?: 'cap' | 'button', nut?: string, brace?: boolean, load?: number, width?: number,
|
|
59
|
+
* printer?: object, material?: string | object, given?: object, cache?: object }} [o]
|
|
60
|
+
* other: a's profile, for the upright leg (default the same); face, otherFace: the faces the legs lie on (default top);
|
|
61
|
+
* thread: the screws' (default the largest a slot nut is made for in both slots); head: cap (default) or button; nut: a
|
|
62
|
+
* kind of slot nut, for the tongue's depth (default the tallest tongue of any kind); brace: fill the inside corner with
|
|
63
|
+
* a web; load: the design load in N, across beam a at the upright's screw (default 100); width: across the bracket
|
|
64
|
+
* (default the face's cell); cache: { get, set } for the finite elements' results
|
|
65
|
+
* @returns {Bracket}
|
|
66
|
+
*/
|
|
67
|
+
export function bracketModel(profile: string | object, o?: {
|
|
68
|
+
other?: string | object;
|
|
69
|
+
face?: string;
|
|
70
|
+
otherFace?: string;
|
|
71
|
+
thread?: string;
|
|
72
|
+
head?: "cap" | "button";
|
|
73
|
+
nut?: string;
|
|
74
|
+
brace?: boolean;
|
|
75
|
+
load?: number;
|
|
76
|
+
width?: number;
|
|
77
|
+
printer?: object;
|
|
78
|
+
material?: string | object;
|
|
79
|
+
given?: object;
|
|
80
|
+
cache?: object;
|
|
81
|
+
}): Bracket;
|
|
82
|
+
/**
|
|
83
|
+
* A printed corner bracket's solid, from bracketModel's model or its arguments: laid on its side to print (pose
|
|
84
|
+
* 'print', the default), or in its fitted frame (pose 'fit': x along b's face away from a, y up a, z across, the corner
|
|
85
|
+
* line on the slots' centre). tongues: false leaves them off (the body alone, which may not overlap a beam's envelope);
|
|
86
|
+
* ops: booleans to join and cut with ({ union, subtract }, as @rulecad/shapes' ops gives), JSCAD's where left out.
|
|
87
|
+
* @param {object | string} m a Bracket, or bracketModel's profile @param {object} [o] bracketModel's options, pose, tongues and ops
|
|
88
|
+
* @returns {object} a JSCAD geom3, with .model
|
|
89
|
+
*/
|
|
90
|
+
export function bracket(m: object | string, o?: object): object;
|
|
91
|
+
/**
|
|
92
|
+
* @typedef {{ kind: 'fitting', fitting: 'gusset' | 'splice', shape: string, name: string, title: string, profile: string, face: string, thread: string, head: string,
|
|
93
|
+
* width: number, thickness: number, arm: number, round: number, hole: number, outline: number[][], tongues: object[], screws: { leg: 'b' | 'a', thread: string, head: string, grip: number, at: number[], axis: number[], nut: string }[],
|
|
94
|
+
* load: object, stiffness: object, stress: number, margin: number, deflection: number, fe: object, volume: number, grams: number, material: string, printer: string, findings: object[], rests: object[] }} Plate
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* A printed flat plate over a joint: a gusset (shape L, T or cross) or a splice plate (shape splice), on the faces of
|
|
98
|
+
* beams of one profile that lie in one plane. Each arm runs along a beam's slot with `count` screws into slot nuts and
|
|
99
|
+
* a tongue that keys into the slot; the inside corners are rounded half an arm's width. Sized from the named load (in
|
|
100
|
+
* the plate's plane, across beam a at its farthest screw, b's screws held) by finite elements to about twice the
|
|
101
|
+
* margin. It prints contact face up, its tongues on top.
|
|
102
|
+
* @param {string | object} profile @param {{ shape?: 'L' | 'T' | 'cross' | 'splice', face?: string, thread?: string, head?: 'cap' | 'button', nut?: string, count?: number, load?: number, width?: number,
|
|
103
|
+
* printer?: object, material?: string | object, given?: object, cache?: object }} [o] count: screws on each arm (default 2)
|
|
104
|
+
* @returns {Plate}
|
|
105
|
+
*/
|
|
106
|
+
export function plateModel(profile: string | object, o?: {
|
|
107
|
+
shape?: "L" | "T" | "cross" | "splice";
|
|
108
|
+
face?: string;
|
|
109
|
+
thread?: string;
|
|
110
|
+
head?: "cap" | "button";
|
|
111
|
+
nut?: string;
|
|
112
|
+
count?: number;
|
|
113
|
+
load?: number;
|
|
114
|
+
width?: number;
|
|
115
|
+
printer?: object;
|
|
116
|
+
material?: string | object;
|
|
117
|
+
given?: object;
|
|
118
|
+
cache?: object;
|
|
119
|
+
}): Plate;
|
|
120
|
+
/**
|
|
121
|
+
* A printed plate's solid, from plateModel's model or its arguments: contact face up to print (pose 'print', the
|
|
122
|
+
* default; its frame's z then runs down into the beams, so the plate is turned over), or in its fitted frame (pose
|
|
123
|
+
* 'fit': x along b, y along a, the contact face at z = 0 and the plate on +z, away from the beams). tongues: false leaves
|
|
124
|
+
* them off; ops: booleans to join and cut with, as bracket's.
|
|
125
|
+
* @param {object | string} m a Plate, or plateModel's profile @param {object} [o] plateModel's options, pose, tongues and ops
|
|
126
|
+
* @returns {object} a JSCAD geom3, with .model
|
|
127
|
+
*/
|
|
128
|
+
export function plate(m: object | string, o?: object): object;
|
|
129
|
+
/**
|
|
130
|
+
* The rules the fittings add, each with what it rests on.
|
|
131
|
+
* @type {Record<string, { value: number, unit: string, rule: string, kind: string, source: string, checked: string }>}
|
|
132
|
+
*/
|
|
133
|
+
export const FITTING_DEFAULTS: Record<string, {
|
|
134
|
+
value: number;
|
|
135
|
+
unit: string;
|
|
136
|
+
rule: string;
|
|
137
|
+
kind: string;
|
|
138
|
+
source: string;
|
|
139
|
+
checked: string;
|
|
140
|
+
}>;
|
|
141
|
+
export namespace FITTINGS {
|
|
142
|
+
namespace bracket {
|
|
143
|
+
let what: string;
|
|
144
|
+
let joins: string[];
|
|
145
|
+
}
|
|
146
|
+
namespace gusset {
|
|
147
|
+
let what_1: string;
|
|
148
|
+
export { what_1 as what };
|
|
149
|
+
let joins_1: string[];
|
|
150
|
+
export { joins_1 as joins };
|
|
151
|
+
}
|
|
152
|
+
namespace splice {
|
|
153
|
+
let what_2: string;
|
|
154
|
+
export { what_2 as what };
|
|
155
|
+
let joins_2: string[];
|
|
156
|
+
export { joins_2 as joins };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export function printerOf(what: string, p: any): any;
|
|
160
|
+
export function pfig(pr: any, k: string): number;
|
|
161
|
+
export function materialOf(what: string, m: any): any;
|
|
162
|
+
export function options(what: string, o: any, keys: string[]): void;
|
|
163
|
+
export function profileOf(what: string, p: any, given: any): any;
|
|
164
|
+
export function ccw(pts: number[][]): number[][];
|
|
165
|
+
export function combine(parts: any[], cuts: any[], ops: any): any;
|
|
166
|
+
export type Bracket = {
|
|
167
|
+
kind: "fitting";
|
|
168
|
+
fitting: "bracket";
|
|
169
|
+
name: string;
|
|
170
|
+
title: string;
|
|
171
|
+
profile: string;
|
|
172
|
+
other: string;
|
|
173
|
+
faces: {
|
|
174
|
+
b: string;
|
|
175
|
+
a: string;
|
|
176
|
+
};
|
|
177
|
+
thread: string;
|
|
178
|
+
head: string;
|
|
179
|
+
brace: boolean;
|
|
180
|
+
width: number;
|
|
181
|
+
thickness: number;
|
|
182
|
+
leg: number;
|
|
183
|
+
screwAt: number;
|
|
184
|
+
round: number;
|
|
185
|
+
braceSize: number;
|
|
186
|
+
hole: number;
|
|
187
|
+
tongues: {
|
|
188
|
+
b: object;
|
|
189
|
+
a: object;
|
|
190
|
+
};
|
|
191
|
+
screws: {
|
|
192
|
+
leg: "b" | "a";
|
|
193
|
+
thread: string;
|
|
194
|
+
head: string;
|
|
195
|
+
grip: number;
|
|
196
|
+
at: number[];
|
|
197
|
+
axis: number[];
|
|
198
|
+
nut: string;
|
|
199
|
+
}[];
|
|
200
|
+
load: {
|
|
201
|
+
force: number;
|
|
202
|
+
what: string;
|
|
203
|
+
at: number[];
|
|
204
|
+
direction: number[];
|
|
205
|
+
};
|
|
206
|
+
stiffness: {
|
|
207
|
+
linear: number;
|
|
208
|
+
bending: number;
|
|
209
|
+
kind: string;
|
|
210
|
+
rule: string;
|
|
211
|
+
};
|
|
212
|
+
stress: number;
|
|
213
|
+
margin: number;
|
|
214
|
+
deflection: number;
|
|
215
|
+
fe: object;
|
|
216
|
+
volume: number;
|
|
217
|
+
grams: number;
|
|
218
|
+
material: string;
|
|
219
|
+
printer: string;
|
|
220
|
+
section: number[][];
|
|
221
|
+
findings: object[];
|
|
222
|
+
rests: object[];
|
|
223
|
+
};
|
|
224
|
+
export type Plate = {
|
|
225
|
+
kind: "fitting";
|
|
226
|
+
fitting: "gusset" | "splice";
|
|
227
|
+
shape: string;
|
|
228
|
+
name: string;
|
|
229
|
+
title: string;
|
|
230
|
+
profile: string;
|
|
231
|
+
face: string;
|
|
232
|
+
thread: string;
|
|
233
|
+
head: string;
|
|
234
|
+
width: number;
|
|
235
|
+
thickness: number;
|
|
236
|
+
arm: number;
|
|
237
|
+
round: number;
|
|
238
|
+
hole: number;
|
|
239
|
+
outline: number[][];
|
|
240
|
+
tongues: object[];
|
|
241
|
+
screws: {
|
|
242
|
+
leg: "b" | "a";
|
|
243
|
+
thread: string;
|
|
244
|
+
head: string;
|
|
245
|
+
grip: number;
|
|
246
|
+
at: number[];
|
|
247
|
+
axis: number[];
|
|
248
|
+
nut: string;
|
|
249
|
+
}[];
|
|
250
|
+
load: object;
|
|
251
|
+
stiffness: object;
|
|
252
|
+
stress: number;
|
|
253
|
+
margin: number;
|
|
254
|
+
deflection: number;
|
|
255
|
+
fe: object;
|
|
256
|
+
volume: number;
|
|
257
|
+
grams: number;
|
|
258
|
+
material: string;
|
|
259
|
+
printer: string;
|
|
260
|
+
findings: object[];
|
|
261
|
+
rests: object[];
|
|
262
|
+
};
|