@rulecad/shapes 0.4.6 → 0.4.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 +25 -0
- package/README.md +15 -2
- package/optimised.d.mts +4 -2
- package/optimised.mjs +7 -4
- package/package.json +1 -1
- package/seats.d.mts +58 -10
- package/seats.mjs +67 -15
- package/shapes.d.mts +1 -1
- package/shapes.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,31 @@ What changed in each release, for someone upgrading a workspace. A **printed siz
|
|
|
4
4
|
print (a hole's diameter, a seat's depth, a part's outline). Each release says whether any printed size moved, and
|
|
5
5
|
why.
|
|
6
6
|
|
|
7
|
+
## 0.4.8: a part as a region
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- `optimisedOutline` leaves a design's part named as a keep or avoid region to the design, as `optimisedSolid` does:
|
|
11
|
+
`regionShape` gives null for one. Before, it was drawn as a circle with no radius, and the build failed.
|
|
12
|
+
|
|
13
|
+
## 0.4.7: shaft bores in one place
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `shaftBore(shaft, { fit, across, printer })` and its table `SHAFT_FITS`: the bore a printed part takes for a bought
|
|
17
|
+
shaft, in one place (#307). `slide` is the fit bar's measured D-bore (0.05 mm each side, so 5.2 mm drawn for a 5 mm
|
|
18
|
+
shaft on the X1C), `press` the estimate of -0.02 mm each side, `run` the printer's `fit`, or a gap in mm. Each answer
|
|
19
|
+
says how far its fit is trusted (`kind`). `@rulecad/motors` now reads its bore from here, so the three agree.
|
|
20
|
+
- `plainBearing` and `pulleyBore` take `fit` as `shaftBore` does.
|
|
21
|
+
- `shaftBore` takes a `hole_comp` below 0, for a printer whose holes come out large, as `@rulecad/motors`' bore always
|
|
22
|
+
has; `plainBearing` and `pulleyBore` now take one too (they refused it). It refuses a `hole_comp` that is not a
|
|
23
|
+
number, or one that leaves no bore, by name.
|
|
24
|
+
|
|
25
|
+
### Printed sizes
|
|
26
|
+
|
|
27
|
+
- `pulleyBore` is drawn at the measured slide fit: 5.2 mm for a 5 mm shaft, 8.2 mm for 8 mm (it was 5.3 and 8.3). It
|
|
28
|
+
read the printer's `slip`, a figure across the diameter, as a gap each side. Give `fit: 'run'` for an idler that
|
|
29
|
+
turns on its axle. No example project draws a `pulleyBore`.
|
|
30
|
+
- `plainBearing` is unchanged (8.5 mm for 8 mm on the X1C).
|
|
31
|
+
|
|
7
32
|
## 0.4.6: print-in-place clearances (#162)
|
|
8
33
|
|
|
9
34
|
### Added
|
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ The printed side of a bearing or a shaft. Each one prints without supports in th
|
|
|
63
63
|
its sizes from rules: the bearing's from its rule set, the fit from the printer's (`hole_comp`, `fit`, `press`, `slip`).
|
|
64
64
|
|
|
65
65
|
```js
|
|
66
|
-
import { bearingSeat, seatSize, plainBearing, shaftShoulder, clipGroove } from '@rulecad/shapes'
|
|
66
|
+
import { bearingSeat, seatSize, shaftBore, plainBearing, pulleyBore, shaftShoulder, clipGroove } from '@rulecad/shapes'
|
|
67
67
|
|
|
68
68
|
const seat = bearingSeat(v['608'], { fit: 'press', printer: v.x1c, at: [0, 0, 12], into: '-z', through: true, relief: 5 })
|
|
69
69
|
seat.seat.pocket // 22.05: the diameter as drawn; clearance -0.05 once printed
|
|
@@ -77,7 +77,20 @@ clipGroove(8, { width: 1, depth: 0.5, at: [0, 0, 30] })
|
|
|
77
77
|
|---|---|
|
|
78
78
|
| Pocket, as drawn | outer + `hole_comp` - `press` (or + `slip`, or + a clearance you give, in mm across) |
|
|
79
79
|
| Ledge (`lip`) | a quarter of the races' radial depth by default, so it carries the outer race only; at most half |
|
|
80
|
-
|
|
|
80
|
+
| Shaft bore, as drawn | shaft + 2 × the fit each side + `hole_comp` (`shaftBore`): `slide` 0.05 mm (measured), `press` -0.02 mm (estimate), `run` the printer's `fit`, or a gap in mm |
|
|
81
|
+
| Plain bore, as drawn | a shaft bore at `run` by default: the printer's `fit` each side |
|
|
82
|
+
|
|
83
|
+
Every bore for a bought shaft reads its fit from one place, `shaftBore` and its table `SHAFT_FITS`: `plainBearing`,
|
|
84
|
+
`pulleyBore` and the motor's bore in `@rulecad/motors`. So a new measurement of the slide fit moves them all at once.
|
|
85
|
+
The slide fit was measured on the fit bar's D-bores (examples/bench/projects/benchmarks/MEASURE.md row 3, PLA on the
|
|
86
|
+
X1C, 2026-11-10): a 5 mm shaft slides comfortably in a bore drawn 5.2 mm, is tight in 5.1 mm and will not go in 5.0 mm.
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
shaftBore(5, { printer: v.x1c }) // { diameter: 5.2, each: 0.05, kind: 'measured', ... }: a hub that slides on
|
|
90
|
+
shaftBore(5, { fit: 'press', across: 4.5, printer: v.x1c }) // 5.06 across, 4.56 across a D flat
|
|
91
|
+
pulleyBore({ bore: 5 }, { length: 12, printer: v.x1c }) // 5.2: a pulley's grub screw bears on the shaft
|
|
92
|
+
plainBearing(8, { length: 10, printer: v.x1c }) // 8.5: a bore that turns on its shaft, at run
|
|
93
|
+
```
|
|
81
94
|
|
|
82
95
|
`lm8uuPocket`, `nutTrap`, `pulleyBore` and `beltClamp` are the same idea for a linear bearing, a lead-screw nut's
|
|
83
96
|
flange and body, a pulley on its shaft and a GT2 belt's grip. Of these only `nutTrap` has screws, the ones that hold
|
package/optimised.d.mts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export function fromOutlines(loops: [number, number][][]): jscad.geometries.geom2.Geom2;
|
|
6
6
|
/**
|
|
7
|
-
* A region of a problem (a circle, a centred rectangle or a polygon) as a JSCAD 2D shape
|
|
8
|
-
*
|
|
7
|
+
* A region of a problem (a circle, a centred rectangle or a polygon) as a JSCAD 2D shape; a design's part is null (it
|
|
8
|
+
* is the design's own to add or cut, as it is in 3D).
|
|
9
|
+
* @param {{ at?: [number, number], r?: number, size?: [number, number], points?: [number, number][], part?: string }} r
|
|
9
10
|
* @param {number} [segments]
|
|
10
11
|
*/
|
|
11
12
|
export function regionShape(r: {
|
|
@@ -13,6 +14,7 @@ export function regionShape(r: {
|
|
|
13
14
|
r?: number;
|
|
14
15
|
size?: [number, number];
|
|
15
16
|
points?: [number, number][];
|
|
17
|
+
part?: string;
|
|
16
18
|
}, segments?: number): jscad.geometries.geom2.Geom2;
|
|
17
19
|
/**
|
|
18
20
|
* An optimised result's outline, its keep regions added and avoid regions cut exactly.
|
package/optimised.mjs
CHANGED
|
@@ -23,11 +23,13 @@ export function fromOutlines(loops) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* A region of a problem (a circle, a centred rectangle or a polygon) as a JSCAD 2D shape
|
|
27
|
-
*
|
|
26
|
+
* A region of a problem (a circle, a centred rectangle or a polygon) as a JSCAD 2D shape; a design's part is null (it
|
|
27
|
+
* is the design's own to add or cut, as it is in 3D).
|
|
28
|
+
* @param {{ at?: [number, number], r?: number, size?: [number, number], points?: [number, number][], part?: string }} r
|
|
28
29
|
* @param {number} [segments]
|
|
29
30
|
*/
|
|
30
31
|
export function regionShape(r, segments = 48) {
|
|
32
|
+
if (r.part || r.triangles) return null;
|
|
31
33
|
if (r.points) return polygon({ points: r.points });
|
|
32
34
|
if (r.size) return rectangle({ center: r.at, size: r.size });
|
|
33
35
|
return circle({ center: r.at, radius: r.r, segments });
|
|
@@ -40,8 +42,9 @@ export function regionShape(r, segments = 48) {
|
|
|
40
42
|
*/
|
|
41
43
|
export function optimisedOutline(result, { segments = 48 } = {}) {
|
|
42
44
|
let shape = fromOutlines(result.outlines);
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
+
const keep = result.regions.keep.map((r) => regionShape(r, segments)).filter(Boolean), avoid = result.regions.avoid.map((r) => regionShape(r, segments)).filter(Boolean);
|
|
46
|
+
if (keep.length) shape = union(shape, ...keep);
|
|
47
|
+
if (avoid.length) shape = subtract(shape, ...avoid);
|
|
45
48
|
return shape;
|
|
46
49
|
}
|
|
47
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/shapes",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Shape helpers for printed JSCAD designs: text that prints cleanly, anchors on a face, clean local cuts, and enclosure pieces (shells, lids, rails, print-safe holes).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/seats.d.mts
CHANGED
|
@@ -53,15 +53,45 @@ export function bearingSeat(bearing: {
|
|
|
53
53
|
into?: string;
|
|
54
54
|
}): object;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
56
|
+
* The bore a printed part takes for a bought shaft, in numbers: the one place every shaft bore in the kit reads its fit
|
|
57
|
+
* from (a motor's bore in @rulecad/motors, pulleyBore, plainBearing). The bore as drawn is the shaft, plus the fit each
|
|
58
|
+
* side, plus the printer's hole compensation (printed holes come out that much small across; below 0 for a printer
|
|
59
|
+
* whose holes come out large).
|
|
59
60
|
* @param {number} shaft diameter
|
|
60
|
-
* @param {{
|
|
61
|
-
*
|
|
61
|
+
* @param {{ fit?: 'slide' | 'press' | 'run' | number, across?: number, printer: { hole_comp: number, fit?: number } }} o
|
|
62
|
+
* fit: one of SHAFT_FITS, run (the printer's fit each side, for a part that turns on the shaft), or a gap each side
|
|
63
|
+
* in mm (below 0, a press); across: a D-shaft's width across its flat, to have the flat's line as drawn as well
|
|
64
|
+
* @returns {{ diameter: number, across?: number, each: number, comp: number, fit: string | number, kind: string }}
|
|
65
|
+
* each: the gap each side as drawn, before hole_comp; kind: how far that gap is trusted (measured, estimate, the
|
|
66
|
+
* derived for run, from the printer's rule; given for a number)
|
|
67
|
+
*/
|
|
68
|
+
export function shaftBore(shaft: number, { fit, across, printer, what }?: {
|
|
69
|
+
fit?: "slide" | "press" | "run" | number;
|
|
70
|
+
across?: number;
|
|
71
|
+
printer: {
|
|
72
|
+
hole_comp: number;
|
|
73
|
+
fit?: number;
|
|
74
|
+
};
|
|
75
|
+
}): {
|
|
76
|
+
diameter: number;
|
|
77
|
+
across?: number;
|
|
78
|
+
each: number;
|
|
79
|
+
comp: number;
|
|
80
|
+
fit: string | number;
|
|
81
|
+
kind: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* A plain bearing for a shaft, where a ball bearing is more than the load needs. Its bore is shaftBore's: the shaft plus
|
|
85
|
+
* the fit each side, plus the printer's hole compensation. As a bore to subtract; given a wall, a bush standing up from
|
|
86
|
+
* z = 0 to add (a tube lying down wouldn't print round).
|
|
87
|
+
* @param {number} shaft diameter
|
|
88
|
+
* @param {{ fit?: 'run' | 'slide' | 'press' | number, clearance?: number, length: number, wall?: number, through?: boolean, printer: object, at?: number[], into?: string }} o
|
|
89
|
+
* fit: as shaftBore (default run, the printer's fit each side, as a bearing turns on its shaft); clearance: a gap each
|
|
90
|
+
* side in mm, the same as a number for fit
|
|
62
91
|
* @returns {object} a JSCAD geom3, with .bore the diameter as drawn and .clearance each side
|
|
63
92
|
*/
|
|
64
|
-
export function plainBearing(shaft: number, { clearance, length, wall, through, printer, at, into }?: {
|
|
93
|
+
export function plainBearing(shaft: number, { fit, clearance, length, wall, through, printer, at, into, what }?: {
|
|
94
|
+
fit?: "run" | "slide" | "press" | number;
|
|
65
95
|
clearance?: number;
|
|
66
96
|
length: number;
|
|
67
97
|
wall?: number;
|
|
@@ -145,18 +175,22 @@ export function nutTrap(nut: {
|
|
|
145
175
|
}): object;
|
|
146
176
|
/**
|
|
147
177
|
* A bore for a pulley on a stepper's round shaft (no flat: a pulley's grub screw bears on the shaft), or a plain idler's
|
|
148
|
-
* axle, to subtract. A pass-through with a chamfered mouth.
|
|
149
|
-
*
|
|
178
|
+
* axle, to subtract. A pass-through with a chamfered mouth. Its fit is shaftBore's slide, measured on a 5 mm shaft, the
|
|
179
|
+
* same as a motor's bore: a 5 mm bore is drawn 5.2 mm on the X1C.
|
|
180
|
+
* @param {{ bore: number }} pulley @param {{ length: number, fit?: 'slide' | 'run' | 'press' | number, printer: object, at?: number[], into?: string, through?: boolean }} o
|
|
181
|
+
* fit: as shaftBore (default slide); run, for an idler that turns on its axle
|
|
182
|
+
* @returns {object} a JSCAD geom3 to subtract, with .bore the diameter as drawn and .clearance each side
|
|
150
183
|
*/
|
|
151
184
|
export function pulleyBore(pulley: {
|
|
152
185
|
bore: number;
|
|
153
|
-
}, { length, printer, at, into, through }?: {
|
|
186
|
+
}, { length, fit, printer, at, into, through }?: {
|
|
154
187
|
length: number;
|
|
188
|
+
fit?: "slide" | "run" | "press" | number;
|
|
155
189
|
printer: object;
|
|
156
190
|
at?: number[];
|
|
157
191
|
into?: string;
|
|
158
192
|
through?: boolean;
|
|
159
|
-
}):
|
|
193
|
+
}): object;
|
|
160
194
|
/**
|
|
161
195
|
* A comb that grips a GT2 belt, to add: teeth of the belt's pitch on a block, the belt pressed in face first and held by
|
|
162
196
|
* a plain cover. Printed teeth up, so nothing overhangs.
|
|
@@ -172,3 +206,17 @@ export function beltClamp(belt: {
|
|
|
172
206
|
wall: number;
|
|
173
207
|
at?: number[];
|
|
174
208
|
}): object;
|
|
209
|
+
/**
|
|
210
|
+
* The fits a printed bore takes on a bought shaft (a motor's D-shaft, a pulley's, an axle), each side of the shaft, as
|
|
211
|
+
* drawn before the printer's hole compensation is added. `run`, for a part that turns on the shaft, is the printer's own
|
|
212
|
+
* `fit` each side, so it has no figure here.
|
|
213
|
+
* @type {Record<'slide' | 'press', { value: number, unit: string, rule: string, kind: string, source: string, checked: string }>}
|
|
214
|
+
*/
|
|
215
|
+
export const SHAFT_FITS: Record<"slide" | "press", {
|
|
216
|
+
value: number;
|
|
217
|
+
unit: string;
|
|
218
|
+
rule: string;
|
|
219
|
+
kind: string;
|
|
220
|
+
source: string;
|
|
221
|
+
checked: string;
|
|
222
|
+
}>;
|
package/seats.mjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// the material along a direction (into): '+x', '-x', '+y', '-y', '+z' (up from the bed) or '-z' (down from a top face).
|
|
5
5
|
// seatSize(bearing, { fit, lip, printer }) the numbers: the pocket as drawn, its depth, the relief, the fit
|
|
6
6
|
// bearingSeat(bearing, { fit, lip, relief, through, lead, printer, at, into }) a pocket to subtract, for the outer race
|
|
7
|
-
//
|
|
7
|
+
// shaftBore(shaft, { fit, across, printer }) the numbers: a bore for a bought shaft, at one of SHAFT_FITS, as drawn
|
|
8
|
+
// plainBearing(shaft, { fit, clearance, length, wall, through, printer, at, into }) a bore to subtract, or with wall a bush to add
|
|
8
9
|
// shaftShoulder(shaft, { shoulder, height, at }) a collar to add to a printed shaft, stood up: flat on top, 45° below
|
|
9
10
|
// clipGroove(shaft, { width, depth, at }) a ring to subtract from a printed shaft, stood up: flat below, sloped above
|
|
10
11
|
import jscad from '@jscad/modeling';
|
|
@@ -92,24 +93,72 @@ export function bearingSeat(bearing, { fit = 'press', lip, relief = 1, through =
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
96
|
+
* The fits a printed bore takes on a bought shaft (a motor's D-shaft, a pulley's, an axle), each side of the shaft, as
|
|
97
|
+
* drawn before the printer's hole compensation is added. `run`, for a part that turns on the shaft, is the printer's own
|
|
98
|
+
* `fit` each side, so it has no figure here.
|
|
99
|
+
* @type {Record<'slide' | 'press', { value: number, unit: string, rule: string, kind: string, source: string, checked: string }>}
|
|
100
|
+
*/
|
|
101
|
+
export const SHAFT_FITS = {
|
|
102
|
+
slide: { value: 0.05, unit: 'mm', rule: 'Gap each side of a shaft in its bore, with the printed hole\'s shrinkage allowed for, so it slides on and no more: a 5 mm D-shaft slides comfortably in a bore drawn 5.2 mm (0.05 each side and hole_comp 0.1), is tight in 5.1 mm and will not go in 5.0 mm', kind: 'measured', source: 'fit bar row 2, examples/bench/projects/benchmarks/MEASURE.md row 3, PLA on the X1C', checked: '2026-11-10' },
|
|
103
|
+
press: { value: -0.02, unit: 'mm', rule: 'Each side of a shaft in a press-fit bore as printed: a hair tight, 0.8% strain on a 5 mm shaft, well inside what PLA stretches to before it cracks. A D flat does the driving. A bore drawn 5.06 mm for a 5 mm shaft falls between the fit bar\'s 5.1 mm (tight) and 5.0 mm (too tight)', kind: 'estimate', source: 'A reasoned guess, between the fit bar\'s tight and too tight bores (examples/bench/projects/benchmarks/MEASURE.md row 3); not yet pressed and turned under load', checked: '2026-11-10' }
|
|
104
|
+
};
|
|
105
|
+
const SHAFT_FIT_NAMES = ['slide', 'press', 'run'];
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The bore a printed part takes for a bought shaft, in numbers: the one place every shaft bore in the kit reads its fit
|
|
109
|
+
* from (a motor's bore in @rulecad/motors, pulleyBore, plainBearing). The bore as drawn is the shaft, plus the fit each
|
|
110
|
+
* side, plus the printer's hole compensation (printed holes come out that much small across; below 0 for a printer
|
|
111
|
+
* whose holes come out large).
|
|
112
|
+
* @param {number} shaft diameter
|
|
113
|
+
* @param {{ fit?: 'slide' | 'press' | 'run' | number, across?: number, printer: { hole_comp: number, fit?: number } }} o
|
|
114
|
+
* fit: one of SHAFT_FITS, run (the printer's fit each side, for a part that turns on the shaft), or a gap each side
|
|
115
|
+
* in mm (below 0, a press); across: a D-shaft's width across its flat, to have the flat's line as drawn as well
|
|
116
|
+
* @returns {{ diameter: number, across?: number, each: number, comp: number, fit: string | number, kind: string }}
|
|
117
|
+
* each: the gap each side as drawn, before hole_comp; kind: how far that gap is trusted (measured, estimate, the
|
|
118
|
+
* derived for run, from the printer's rule; given for a number)
|
|
119
|
+
*/
|
|
120
|
+
export function shaftBore(shaft, { fit = 'slide', across, printer, what = 'shaftBore' } = {}) {
|
|
121
|
+
const p = printerOf(what, printer);
|
|
122
|
+
size(what, 'shaft', shaft);
|
|
123
|
+
// hole_comp may be below 0 here, for a printer whose holes come out large: motors' bore has always taken one
|
|
124
|
+
const comp = p.hole_comp;
|
|
125
|
+
if (!(typeof comp === 'number' && Number.isFinite(comp))) throw new Error(`${what}: printer.hole_comp is a number of mm, how much smaller across a printed hole comes out (got ${comp})`);
|
|
126
|
+
let each, kind;
|
|
127
|
+
if (typeof fit === 'number') { if (!Number.isFinite(fit) || 2 * fit + comp <= -shaft) throw new Error(`${what}: a fit of ${fit} mm each side${comp < 0 ? ` and hole_comp ${comp}` : ''} leaves no bore for a ${shaft} mm shaft`); each = fit; kind = 'given'; }
|
|
128
|
+
else if (fit === 'run') { each = size(what, 'printer.fit', p.fit); kind = 'derived'; }
|
|
129
|
+
else if (typeof fit === 'string' && Object.hasOwn(SHAFT_FITS, fit)) { each = SHAFT_FITS[fit].value; kind = SHAFT_FITS[fit].kind; }
|
|
130
|
+
else throw new Error(`${what}: fit is ${SHAFT_FIT_NAMES.join(', ')}, or a gap each side in mm (got ${fit})`);
|
|
131
|
+
const out = { diameter: +(shaft + 2 * each + comp).toFixed(4), each, comp, fit, kind };
|
|
132
|
+
if (!(out.diameter > 0)) throw new Error(`${what}: hole_comp ${comp} leaves no bore for a ${shaft} mm shaft at ${fit}`);
|
|
133
|
+
if (across != null) {
|
|
134
|
+
if (size(what, 'across', across) > shaft) throw new Error(`${what}: across the flat (${across}) is at most the shaft's diameter, ${shaft} mm`);
|
|
135
|
+
out.across = +(across + 2 * each + comp).toFixed(4);
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A plain bearing for a shaft, where a ball bearing is more than the load needs. Its bore is shaftBore's: the shaft plus
|
|
142
|
+
* the fit each side, plus the printer's hole compensation. As a bore to subtract; given a wall, a bush standing up from
|
|
143
|
+
* z = 0 to add (a tube lying down wouldn't print round).
|
|
98
144
|
* @param {number} shaft diameter
|
|
99
|
-
* @param {{ clearance?: number, length: number, wall?: number, through?: boolean, printer: object, at?: number[], into?: string }} o
|
|
100
|
-
*
|
|
145
|
+
* @param {{ fit?: 'run' | 'slide' | 'press' | number, clearance?: number, length: number, wall?: number, through?: boolean, printer: object, at?: number[], into?: string }} o
|
|
146
|
+
* fit: as shaftBore (default run, the printer's fit each side, as a bearing turns on its shaft); clearance: a gap each
|
|
147
|
+
* side in mm, the same as a number for fit
|
|
101
148
|
* @returns {object} a JSCAD geom3, with .bore the diameter as drawn and .clearance each side
|
|
102
149
|
*/
|
|
103
|
-
export function plainBearing(shaft, { clearance, length, wall, through = false, printer, at = [0, 0, 0], into = '-z' } = {}) {
|
|
104
|
-
|
|
150
|
+
export function plainBearing(shaft, { fit, clearance, length, wall, through = false, printer, at = [0, 0, 0], into = '-z', what = 'plainBearing' } = {}) {
|
|
151
|
+
printerOf(what, printer);
|
|
105
152
|
size(what, 'shaft', shaft); size(what, 'length', length);
|
|
106
|
-
|
|
107
|
-
if (
|
|
153
|
+
if (clearance != null && fit != null) throw new Error(`${what}: give fit or clearance, not both: a clearance is a fit in mm each side`);
|
|
154
|
+
if (clearance != null) size(what, 'clearance', clearance);
|
|
155
|
+
const b = shaftBore(shaft, { fit: clearance ?? fit ?? 'run', printer, what }), bore = b.diameter, gap = b.each;
|
|
156
|
+
if (wall == null) return Object.assign(along(tear(bore / 2, bore / 2, OUT, -length - (through ? OUT : 0), UP[into] ?? null), into, at), { bore, clearance: gap, fit: b.fit, kind: b.kind });
|
|
108
157
|
size(what, 'wall', wall);
|
|
109
158
|
if (UP[into]) throw new Error(`${what}: a bush with a wall prints standing up (into +z or -z): a tube on its side wouldn't print round. Bore across a part with no wall instead`);
|
|
110
159
|
const outer = bore / 2 + wall, inner = bore / 2, chamfer = Math.min(0.4, wall / 2);
|
|
111
160
|
const g = extrudeRotate({ segments: SEGMENTS }, polygon({ points: [[inner + chamfer, 0], [outer - chamfer, 0], [outer, chamfer], [outer, length], [inner, length], [inner, chamfer]] }));
|
|
112
|
-
return Object.assign(translate(at, g), { bore, clearance: gap });
|
|
161
|
+
return Object.assign(translate(at, g), { bore, clearance: gap, fit: b.fit, kind: b.kind });
|
|
113
162
|
}
|
|
114
163
|
|
|
115
164
|
/**
|
|
@@ -193,11 +242,14 @@ export function nutTrap(nut, { fit, hole: hole_, printer, at = [0, 0, 0], depth
|
|
|
193
242
|
|
|
194
243
|
/**
|
|
195
244
|
* A bore for a pulley on a stepper's round shaft (no flat: a pulley's grub screw bears on the shaft), or a plain idler's
|
|
196
|
-
* axle, to subtract. A pass-through with a chamfered mouth.
|
|
197
|
-
*
|
|
245
|
+
* axle, to subtract. A pass-through with a chamfered mouth. Its fit is shaftBore's slide, measured on a 5 mm shaft, the
|
|
246
|
+
* same as a motor's bore: a 5 mm bore is drawn 5.2 mm on the X1C.
|
|
247
|
+
* @param {{ bore: number }} pulley @param {{ length: number, fit?: 'slide' | 'run' | 'press' | number, printer: object, at?: number[], into?: string, through?: boolean }} o
|
|
248
|
+
* fit: as shaftBore (default slide); run, for an idler that turns on its axle
|
|
249
|
+
* @returns {object} a JSCAD geom3 to subtract, with .bore the diameter as drawn and .clearance each side
|
|
198
250
|
*/
|
|
199
|
-
export function pulleyBore(pulley, { length, printer, at = [0, 0, 0], into = '-z', through = false } = {}) {
|
|
200
|
-
return plainBearing(size('pulleyBore', 'bore', pulley?.bore), { length, printer, at, into, through,
|
|
251
|
+
export function pulleyBore(pulley, { length, fit = 'slide', printer, at = [0, 0, 0], into = '-z', through = false } = {}) {
|
|
252
|
+
return plainBearing(size('pulleyBore', 'bore', pulley?.bore), { length, fit, printer, at, into, through, what: 'pulleyBore' });
|
|
201
253
|
}
|
|
202
254
|
|
|
203
255
|
/**
|
package/shapes.d.mts
CHANGED
|
@@ -27,5 +27,5 @@ export const scale: typeof jscad.transforms.scale;
|
|
|
27
27
|
import jscad from '@jscad/modeling';
|
|
28
28
|
export { outline, slab, shell, lid, dovetail, gabled, diamond, vents } from "./enclosure.mjs";
|
|
29
29
|
export { countersink, teardropHole, nutPocket, crushRibs, wallOpening } from "./features.mjs";
|
|
30
|
-
export { seatSize, bearingSeat, plainBearing, shaftShoulder, clipGroove, lm8uuPocket, nutTrap, pulleyBore, beltClamp } from "./seats.mjs";
|
|
30
|
+
export { seatSize, bearingSeat, shaftBore, SHAFT_FITS, plainBearing, shaftShoulder, clipGroove, lm8uuPocket, nutTrap, pulleyBore, beltClamp } from "./seats.mjs";
|
|
31
31
|
export { fromOutlines, regionShape, optimisedOutline, solidRegion, optimisedSolid } from "./optimised.mjs";
|
package/shapes.mjs
CHANGED
|
@@ -106,6 +106,6 @@ export const size = (g) => { const [lo, hi] = measureBoundingBox(g); return [hi[
|
|
|
106
106
|
export { scale };
|
|
107
107
|
export { outline, slab, shell, lid, dovetail, gabled, diamond, vents } from './enclosure.mjs';
|
|
108
108
|
export { countersink, teardropHole, nutPocket, crushRibs, wallOpening } from './features.mjs';
|
|
109
|
-
export { seatSize, bearingSeat, plainBearing, shaftShoulder, clipGroove, lm8uuPocket, nutTrap, pulleyBore, beltClamp } from './seats.mjs';
|
|
109
|
+
export { seatSize, bearingSeat, shaftBore, SHAFT_FITS, plainBearing, shaftShoulder, clipGroove, lm8uuPocket, nutTrap, pulleyBore, beltClamp } from './seats.mjs';
|
|
110
110
|
export { ops } from './ops.mjs';
|
|
111
111
|
export { fromOutlines, regionShape, optimisedOutline, solidRegion, optimisedSolid } from './optimised.mjs';
|