@constructorfleet/sketchforge3d 1.25.0 → 1.26.0
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/README.md +2 -2
- package/examples/tap-drill-plate.macro.mjs +24 -25
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -254,9 +254,9 @@ A module that exports a bare function instead of a definition runs in a `fresh`
|
|
|
254
254
|
| `bolt-plate.macro.mjs` | A plate sized around a computed row of tapped holes |
|
|
255
255
|
| `bolt-circle.macro.mjs` | A flange with N tapped holes on a ring of radius R |
|
|
256
256
|
| `filleted-box.macro.mjs` | A box from three numbers, with every roundable edge filleted on the server |
|
|
257
|
-
| `tap-drill-plate.macro.mjs` | A plate
|
|
257
|
+
| `tap-drill-plate.macro.mjs` | A plate cut with an M8 thread through `project.cut`, exported as STL |
|
|
258
258
|
|
|
259
|
-
Tapped holes are `kind: "thread"` with `hole: true`: the form is cut wider by a clearance and the shape is marked as a hole, so grouping it with the plate in the editor
|
|
259
|
+
Tapped holes are `kind: "thread"` with `hole: true`: the form is cut wider by a clearance and the shape is marked as a hole, so grouping it with the plate in the editor or through `project.group` taps the plate. `project.cut` can also subtract a thread mesh directly. `tap-drill-plate.macro.mjs` runs the whole cut-and-export workflow through the API with an M8 thread cutter.
|
|
260
260
|
|
|
261
261
|
## Development
|
|
262
262
|
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { writeFile } from "node:fs/promises";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A plate
|
|
4
|
+
* A plate tapped with an M8 thread cutter, cut on the server and exported as STL.
|
|
5
5
|
*
|
|
6
6
|
* This is the whole workflow, end to end through the API: the plate and a
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* M8 thread cutter is added as a shape, `project.cut` subtracts it as one
|
|
8
|
+
* exact boolean, and `project.export` returns
|
|
9
9
|
* the finished part as STL ready for a slicer. Nothing is left for the editor.
|
|
10
10
|
*
|
|
11
|
-
* The
|
|
12
|
-
*
|
|
13
|
-
* exact boolean cannot cut that mesh today.
|
|
11
|
+
* The thread cutter includes its core, so it removes the bore and helical
|
|
12
|
+
* thread form in one operation.
|
|
14
13
|
*
|
|
15
14
|
* `replace`, because a part is something you iterate on: a second run gives
|
|
16
15
|
* one plate with the new hole, not a second plate beside the first.
|
|
17
16
|
*
|
|
18
17
|
* @type {import("@constructorfleet/sketchforge3d").MacroDefinition<{
|
|
19
|
-
*
|
|
18
|
+
* size: number, width: number, depth: number, thickness: number, offset: number, out: string,
|
|
20
19
|
* }>}
|
|
21
20
|
*/
|
|
22
21
|
export default {
|
|
23
|
-
name: "
|
|
24
|
-
description: "A plate
|
|
25
|
-
project: { mode: "replace", name: "
|
|
22
|
+
name: "Tapped plate",
|
|
23
|
+
description: "A plate cut with an M8 thread cutter and exported as STL.",
|
|
24
|
+
project: { mode: "replace", name: "Tapped plate" },
|
|
26
25
|
params: {
|
|
27
|
-
/**
|
|
28
|
-
|
|
26
|
+
/** Metric thread size; the cutter removes its matching thread form. */
|
|
27
|
+
size: 8,
|
|
29
28
|
width: 60,
|
|
30
29
|
depth: 40,
|
|
31
30
|
thickness: 8,
|
|
@@ -39,24 +38,24 @@ export default {
|
|
|
39
38
|
const { shapes } = await project.addMany([
|
|
40
39
|
{ kind: "box", name: "Plate", width: params.width, depth: params.depth, height: params.thickness },
|
|
41
40
|
{
|
|
42
|
-
kind: "
|
|
43
|
-
name:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
|
|
41
|
+
kind: "thread",
|
|
42
|
+
name: `M${params.size} tapped hole`,
|
|
43
|
+
size: `M${params.size}`,
|
|
44
|
+
// Match the plate thickness: longer helical meshes can exceed the
|
|
45
|
+
// server kernel's STL importer limits for boolean cutters.
|
|
46
|
+
length: params.thickness,
|
|
48
47
|
x: params.offset,
|
|
49
|
-
elevation:
|
|
48
|
+
elevation: 0,
|
|
50
49
|
},
|
|
51
50
|
]);
|
|
52
|
-
const [plate,
|
|
53
|
-
if (!plate || !
|
|
51
|
+
const [plate, thread] = shapes;
|
|
52
|
+
if (!plate || !thread) throw new Error("Expected a plate and a thread cutter.");
|
|
54
53
|
|
|
55
|
-
// Named operands: the
|
|
56
|
-
const cut = await project.cut({ solidIds: [plate.id], holeIds: [
|
|
57
|
-
log(`
|
|
54
|
+
// Named operands: the thread need not be marked `hole: true` to be cut away.
|
|
55
|
+
const cut = await project.cut({ solidIds: [plate.id], holeIds: [thread.id] });
|
|
56
|
+
log(`tapped M${params.size} through the plate: ${cut.triangles} triangles`);
|
|
58
57
|
|
|
59
|
-
const stl = await project.export({ format: "stl", shapeIds: [cut.shape.id], name: "
|
|
58
|
+
const stl = await project.export({ format: "stl", shapeIds: [cut.shape.id], name: "tapped-plate" });
|
|
60
59
|
if (params.out) {
|
|
61
60
|
await writeFile(params.out, stl.data);
|
|
62
61
|
log(`wrote ${stl.bytes} bytes to ${params.out}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructorfleet/sketchforge3d",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Typed client and macro runner for the SketchForge REST API.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"author": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"client"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@constructorfleet/sketchforge-engine": "1.
|
|
22
|
+
"@constructorfleet/sketchforge-engine": "1.26.0",
|
|
23
23
|
"fflate": "^0.8.3",
|
|
24
24
|
"sharp": "^0.35.5"
|
|
25
25
|
},
|