@rulecad/cad 0.7.48 → 0.7.55
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/AGENTS.md +24 -6
- package/EXAMPLES.md +347 -1
- package/README.md +136 -3
- package/bin/cad.mjs +73 -24
- package/lib/assembly.mjs +96 -34
- package/lib/beams.mjs +147 -0
- package/lib/bought.mjs +1 -1
- package/lib/buildpage.mjs +6 -3
- package/lib/design.mjs +48 -13
- package/lib/edit.mjs +12 -4
- package/lib/fasten.mjs +824 -0
- package/lib/fixings.mjs +42 -0
- package/lib/frames.mjs +63 -0
- package/lib/links.mjs +2 -1
- package/lib/list.mjs +38 -12
- package/lib/measured.mjs +69 -8
- package/lib/motors.mjs +48 -7
- package/lib/order.mjs +20 -6
- package/lib/preview/page.html +4 -2
- package/lib/preview.mjs +3 -2
- package/lib/profilemeasure.mjs +278 -0
- package/lib/sandbox-hooks.mjs +2 -2
- package/lib/sandbox-run.mjs +6 -3
- package/lib/sandbox.mjs +9 -6
- package/lib/schema.mjs +1 -1
- package/lib/sheet.mjs +143 -4
- package/package.json +5 -3
- package/schemas/assembly.schema.json +41 -2
- package/schemas/outline.schema.json +24 -0
package/AGENTS.md
CHANGED
|
@@ -21,6 +21,10 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
21
21
|
- When a part must fit something whose model exists (a maker's CAD, a model site), measure that model:
|
|
22
22
|
`npx cad measure <file> --rules <name> --source <url> --licence "…"`. Look at the drawing in `.preview/measure/`,
|
|
23
23
|
then rename the draft rules for what they are and say in each `rule` what the feature does.
|
|
24
|
+
- For a beam (an aluminium extrusion) the kit has no profile for, measure the maker's model or a DXF of its section:
|
|
25
|
+
`npx cad measure <beam.stl|section.dxf> --profile <name> --source <url> --licence "…"`. It writes a draft profile
|
|
26
|
+
set and the section's outline into this workspace's `rules/`. Look at the drawing, check the slot figures against
|
|
27
|
+
the maker's sheet, and never copy the outline out of the workspace: it is the maker's shape.
|
|
24
28
|
- Model it from those rules, then `npx cad match <project>/<object> <file>`: report the worst places with their numbers,
|
|
25
29
|
and look at the sections picture. A deliberate clearance shows as an even offset; anything else is a finding.
|
|
26
30
|
- Don't copy the shape of a model whose licence is non-commercial, no-derivatives or share-alike into a design under
|
|
@@ -30,7 +34,7 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
30
34
|
1. `npx cad history <project>/<object>` first: read the print log. A failed print is the reason for most changes:
|
|
31
35
|
fix the rule or variable it points at (a measured fit beats a community rule).
|
|
32
36
|
2. Change, then check, preview and look, as for a new part. Change values with `npx cad set <project>/<object>
|
|
33
|
-
name=value` and assemblies with `npx cad add fit|joint|item|pose …`: they keep the file's layout and refuse an edit
|
|
37
|
+
name=value` and assemblies with `npx cad add fit|joint|item|pose|fasten …`: they keep the file's layout and refuse an edit
|
|
34
38
|
that breaks it. `npx cad values` lists an object's numbers; `npx cad why <project>/<object>.<name>` shows what a
|
|
35
39
|
value depends on, down to the rules (estimates marked). `--json` on check, values and why gives data to act on:
|
|
36
40
|
each finding has a code, its numbers and where it is.
|
|
@@ -43,15 +47,23 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
43
47
|
- Walls are whole numbers of print lines (`x1c.line * 3`, or your printer's set), heights whole numbers of layers.
|
|
44
48
|
- Holes and slots get the printer's hole compensation; parts that slide together get its fit clearance. Chamfer
|
|
45
49
|
bottom edges.
|
|
50
|
+
- A hole or a seat for a screw, a nut or a heat-set insert comes from `v.fixings`, named by its thread, never from a
|
|
51
|
+
typed number: `v.fixings.hole('M3', { kind: 'pilot', at })` (kinds: `clearance`, `close`, `loose`, `pilot`, `tap`,
|
|
52
|
+
`insert`, `thread`), `counterbore`, `countersink`, `nutPocket`, `nutTrap`, `squareNutSlot`, `insertBoss`. Each reads
|
|
53
|
+
the workspace's thread set (`rules/m3.json` before the kit's), the project's printer and its material, so no
|
|
54
|
+
diameter is typed and none is passed in. `cad check` then says what each was drawn to and the rule it rests on:
|
|
55
|
+
report a figure it marks as an estimate or a community figure, and measure it. A thread's name is text
|
|
56
|
+
(`'M3x12 cap'`), so the check on numbers passes it.
|
|
46
57
|
- An overhang warning means supports: say so in `orientation`, or change the shape or orientation.
|
|
47
58
|
- A part that moves by bending (a spring, a snap, a hinge with no pin) is a flexure from `v.flexures`: drawn flat, so it
|
|
48
59
|
bends within its layers; give its thickness in whole lines (`x1c.line`), and check its strain at the travel against
|
|
49
60
|
the material's limit with `v.flexures.printable`. PLA creeps held bent and fatigues; PETG or nylon for springs.
|
|
50
|
-
- Use the print-aware features in `v.shapes` before drawing your own: `
|
|
51
|
-
`
|
|
61
|
+
- Use the print-aware features in `v.shapes` before drawing your own: `teardropHole`, `crushRibs`, `wallOpening`
|
|
62
|
+
print without supports as drawn (and `countersink` and `nutPocket` for a size that is no screw's). Use `v.ops.union/subtract/intersect` for booleans: the
|
|
52
63
|
workspace can switch them to Manifold (faster, watertight) without touching the design.
|
|
53
|
-
- Designs run sandboxed: they may import only `@jscad/modeling`, `@rulecad/shapes`, `@rulecad/flexures
|
|
54
|
-
their project, and can't write files or start
|
|
64
|
+
- Designs run sandboxed: they may import only `@jscad/modeling`, `@rulecad/shapes`, `@rulecad/flexures`,
|
|
65
|
+
`@rulecad/gears`, `@rulecad/motors`, `@rulecad/fixings` and files in their project, and can't write files or start
|
|
66
|
+
programs. To see a value while designing, `console.log` it: it comes
|
|
55
67
|
out with the command's output. A misspelt `v.name` stops the build and says which name was meant.
|
|
56
68
|
- Something printed under the part and removed afterwards is a named `support` part (`return { cap, pillar }`, both
|
|
57
69
|
described in the .json's `parts`), not part of the shape. Look at `cad preview --explode` too.
|
|
@@ -73,7 +85,13 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
73
85
|
them with joints, name the positions in `poses`, and run `cad check --sweep` to find where parts collide on the way.
|
|
74
86
|
See "Joints and poses" in the cad README.
|
|
75
87
|
- A part is named in fits as `<item>.<part>`; an object that returns one unnamed shape has one part, `body`.
|
|
76
|
-
-
|
|
88
|
+
- Where parts screw together, say so with `fasten`, which knows the screw:
|
|
89
|
+
`{ "screw": "M3 cap", "through": ["bracket"], "into": "base", "at": ["bracket.h1", "bracket.h2"] }` (anchors on the
|
|
90
|
+
holes' axes), or `"holes": "bracket.body"` to use the part's own holes; `npx cad add fasten …` writes it. The check
|
|
91
|
+
reads the holes from the parts as drawn: one axis through the stack, a clearance hole in each part passed, a pilot,
|
|
92
|
+
insert or nut at the far end, the length chosen from what is sold, thread engaged, and the seat under the head.
|
|
93
|
+
Report what it finds with its numbers, and fix the part, never the relation, to make it pass.
|
|
94
|
+
- A gap fit can't tell whether holes line up. Where a board only rests on its screws' bosses, a holes fit follows them
|
|
77
95
|
(`{ "holes": "pcb.board", "into": "case.body", "depth": "m2.insert_length" }`).
|
|
78
96
|
- A part built around another (a case around its board) reads it: `"uses": ["macropad/pcb"]`, then
|
|
79
97
|
`pcb.board_w` and `v.pcb.board_holes`. Never copy another object's numbers by hand.
|
package/EXAMPLES.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[The tutorial](TUTORIAL.md) ends with a wall hook checked against its screw. These examples carry on from there, one
|
|
4
4
|
for each thing the [README](README.md) describes after that: parts, variants and releases, joints and poses, a model
|
|
5
|
-
from elsewhere, an optimised part, a board, a mechanism printed flat, gears, a gearbox, a motor, a robot joint,
|
|
5
|
+
from elsewhere, an optimised part, a board, a mechanism printed flat, gears, a gearbox, a motor, a robot joint, a machine sized from its task, and a bracket screwed on. Each is a few files and the commands to run
|
|
6
6
|
them. The tests write every file here and run every command, so what you read is what works.
|
|
7
7
|
|
|
8
8
|
They start from a workspace `npm create rulecad my-designs` makes, as the tutorial does, and run in order: later
|
|
@@ -5748,3 +5748,349 @@ Said plainly, because a gait that passes these checks is not a robot that walks:
|
|
|
5748
5748
|
|
|
5749
5749
|
`npm create rulecad --machine leg` starts a project from the leg and its stand. The step file for a gait, for a streamer grown to more axes, is not done yet, and neither is a measured leg.
|
|
5750
5750
|
|
|
5751
|
+
|
|
5752
|
+
## 15. Fixings: a bracket screwed on
|
|
5753
|
+
|
|
5754
|
+
A small shelf bracket and the wall plate it screws to. Every hole and seat in them comes from `v.fixings`, named by its
|
|
5755
|
+
thread and never by a typed diameter: a counterbore and its clearance hole for the screws' heads, a pilot the screw
|
|
5756
|
+
cuts its own thread in, a boss for a heat-set insert, a slot a nut drops into, and countersinks. The assembly says which
|
|
5757
|
+
screws join what with `fasten`, and the check follows each screw along its axis: whether the holes line up, what holds
|
|
5758
|
+
its far end, how long it should be, how much thread it has, what its head sits on, whether a hex key reaches it, and
|
|
5759
|
+
what the shelf's weight does to it. Two mistakes follow, each caught by name. [Choosing a pilot, an insert or a
|
|
5760
|
+
nut](../../docs/guides/pilot-insert-nut.md) explains when each end is the right one.
|
|
5761
|
+
|
|
5762
|
+
The bracket is shown with all three ends at once, so one small model shows each. A real one would use one kind.
|
|
5763
|
+
|
|
5764
|
+
```json projects/fix/project.json
|
|
5765
|
+
{
|
|
5766
|
+
"name": "fix",
|
|
5767
|
+
"title": "A bracket screwed on",
|
|
5768
|
+
"printer": "x1c",
|
|
5769
|
+
"material": "PLA",
|
|
5770
|
+
"objects": ["plate", "bracket", "wall"]
|
|
5771
|
+
}
|
|
5772
|
+
```
|
|
5773
|
+
|
|
5774
|
+
### The plate
|
|
5775
|
+
|
|
5776
|
+
It goes flat on the bed with its back down, and the back goes on the wall. Four posts stand out of it for the
|
|
5777
|
+
bracket's foot to rest on. One is the insert's boss from `insertBoss`; the other three are the same column, flared at
|
|
5778
|
+
the root the same way, so no inside corner is square. The top post has a pilot; the two in the middle are passed
|
|
5779
|
+
right through by screws coming from behind, their heads sunk flush with the back in countersinks that open on to the
|
|
5780
|
+
bed (a 45° cone, which prints). Two M4 countersinks at the ends take the wall's own screws, chosen for the wall.
|
|
5781
|
+
|
|
5782
|
+
```json projects/fix/objects/plate.json
|
|
5783
|
+
{
|
|
5784
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
5785
|
+
"name": "plate",
|
|
5786
|
+
"title": "Wall plate",
|
|
5787
|
+
"version": "0.1.0",
|
|
5788
|
+
"uses": ["x1c"],
|
|
5789
|
+
"material": "PLA",
|
|
5790
|
+
"orientation": "Flat, its back on the bed: the back goes against the wall, the four posts stand out from it",
|
|
5791
|
+
"variables": {
|
|
5792
|
+
"thick": { "value": "x1c.layer * 15", "unit": "mm", "rule": "The plate: whole layers, and enough for the wall screws' M4 countersinks, 2.2 mm deep" },
|
|
5793
|
+
"stand": { "value": "x1c.layer * 34", "unit": "mm", "rule": "The posts: as tall as the insert's hole is deep, in whole layers, so the insert's boss is a post" },
|
|
5794
|
+
"pitch": { "value": 32, "unit": "mm", "rule": "Between the two screws from the front, up the wall: as the bracket's" },
|
|
5795
|
+
"nut_pitch": { "value": 12, "unit": "mm", "rule": "Between the two screws from behind, up the wall: as the bracket's nuts" },
|
|
5796
|
+
"width": { "value": 20, "unit": "mm", "rule": "Across the plate: a post and a few mm each side" },
|
|
5797
|
+
"long": { "value": 70, "unit": "mm", "rule": "Up the plate: the bracket's foot and a wall screw beyond each end" },
|
|
5798
|
+
"round": { "value": 4, "unit": "mm", "rule": "The plate's corners, rounded" },
|
|
5799
|
+
"wall_pitch": { "value": 58, "unit": "mm", "rule": "Between the wall screws, clear of the bracket's foot and the posts" },
|
|
5800
|
+
"floor": { "value": "x1c.layer * 5", "unit": "mm", "rule": "Plastic left under the pilot, so it does not break through the back" }
|
|
5801
|
+
}
|
|
5802
|
+
}
|
|
5803
|
+
```
|
|
5804
|
+
|
|
5805
|
+
```js projects/fix/objects/plate.js
|
|
5806
|
+
// The wall plate: four posts for the bracket, each the end its screw needs, and two countersunk holes for the wall.
|
|
5807
|
+
import jscad from '@jscad/modeling'
|
|
5808
|
+
const { roundedRectangle, cylinder, cylinderElliptic } = jscad.primitives
|
|
5809
|
+
const { extrudeLinear } = jscad.extrusions
|
|
5810
|
+
|
|
5811
|
+
export function main (v) {
|
|
5812
|
+
const f = v.fixings, top = v.thick + v.stand
|
|
5813
|
+
const slab = extrudeLinear({ height: v.thick }, roundedRectangle({ size: [v.width, v.long], roundRadius: v.round }))
|
|
5814
|
+
// the insert's boss, from the kit; the other posts are the same column, flared at the root the same way
|
|
5815
|
+
const boss = f.insertBoss('M3', { height: v.stand, at: [0, 0 - v.pitch / 2, v.thick] }), R = boss.model.outer / 2, root = boss.model.root
|
|
5816
|
+
const post = (y) => v.ops.union(cylinderElliptic({ height: root, startRadius: [R + root, R + root], endRadius: [R, R], center: [0, y, v.thick + root / 2] }),
|
|
5817
|
+
cylinder({ radius: R, height: v.stand, center: [0, y, v.thick + v.stand / 2] }))
|
|
5818
|
+
const body = v.ops.union(slab, boss.boss, post(v.pitch / 2), ...[-1, 1].map((s) => post(s * v.nut_pitch / 2)))
|
|
5819
|
+
return v.ops.subtract(body, boss.hole,
|
|
5820
|
+
f.hole('M3', { kind: 'pilot', depth: top - v.floor, at: [0, v.pitch / 2, top] }),
|
|
5821
|
+
...[-1, 1].map((s) => f.countersink('M3', { length: top, thickness: top, into: '+z', at: [0, s * v.nut_pitch / 2, 0] })),
|
|
5822
|
+
...[-1, 1].map((s) => f.countersink('M4', { length: v.thick, thickness: v.thick, at: [0, s * v.wall_pitch / 2, v.thick] })))
|
|
5823
|
+
}
|
|
5824
|
+
```
|
|
5825
|
+
|
|
5826
|
+
### The bracket
|
|
5827
|
+
|
|
5828
|
+
The bracket prints on its side: the web, the triangle that carries the shelf, lies flat on the bed, and the foot stands
|
|
5829
|
+
up from its back edge. So the first layer is one plain shape, the inside corner between web and foot is a 45° fillet,
|
|
5830
|
+
and every hole through the foot lies on its side: a counterbore and its hole are one teardrop cutter, with 45° roofs.
|
|
5831
|
+
The nut's slot opens at the top of the foot as it prints, and the nut drops in from there, so nothing spans. The web's
|
|
5832
|
+
lower end is deep enough (`heel`) that the foot and its fillet stand on it all the way along.
|
|
5833
|
+
|
|
5834
|
+
```json projects/fix/objects/bracket.json
|
|
5835
|
+
{
|
|
5836
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
5837
|
+
"name": "bracket",
|
|
5838
|
+
"title": "Shelf bracket",
|
|
5839
|
+
"version": "0.1.0",
|
|
5840
|
+
"uses": ["x1c"],
|
|
5841
|
+
"material": "PLA",
|
|
5842
|
+
"orientation": "On its side: the web flat on the bed, the foot standing up from its back edge, the nuts' slots open at the top",
|
|
5843
|
+
"variables": {
|
|
5844
|
+
"web": { "value": "x1c.layer * 15", "unit": "mm", "rule": "The web's thickness, flat on the bed: 3 mm carries the shelf 80 times over (EXAMPLES chapter 15 works it); thinner is a floppy edge" },
|
|
5845
|
+
"wide": { "value": 44, "unit": "mm", "rule": "Up the wall: the four screws and the foot's ends" },
|
|
5846
|
+
"reach": { "value": 40, "unit": "mm", "rule": "Out from the wall: the shelf's depth it carries" },
|
|
5847
|
+
"heel": { "value": 14, "unit": "mm", "rule": "The web's depth at its lower end: under the whole foot and its fillet, so neither hangs in the air" },
|
|
5848
|
+
"foot": { "value": "x1c.layer * 32", "unit": "mm", "rule": "The foot's thickness, where the screws pass: a counterbored head, and the nut's slot with plastic each side of it" },
|
|
5849
|
+
"out": { "value": 25, "unit": "mm", "rule": "The foot, out to one side of the web: room for the screws and the nuts' slots beyond them" },
|
|
5850
|
+
"at": { "value": 14, "unit": "mm", "rule": "The screws' line, from the web's face: clear of the web and its fillet for the head and the key" },
|
|
5851
|
+
"pitch": { "value": 32, "unit": "mm", "rule": "Between the two screws from the front: as far apart as the foot allows, so they share the shelf's pull" },
|
|
5852
|
+
"nut_pitch": { "value": 12, "unit": "mm", "rule": "Between the two nuts' slots, inside the front screws' counterbores with plastic between" },
|
|
5853
|
+
"fillet": { "value": 4, "unit": "mm", "rule": "The 45° fillet in the inside corner between the web and the foot, so the corner is not square" },
|
|
5854
|
+
"nut_floor": { "value": "x1c.layer * 6", "unit": "mm", "rule": "Plastic between the foot's back and the nut's slot" }
|
|
5855
|
+
},
|
|
5856
|
+
"anchors": {
|
|
5857
|
+
"pilot": { "at": ["pitch / 2", "foot", "at"], "axis": [0, 1, 0] },
|
|
5858
|
+
"insert": { "at": ["0 - pitch / 2", "foot", "at"], "axis": [0, 1, 0] },
|
|
5859
|
+
"nut1": { "at": ["nut_pitch / 2", 0, "at"], "axis": [0, -1, 0] },
|
|
5860
|
+
"nut2": { "at": ["0 - nut_pitch / 2", 0, "at"], "axis": [0, -1, 0] },
|
|
5861
|
+
"shelf": { "at": ["wide / 2", "reach - 10", "web / 2"], "axis": [0, 0, 1] }
|
|
5862
|
+
}
|
|
5863
|
+
}
|
|
5864
|
+
```
|
|
5865
|
+
|
|
5866
|
+
The anchors are where the screws go: `pilot` and `insert` on the foot's front face, over the two front screws' holes,
|
|
5867
|
+
and `nut1` and `nut2` on its back, where the screws from behind come in. `shelf` is where the shelf's weight is hung.
|
|
5868
|
+
|
|
5869
|
+
```js projects/fix/objects/bracket.js
|
|
5870
|
+
// A shelf bracket, drawn as it prints: the web flat on the bed, the foot standing up along its back edge.
|
|
5871
|
+
// Two cap screws go down counterbores in the foot into the wall plate; two more come from behind the plate into nuts
|
|
5872
|
+
// dropped into slots in the foot.
|
|
5873
|
+
import jscad from '@jscad/modeling'
|
|
5874
|
+
const { polygon, cuboid } = jscad.primitives
|
|
5875
|
+
const { extrudeLinear } = jscad.extrusions
|
|
5876
|
+
const { transform, translate } = jscad.transforms
|
|
5877
|
+
|
|
5878
|
+
// (a profile drawn in y and z, extruded along x)
|
|
5879
|
+
const alongX = (g) => transform([0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1], g)
|
|
5880
|
+
|
|
5881
|
+
export function main (v) {
|
|
5882
|
+
const f = v.fixings, half = v.wide / 2
|
|
5883
|
+
const web = extrudeLinear({ height: v.web }, polygon({ points: [[0 - half, 0], [half, 0], [half, v.reach], [0 - half, v.heel]] }))
|
|
5884
|
+
const foot = cuboid({ size: [v.wide, v.foot, v.out], center: [0, v.foot / 2, v.out / 2] })
|
|
5885
|
+
const fillet = translate([0 - half, 0, 0], alongX(extrudeLinear({ height: v.wide }, polygon({ points: [[v.foot, v.web], [v.foot + v.fillet, v.web], [v.foot, v.web + v.fillet]] }))))
|
|
5886
|
+
const trap = f.nutTrapModel('M3', { axis: 'y', into: '-z', depth: v.out - v.at })
|
|
5887
|
+
return v.ops.subtract(v.ops.union(web, foot, fillet),
|
|
5888
|
+
...[-1, 1].map((s) => f.counterbore('M3 cap', { length: v.foot, thickness: v.foot, into: '-y', at: [s * v.pitch / 2, v.foot, v.at] })),
|
|
5889
|
+
...[-1, 1].flatMap((s) => [f.hole('M3', { depth: v.foot, into: '+y', at: [s * v.nut_pitch / 2, 0, v.at] }),
|
|
5890
|
+
f.nutTrap('M3', { axis: 'y', into: '-z', depth: v.out - v.at, at: [s * v.nut_pitch / 2, v.nut_floor + trap.gap / 2, v.out] })]))
|
|
5891
|
+
}
|
|
5892
|
+
```
|
|
5893
|
+
|
|
5894
|
+
`nutTrapModel` gives the slot's numbers before it is cut: its `gap` along the screw puts the nut's middle where the
|
|
5895
|
+
slot is drawn, so the nut sits `nut_floor` in from the foot's back whatever the printer's slip.
|
|
5896
|
+
|
|
5897
|
+
```sh
|
|
5898
|
+
npx cad check fix/plate
|
|
5899
|
+
npx cad check fix/bracket
|
|
5900
|
+
```
|
|
5901
|
+
|
|
5902
|
+
Each prints without supports: no overhang past 45°, no ledge, nothing in mid-air, one piece, a plain first layer. Each
|
|
5903
|
+
seat says what it was drawn to and the rule it rests on: the pilot 2.9 mm from `x1c.pilot_m3` (measured on this
|
|
5904
|
+
printer), the insert's hole 4 mm from `m3.insert_hole` (a community figure, as drawn), each clearance hole 3.5 mm
|
|
5905
|
+
(`m3.clearance`, from ISO 273, plus `x1c.hole_comp`), the counterbore 6 mm by 3 mm, the countersink 6.82 mm at 90°, and
|
|
5906
|
+
the nut's slot 5.7 mm across the flats and 2.6 mm along the screw (`m3.nut_flats` and `m3.nut_height`, plus
|
|
5907
|
+
`x1c.hole_comp` and `x1c.slip`).
|
|
5908
|
+
|
|
5909
|
+
### Screwed together
|
|
5910
|
+
|
|
5911
|
+
The plate's back is the wall, at z = 0, and up the wall is y. The bracket is turned from how it prints to how it hangs,
|
|
5912
|
+
and stands on the posts. Two `fasten` relations hold it: two cap screws from the front, through the bracket into the
|
|
5913
|
+
plate, and two countersunk screws from behind, through the plate into the bracket's nuts. Neither names a length: the
|
|
5914
|
+
check chooses the shortest sold that fits each screw. The shelf is 2 kg hung at the `shelf` anchor, and gravity runs
|
|
5915
|
+
down the wall.
|
|
5916
|
+
|
|
5917
|
+
```json projects/fix/assemblies/shelf.json
|
|
5918
|
+
{
|
|
5919
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/assembly.schema.json",
|
|
5920
|
+
"title": "A shelf bracket on its wall plate",
|
|
5921
|
+
"kind": "fit",
|
|
5922
|
+
"description": "The plate's back on the wall (z = 0), the bracket on its four posts, up the wall along y. Two cap screws go through the bracket's foot into the plate, one into a pilot and one into a heat-set insert; two countersunk screws come from behind the plate into nuts in the foot.",
|
|
5923
|
+
"items": [
|
|
5924
|
+
{ "id": "plate", "object": "plate" },
|
|
5925
|
+
{ "id": "bracket", "object": "bracket", "rotate": [90, 0, 90], "at": ["0 - bracket.at", 0, "plate.thick + plate.stand"] }
|
|
5926
|
+
],
|
|
5927
|
+
"fits": [
|
|
5928
|
+
{ "a": "bracket", "b": "plate", "min": 0, "max": 0.05, "note": "The foot sits on the plate's posts" }
|
|
5929
|
+
],
|
|
5930
|
+
"fasten": [
|
|
5931
|
+
{ "screw": "M3 cap", "through": ["bracket"], "into": "plate", "at": ["bracket.pilot", "bracket.insert"], "note": "Front screws" },
|
|
5932
|
+
{ "screw": "M3 countersunk", "through": ["plate"], "into": "bracket", "at": ["bracket.nut1", "bracket.nut2"], "nut": true, "torque": 0.3, "note": "Back screws" }
|
|
5933
|
+
],
|
|
5934
|
+
"gravity": [0, -1, 0],
|
|
5935
|
+
"loads": [
|
|
5936
|
+
{ "mass": 2, "at": "bracket.shelf", "note": "A shelf and what stands on it" }
|
|
5937
|
+
]
|
|
5938
|
+
}
|
|
5939
|
+
```
|
|
5940
|
+
|
|
5941
|
+
```sh
|
|
5942
|
+
npx cad check fix/shelf
|
|
5943
|
+
npx cad list fix/shelf
|
|
5944
|
+
npx cad order fix/shelf
|
|
5945
|
+
```
|
|
5946
|
+
|
|
5947
|
+
What the check says, screw by screw:
|
|
5948
|
+
|
|
5949
|
+
- `fasten.holes`: each screw has one axis from under its head through the part it passes into the part it ends in.
|
|
5950
|
+
- `fasten.clearance`: the bracket's and the plate's holes measure 3.5 mm, an M3 clearance hole as drawn.
|
|
5951
|
+
- `fasten.end`: the top front screw ends in a pilot, 2.9 mm and 8.8 mm deep; the bottom one in an insert's hole, 4 mm
|
|
5952
|
+
and 6.7 mm deep; each back screw in an M3 hex nut in its seat in the bracket, 5.7 mm across the flats for the nut's
|
|
5953
|
+
5.5 mm. The slot is found where it crosses the screw, and the nut drawn there, flats to the slot's walls.
|
|
5954
|
+
- `fasten.length`: M3x10 cap for the pilot (3.4 mm under the head and 6.6 mm into the plate, 1.2 mm short of
|
|
5955
|
+
bottoming out), M3x8 cap for the insert, M3x16 countersunk for the nuts.
|
|
5956
|
+
- `fasten.engagement`: 6.6 mm of thread in PLA where `m3.pilot_depth` asks 5 mm; 4.6 mm in the insert, where
|
|
5957
|
+
`fixings.insert_engagement` asks a diameter or the whole insert; the nut's whole 2.4 mm.
|
|
5958
|
+
- `fasten.seat`: the cap heads sit flat, 3 mm down their counterbores, and PLA under them takes 553 N, a tightening
|
|
5959
|
+
of 0.33 N m; the countersunk heads sit in an 89.8° countersink, flush with the back.
|
|
5960
|
+
- `fasten.access`: a 2.5 mm hex key reaches each cap head along its axis, and a 2 mm key each countersunk head, with
|
|
5961
|
+
nothing within the key's corners for its long arm's 58.5 mm or 52 mm (`hexkey`, ISO 2936).
|
|
5962
|
+
- `fasten.load`: with the shelf's 2 kg, the front screws hold 41.4 times the load, the pilot's thread in PLA first;
|
|
5963
|
+
the back screws 32.6 times, the screw first (the nut's thread is steel and not checked). Each holds its shear by
|
|
5964
|
+
friction 9.5 and 3.6 times over. The torque on the back screws is given (0.3 N m), because the check holds the
|
|
5965
|
+
pressure under a flat seat and not yet on a countersink's cone.
|
|
5966
|
+
|
|
5967
|
+
Each relation is reckoned as if it held the bracket alone, so the two figures are each the worst case. They rest on
|
|
5968
|
+
estimates (the plastic's strength in shear, the nut factor, the friction), and the finding names each one.
|
|
5969
|
+
|
|
5970
|
+
`cad list` gives the screws by thread, length and head, with what they weigh and how they are bought, and the two
|
|
5971
|
+
prints: the plate 5.9 g and the bracket 11.8 g, 17.7 g and about 20 minutes of printing, and 5 g of fixings.
|
|
5972
|
+
`cad order` gives the steps: the plate first, then the bracket with its four screws, each with its key and torque, the
|
|
5973
|
+
insert and the nuts named with them.
|
|
5974
|
+
|
|
5975
|
+
### Strong enough, and small
|
|
5976
|
+
|
|
5977
|
+
The design rule is the smallest part that carries its load about twice over. By hand, PLA at 39 MPa along the layers
|
|
5978
|
+
(`pla.strength`, a community figure), 2 kg is 19.6 N:
|
|
5979
|
+
|
|
5980
|
+
| Part | Where it is worst | Load | Stress | Margin |
|
|
5981
|
+
|---|---|---|---|---|
|
|
5982
|
+
| Bracket's web | At the foot, 23.6 mm in from the shelf's weight, a section 44 mm deep and 3 mm thick | 463 N mm | 0.48 MPa | 81 times |
|
|
5983
|
+
| Plate | At the lowest post, 19 mm above its bottom edge, which bears on the wall; the top wall screw pulls 780 / 64 = 12.2 N | 232 N mm | 7.7 MPa | 5 times |
|
|
5984
|
+
| Front screws | `fasten.load` | 16.3 N of pull | | 41.4 times |
|
|
5985
|
+
| Back screws | `fasten.load` | 65.2 N of pull | | 32.6 times |
|
|
5986
|
+
|
|
5987
|
+
The web's section modulus is 3 × 44² / 6 = 968 mm³ and the plate's 20 × 3² / 6 = 30 mm³; each stress is the moment
|
|
5988
|
+
over it. The web is stressed along its layers, since it lies flat as it prints. The plate is the part the load sizes:
|
|
5989
|
+
its 3 mm is the least that holds the wall screws' countersinks, and carries the shelf five times. The bracket is sized
|
|
5990
|
+
by its fixings, not its load: room for a head and its key, a nut's slot with plastic round it, and four screws far
|
|
5991
|
+
enough apart to share the pull. A thinner web would still carry the shelf, and would flap.
|
|
5992
|
+
|
|
5993
|
+
### Two mistakes, caught
|
|
5994
|
+
|
|
5995
|
+
A screw too short. The front screws named as M3x6 by hand:
|
|
5996
|
+
|
|
5997
|
+
```json projects/fix/assemblies/short.json
|
|
5998
|
+
{
|
|
5999
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/assembly.schema.json",
|
|
6000
|
+
"title": "The shelf bracket on front screws too short",
|
|
6001
|
+
"kind": "fit",
|
|
6002
|
+
"items": [
|
|
6003
|
+
{ "id": "plate", "object": "plate" },
|
|
6004
|
+
{ "id": "bracket", "object": "bracket", "rotate": [90, 0, 90], "at": ["0 - bracket.at", 0, "plate.thick + plate.stand"] }
|
|
6005
|
+
],
|
|
6006
|
+
"fits": [
|
|
6007
|
+
{ "a": "bracket", "b": "plate", "min": 0, "max": 0.05, "note": "The foot sits on the plate's posts" }
|
|
6008
|
+
],
|
|
6009
|
+
"fasten": [
|
|
6010
|
+
{ "screw": "M3x6 cap", "through": ["bracket"], "into": "plate", "at": ["bracket.pilot", "bracket.insert"], "note": "Front screws" },
|
|
6011
|
+
{ "screw": "M3 countersunk", "through": ["plate"], "into": "bracket", "at": ["bracket.nut1", "bracket.nut2"], "nut": true, "torque": 0.3, "note": "Back screws" }
|
|
6012
|
+
]
|
|
6013
|
+
}
|
|
6014
|
+
```
|
|
6015
|
+
|
|
6016
|
+
`npx cad check fix/short` fails, and says what would do:
|
|
6017
|
+
|
|
6018
|
+
```text
|
|
6019
|
+
✗ Front screws, screw 1 (bracket.pilot): M3x6 cap engages 2.6 mm of thread in pla (a plastic), 5.2 turns, where m3.pilot_depth asks 5 mm: M3x10 cap would do
|
|
6020
|
+
✗ Front screws, screw 2 (bracket.insert): M3x6 cap engages 2.6 mm of thread in the insert, 5.7 mm long, 5.2 turns, where fixings.insert_engagement asks a diameter of thread or the whole insert, 3 mm: M3x8 cap would do
|
|
6021
|
+
```
|
|
6022
|
+
|
|
6023
|
+
A screw that cannot be reached. Shelves usually go up plate first: screw the plate to the wall, then hang the bracket
|
|
6024
|
+
on it. With the wall in the assembly, drawn faint and never printed, and the plate fastened to it:
|
|
6025
|
+
|
|
6026
|
+
```json projects/fix/objects/wall.json
|
|
6027
|
+
{
|
|
6028
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
6029
|
+
"name": "wall",
|
|
6030
|
+
"title": "A patch of wall",
|
|
6031
|
+
"version": "0.1.0",
|
|
6032
|
+
"role": "reference",
|
|
6033
|
+
"variables": {
|
|
6034
|
+
"size": { "value": 120, "unit": "mm", "rule": "A patch of wall round the plate" },
|
|
6035
|
+
"deep": { "value": 20, "unit": "mm", "rule": "Enough to show where it is" }
|
|
6036
|
+
}
|
|
6037
|
+
}
|
|
6038
|
+
```
|
|
6039
|
+
|
|
6040
|
+
```js projects/fix/objects/wall.js
|
|
6041
|
+
// The wall the plate goes on: a reference, drawn faint and never printed. Its face is z = 0.
|
|
6042
|
+
import jscad from '@jscad/modeling'
|
|
6043
|
+
const { cuboid } = jscad.primitives
|
|
6044
|
+
|
|
6045
|
+
export function main (v) {
|
|
6046
|
+
return cuboid({ size: [v.size, v.size, v.deep], center: [0, 0, 0 - v.deep / 2] })
|
|
6047
|
+
}
|
|
6048
|
+
```
|
|
6049
|
+
|
|
6050
|
+
```json projects/fix/assemblies/wall-first.json
|
|
6051
|
+
{
|
|
6052
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/assembly.schema.json",
|
|
6053
|
+
"title": "The plate on the wall first",
|
|
6054
|
+
"kind": "fit",
|
|
6055
|
+
"items": [
|
|
6056
|
+
{ "id": "wall", "object": "wall" },
|
|
6057
|
+
{ "id": "plate", "object": "plate" },
|
|
6058
|
+
{ "id": "bracket", "object": "bracket", "rotate": [90, 0, 90], "at": ["0 - bracket.at", 0, "plate.thick + plate.stand"] }
|
|
6059
|
+
],
|
|
6060
|
+
"fits": [
|
|
6061
|
+
{ "a": "plate", "b": "wall", "fastens": true, "min": 0, "note": "The plate on the wall, on two wall screws" },
|
|
6062
|
+
{ "a": "bracket", "b": "plate", "min": 0, "max": 0.05, "note": "The foot sits on the plate's posts" }
|
|
6063
|
+
],
|
|
6064
|
+
"fasten": [
|
|
6065
|
+
{ "screw": "M3 cap", "through": ["bracket"], "into": "plate", "at": ["bracket.pilot", "bracket.insert"], "note": "Front screws" },
|
|
6066
|
+
{ "screw": "M3 countersunk", "through": ["plate"], "into": "bracket", "at": ["bracket.nut1", "bracket.nut2"], "nut": true, "torque": 0.3, "note": "Back screws" }
|
|
6067
|
+
]
|
|
6068
|
+
}
|
|
6069
|
+
```
|
|
6070
|
+
|
|
6071
|
+
`npx cad check fix/wall-first` fails on the back screws and on the order, naming the wall:
|
|
6072
|
+
|
|
6073
|
+
```text
|
|
6074
|
+
✗ Back screws, 2 M3 countersunk screws: a 2 mm hex key cannot reach the head: wall stands over it, 0.05 mm up the screw's axis and goes on first (The plate on the wall, on two wall screws), and a ball-end key tilted 25° does not clear it either. Move the screw, open a way through wall, or fit wall after
|
|
6075
|
+
✗ the screw of "Back screws" can't be reached in any order: wall stands over it and goes on first (The plate on the wall, on two wall screws)
|
|
6076
|
+
```
|
|
6077
|
+
|
|
6078
|
+
So this bracket goes on its plate at the bench, and the plate then goes on the wall: its wall screws are clear of the
|
|
6079
|
+
foot, and `cad order fix/shelf` builds it in that order. The other way to hang it plate first is to bring every screw
|
|
6080
|
+
in from the front: four front screws into pilots or inserts, and no nut.
|
|
6081
|
+
|
|
6082
|
+
### The build page
|
|
6083
|
+
|
|
6084
|
+
`npx cad link fix/shelf --md` gives a link to the model page. Since the assembly has a `fasten`, the link carries a build
|
|
6085
|
+
page: the prints with their grams and time, a Fasteners table (each screw, nut and insert, how many, their grams, and
|
|
6086
|
+
the packs to buy with what is spare), and the steps of `cad order`, each with its screws, the key and the torque to
|
|
6087
|
+
tighten to. The screws, the insert and the nuts are drawn faint in place.
|
|
6088
|
+
|
|
6089
|
+
### What is measured, and what waits on the bench
|
|
6090
|
+
|
|
6091
|
+
The pilot is the X1C's own measured figure. The insert's hole, the nut's slot, the counterbore's room for a head and
|
|
6092
|
+
the strength figures under `fasten.load` are not, and their findings say so. Print 7 in
|
|
6093
|
+
`examples/bench/projects/benchmarks/MEASURE.md`, the fixings coupon, settles them: pilots at five sizes, insert holes,
|
|
6094
|
+
nut pockets and slots at three fits, a counterbore and printed threads. Its results go back with `cad measured
|
|
6095
|
+
benchmarks/fixings-test <rule>=<figure>`, and every design drawn from `v.fixings` follows them the next time it is
|
|
6096
|
+
built.
|