@rulecad/cad 0.9.0 → 0.10.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/AGENTS.md +21 -6
- package/CHANGELOG.md +320 -0
- package/EXAMPLES.md +22 -17
- package/README.md +192 -40
- package/bin/cad.mjs +465 -80
- package/lib/assembly.mjs +68 -33
- package/lib/cache-file.mjs +105 -0
- package/lib/code-text.mjs +28 -0
- package/lib/design-imports.mjs +127 -0
- package/lib/design.mjs +251 -55
- package/lib/designshapes.mjs +142 -0
- package/lib/edit.mjs +24 -2
- package/lib/estimates.mjs +51 -0
- package/lib/fasten.mjs +11 -5
- package/lib/fe-key.mjs +29 -0
- package/lib/fittings.mjs +20 -15
- package/lib/fixings.mjs +17 -4
- package/lib/framebuild.mjs +1 -1
- package/lib/framegen.mjs +9 -1
- package/lib/frames.mjs +6 -2
- package/lib/framesize.mjs +8 -81
- package/lib/host.mjs +7 -3
- package/lib/kit.mjs +5 -5
- package/lib/list.mjs +29 -21
- package/lib/loads.mjs +35 -23
- package/lib/measured.mjs +738 -98
- package/lib/motors.mjs +9 -29
- package/lib/names.mjs +15 -0
- package/lib/optimise.mjs +34 -25
- package/lib/order.mjs +4 -10
- package/lib/parts.mjs +3 -0
- package/lib/rules.mjs +2 -1
- package/lib/sandbox-hooks.mjs +109 -15
- package/lib/sandbox-lock.mjs +225 -0
- package/lib/sandbox-preload.mjs +2 -2
- package/lib/sandbox-run.mjs +22 -24
- package/lib/sandbox.mjs +173 -30
- package/lib/sheet.mjs +114 -3
- package/lib/versions.mjs +195 -32
- package/lib/workspace.mjs +3 -2
- package/package.json +11 -11
- package/schemas/assembly.schema.json +1 -1
- package/schemas/project.schema.json +6 -0
- package/templates/coupons/MEASURE.md +109 -0
- package/templates/coupons/assemblies/fixings-test.json +20 -0
- package/templates/coupons/assemblies/slot-test.json +11 -0
- package/templates/coupons/objects/fixings-coupon.js +88 -0
- package/templates/coupons/objects/fixings-coupon.json +26 -0
- package/templates/coupons/objects/holds-coupon.js +130 -0
- package/templates/coupons/objects/holds-coupon.json +42 -0
- package/templates/coupons/objects/slot-coupon.js +89 -0
- package/templates/coupons/objects/slot-coupon.json +29 -0
- package/templates/coupons/project.json +10 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Coupons: measure your printer
|
|
2
|
+
|
|
3
|
+
Every hole, pocket and slot the kit draws starts from a figure someone else measured, or an estimate. These coupons
|
|
4
|
+
settle them on your own printer and plastic: each prints a feature at the kit's figure and a step or two either side,
|
|
5
|
+
with its figure beside it. Find the one that works best, write its figure back with `cad measured`, and every design in
|
|
6
|
+
this workspace follows it the next time it is checked or exported.
|
|
7
|
+
|
|
8
|
+
`npx cad coupons` put this project in your workspace. The rows below keep the numbers they have in the kit's full bench
|
|
9
|
+
sheet (`examples/bench/projects/benchmarks/MEASURE.md` in the rulecad repository), so cad's messages and the kit's notes
|
|
10
|
+
name the same row.
|
|
11
|
+
|
|
12
|
+
**Print in your usual plastic, at 0.2 mm layers, four walls, 25% infill.** Keep the same spool for the whole set.
|
|
13
|
+
|
|
14
|
+
## What to print
|
|
15
|
+
|
|
16
|
+
| Print | Parts | Solid mass | Measures |
|
|
17
|
+
|---|---|---|---|
|
|
18
|
+
| 1. Fixings coupons (once in PLA, once in PETG if you print both) | `fixings-coupon`, and `holds-coupon` behind it on the same plate: a plate and 13 loose pieces (`cad plates coupons/fixings-test` lays out both) | 55 g and 38 g, 93 g on one plate about 195 by 194 mm, about 100 minutes | 22 to 28, 40 to 47 |
|
|
19
|
+
| 2. Slot coupon (when you build with aluminium beams) | `slot-coupon` (26 loose pieces; `cad plates coupons/slot-test`) | 40 g, about 45 minutes | 29 to 33 |
|
|
20
|
+
|
|
21
|
+
`cad export coupons/fixings-coupon` (and `holds-coupon`, `slot-coupon`) writes each as a 3MF for Bambu Studio.
|
|
22
|
+
|
|
23
|
+
## What you need
|
|
24
|
+
|
|
25
|
+
| | |
|
|
26
|
+
|---|---|
|
|
27
|
+
| **For the fixings coupon** | Socket cap screws: M2 × 6, M2.5 × 6, M3 × 6, M3 × 8, M4 × 8, M5 × 16; M3 and M4 hex nuts; CNC Kitchen heat-set inserts, M2 × 3 and M3 × 5.7, and a soldering iron with an insert tip; steel bolts or set screws M6 × 16, M8 × 20 and M10 × 25 or longer; a spanner |
|
|
28
|
+
| **For the holds coupon** | Steel dowel pins 3 × 12 mm (ISO 8734 or ISO 2338 m6): two; a few 12 mm lengths of 1.75 mm filament, cut square; disc magnets 6 × 3 mm and 8 × 3 mm, N35 or stronger: three 6 × 3 and four 8 × 3 (sold in tens); a steel M8 hex nut and an M8 washer, for the pull bolt; two blocks of wood no more than 20 mm thick (18 mm plywood offcuts) and a G-clamp; a loop of strong cord; a luggage scale (it reads to 50 kg); a vice, or two scraps of wood to press magnets between |
|
|
29
|
+
| **For the slot coupon** | An offcut of your own beam, 50 to 100 mm long, cut square at one end; M2.5 hex nuts and M2.5 × 8 screws for slot 6, M5 hex nuts and M5 × 10 screws for slot 8; one of the bought slot nuts made for your beam (slide-in or drop-in) |
|
|
30
|
+
|
|
31
|
+
## The measurements
|
|
32
|
+
|
|
33
|
+
Each row's command writes the figure back, in this workspace's copy of the rule set (`rules/x1c.json`, `rules/pla.json`,
|
|
34
|
+
`rules/slot-8.json`), marked as measured with the date. Give it on its own, as the rows show, or after one of your own
|
|
35
|
+
assemblies (`cad measured home/lidded-box x1c.pilot_m3=2.9`) to see what it moves there. `cad measured --export` then
|
|
36
|
+
prints every figure you measured as a change to the kit's rule sets, to send to the kit (see the end of this sheet).
|
|
37
|
+
|
|
38
|
+
| # | What | How | The kit assumes | Measured |
|
|
39
|
+
|---|---|---|---|---|
|
|
40
|
+
| 22 | Pilots, rows M2, M2.5, M3, M4, M5 | Each figure is the hole as drawn. Drive a screw of that size into each by hand with a driver. The best is the smallest the screw goes into straight, without splitting the boss, that turns with an even drag and cannot be pulled out by hand. `cad measured x1c.pilot_m4=<figure>` (and `pilot_m2`, `pilot_m2_5`, `pilot_m3`, `pilot_m5`; from the PETG print, `x1c.pilot_m4_petg`) | M2 2.1, M2.5 2.5, M3 2.9, M4 3.75, M5 4.7 mm | |
|
|
41
|
+
| 23 | Insert holes, rows IM2, IM3 | Each figure is the hole as drawn. Set an insert in each with the iron. The best goes in straight and flush, pushes no ring of plastic up round it, and does not turn when a screw is tightened in it. `x1c.insert_m2=<figure>`, `x1c.insert_m3=<figure>` (`_petg` from the PETG print) | 3.2 and 4.0 mm, the insert maker's | |
|
|
42
|
+
| 24 | Nut pockets, rows NM3, NM4 | Each figure is the clearance across the flats. Press a nut in with a thumb, then drive a screw into it from the top. The best is the tightest the nut goes into by hand and does not turn in as the screw is driven. `x1c.nut_fit=<figure>` | 0 mm (a snug fit) | |
|
|
43
|
+
| 25 | Nut slots, rows TM3 and TM4 (the back edge) | Each figure is the clearance across the flats. Drop a nut into the slot from the top, then run a screw in from the coupon's back edge through it and tighten. The best is the tightest the nut drops into by hand, that keeps it when the coupon is turned over, and where it does not turn as the screw tightens. `x1c.nut_slip=<figure>` | 0.1 mm (`x1c.slip`) | |
|
|
44
|
+
| 26 | Counterbore, CM3 | Drive an M3 × 8 cap screw in: its head sits wholly under the top face, a hex key reaches it, and it tightens in the pilot under it. If the head rubs, raise `x1c.fit` | `x1c.fit` 0.2 mm each side | |
|
|
45
|
+
| 27 | Printed threads, rows M6P, M8P, M10P | Each figure is the gap on the radius between the printed thread and a bought bolt. Turn a bolt into each by hand. The best is the tightest it turns all the way into smoothly, with no binding and no wobble, and that does not strip when tightened firmly with a spanner. Where the sizes differ, take the figure two of the three agree on. `x1c.thread_gap=<figure>` | 0.2 mm, an estimate | |
|
|
46
|
+
| 28 | Thread flanks, M8P against M8S | Rows M8P and M8S are the same holes in the two forms a printed thread can take: P has its down-facing flanks laid back to 45° (the kit's default, easy to print, about 51% of the standard's flank overlap at 0.2 mm), S keeps the standard's 60° form (more overlap, 63%, but its down-facing flanks overhang 60°). Compare them at each gap, in this order: it holds (tighten a bolt firmly with a spanner: no stripping, the least wobble), it turns smoothly (no catching all the way in), it prints clean (look into the hole with a light: whole teeth, no drooping or strings on the flanks' undersides). The form that wins the first test wins, and the next test settles a tie. Write 45 for P or 60 for S: `x1c.thread_flank=45`. It records the result; changing the kit's default form is a decision of its own | 45, the printed form | |
|
|
47
|
+
| 29 | Tongues, slot 6 and slot 8 | Each tongue's figure is its clearance a side in the beam's opening. Lay the head on the beam's face with the tongue in the slot and push it the beam's length from the square end. The best is the tightest that slides all the way by hand, and does not rattle when the beam is shaken across. `cad measured x1c.slot_fit=<figure>` | 0.2 mm a side (`x1c.fit`, community) | |
|
|
48
|
+
| 30 | Carriers, slot 6 (M2.5) and slot 8 (M5) | Each carrier's figure is its clearance a side all round the slot. Drop its nut into its side (or its end), slide it into the beam from the square end, and run a screw into it through a scrap of plate. The best is the tightest that slides the beam's length by hand, nut in, and that pulls up square when the screw is tightened. Where it is looser than the tongue in 29, write the carrier's figure to `x1c.slot_fit` instead: a part that fills the slot needs the larger | 0.2 mm a side | |
|
|
49
|
+
| 31 | Printed slots, slot 6 and slot 8 | Each block's figure is how far its printed slot is opened a side. Slide a bought slot nut for your beam down each from the top. The best is the tightest it runs the length of by hand without catching, and that holds it upright when the block is tipped on its side. `x1c.printed_slot_fit=<figure>` | 0.2 mm a side | |
|
|
50
|
+
| 32 | The slot itself, by caliper | On the beam's square end: the opening across the face, the lips' thickness, the cavity's width under the lips and its depth from the face (the depth rod of the calipers). Write each to the slot set your beam's profile names, or to `slot-6` or `slot-8` for an unbranded beam: `cad measured slot-8.opening=<mm> slot-8.lip_thickness=<mm> slot-8.cavity_width=<mm> slot-8.cavity_depth=<mm>`. They go in your workspace's copy of the set as measured, and cad refuses figures that make no slot | slot 6: opening 6, lips 1.5, cavity 12 wide, 5.5 deep. Slot 8: 8, 2.2, 16.5, 9 (community figures) | |
|
|
51
|
+
| 33 | The fit, confirmed | With 29 to 32 written back, print again the carrier whose figure you wrote to `x1c.slot_fit`: `cad export coupons/slot-coupon --part slot-8-carrier-<figure>` (or `slot-6-`). It is now drawn from your measured slot. It should slide as that carrier did in 30; a design's own carriers take the same fit with `printer: v.x1c` | | |
|
|
52
|
+
| 40 | Snap pins' barb, the six loose snap pins | Each pin has one, two or three notches down its foot: barb 0.3, 0.4 and 0.5 mm past its peg. Hold the plate over the table's edge so a barb can come out underneath, push each 4 mm pin from the top through the middle socket of row S4, and pull it back by its foot; then the 3 mm pins in S3. The best is the deepest barb that still clicks through by hand and holds when pulled firmly. `cad measured x1c.snap_barb=<figure>`. It records the result: pins are still drawn with a 0.4 mm barb unless their name says another (`snap pin 4x6 barb 0.5`) | 0.4 mm | |
|
|
53
|
+
| 41 | Snap pin sockets, rows S3 and S4 | Each figure is the gap round the peg, each side, as drawn. Push the pin that won 40 through each socket of its row. The best is the tightest it clicks through by hand, and that does not rock once through. `x1c.snap_clearance=<figure>` | 0.05 mm, measured on the launcher's fit test plate with 4 mm pins (this row's tightest socket is 0.1) | |
|
|
54
|
+
| 42 | Pins pressed, rows D3P and FP | Each figure is how much smaller the hole is drawn than the pin, past the hole compensation. Press a 3 × 12 mm dowel into each hole of D3P by hand or in a vice, and a 12 mm length of filament into each of FP. The best goes in straight without splitting its boss and cannot be pulled out by hand. Where the two rows differ, write the dowel's. `x1c.pin_press=<figure>` | 0.05 mm, an estimate | |
|
|
55
|
+
| 43 | Pins slipping, rows D3S and FS | Each figure is how much larger the hole is drawn than the pin, past the hole compensation. Slide a dowel into each hole of D3S by hand and turn it, then a length of filament in FS. The best is the tightest it slides into and turns freely in, without rattling. `x1c.pin_slip=<figure>` | 0.2 mm, an estimate | |
|
|
56
|
+
| 44 | Magnet pockets, rows 6x3 and 8x3 | Each figure is how much smaller the pocket is drawn than the magnet, past the hole compensation. Press a magnet into each with a thumb, or in a vice between two scraps of wood. The best goes in flush without splitting the wall, and stays in when the plate is turned over and tapped on the table. Push each out again with a length of filament through the hole under it. `x1c.magnet_press=<figure>`. The glued fit is not printed here: keep `x1c.magnet_glue` unless a glued magnet will not go in, and then raise it by 0.1 | 0.1 mm, an estimate. The kit warns that it stretches a pocket's wall close to PLA's strength (24.6 MPa for 8 × 3, 32.8 MPa for 6 × 3, against 39) | |
|
|
57
|
+
| 45 | Crush ribs, row 8x3R | Each figure is how far inside the magnet the ribs' tips stand, past the hole compensation. Press an 8 × 3 magnet into each by hand. The best goes in flush by hand and holds when the plate is turned over and tapped. `x1c.magnet_crush=<figure>` | 0.2 mm, an estimate | |
|
|
58
|
+
| 46 | Printed bolts in printed nuts, rows M8N and M10N, and the six loose bolts | Each figure is the thread gap on the radius, half of it drawn in the nut and half in the bolt; each loose bolt has one, two or three notches down its head for the first, second and third figure of its row. Turn each bolt through its own nut by hand. The best is the tightest that turns all the way through smoothly, without binding or wobble, and does not strip when tightened firmly by hand on its head (a printed thread takes no spanner). This is a second reading of the gap in 27: the kit draws a printed pair from the same `x1c.thread_gap`. Where the two differ, write the larger, so both turn | 0.2 mm, an estimate | |
|
|
59
|
+
| 47 | A printed bolt's strength across its layers, the pull bolt | Last. Clamp two blocks of wood to the table, 10 mm apart and standing past its edge. The blocks are no more than 20 mm thick, an 18 mm plywood offcut for instance, so the nut reaches the thread with the waist hanging below them. Push the pull bolt up through the gap from below, put an M8 washer and a steel M8 nut on its thread, and run the nut down finger tight: the whole waist and both its cones hang below the blocks. Tie a loop of cord round the waist above the head, hook the luggage scale in it and pull straight down, slowly, until the waist breaks. The scale's peak in kilograms, times 9.81, over the waist's 9.62 mm² (3.5 mm across), is the strength in MPa: kilograms × 1.02. `cad measured pla.strength_z=<MPa>` (from the PETG print, `petg.strength_z`). Wear glasses | 38.2 kg (PLA's 39 MPa along its layers: its data sheet gives no figure across them); 22.6 kg for PETG (23 MPa) | |
|
|
60
|
+
|
|
61
|
+
The fixings coupon (22 to 28) is one plate with a figure beside every feature, and each row named on its left: a
|
|
62
|
+
pilot row by its thread (M4), then I for insert holes, N for nut pockets, T for nut slots, C for the counterbore,
|
|
63
|
+
and a printed thread by its size and form (M8P, M8S). The figure beside a feature is the one to write back. Print it
|
|
64
|
+
once in PLA and once in PETG, both upright as it is drawn. A pilot or an insert hole is written per plastic: the PLA
|
|
65
|
+
figure without a suffix, the PETG one with `_petg`. The nut fits, the thread gap and the flank form are one figure per
|
|
66
|
+
printer: write the PLA figure, and note the PETG one in the last column where it differs. `cad history`
|
|
67
|
+
then shows each against what the kit drew before.
|
|
68
|
+
|
|
69
|
+
The holds coupon (40 to 47) measures what holds two parts together without a steel screw. It prints beside the fixings
|
|
70
|
+
coupon, on the same plate: a plate with a row for each fit, named on its left, and 13 loose pieces. S3 and S4 are
|
|
71
|
+
sockets for 3 and 4 mm snap pins, their figure the gap round the peg; D3P and FP are holes a 3 mm dowel or 1.75 mm
|
|
72
|
+
filament is pressed into, D3S and FS holes it turns in; 6x3 and 8x3 are pockets disc magnets are pressed into, 8x3R a
|
|
73
|
+
pocket with three crush ribs; M8N and M10N are printed nuts, a hex nut's height, for printed bolts. The loose pieces are
|
|
74
|
+
the six printed bolts for those nuts, the pull bolt with its waist, and six snap pins, three of each size. The pull
|
|
75
|
+
bolt prints standing on its 13 mm head, as drawn, so its waist breaks across its layers: lying down it would break
|
|
76
|
+
along them and measure the strength the data sheet already gives. Its waist is 3.5 mm across and 3.5 mm long, under
|
|
77
|
+
38 mm of shank and thread: a sideways push of 1 N at its tip as the nozzle passes stresses the waist about 9.9 MPa
|
|
78
|
+
and sways the tip about 0.46 mm (beam bending, an estimate), where a 3 mm waist 6 mm long took 16 MPa and 1 mm. The
|
|
79
|
+
X1C's bed moves only up and down, so nothing shakes it sideways. If it wobbles or snaps all the same, print it alone,
|
|
80
|
+
after the plate, slowed for cooling as the slicer does for a small layer. A loose piece
|
|
81
|
+
says its figure by notches: one, two or three, for the first, second and third figure of its row. The snap sockets go
|
|
82
|
+
through the plate, and each magnet pocket has a hole under it to push the magnet out, so its first layer has a few
|
|
83
|
+
round holes; everything else stands on a plain first layer. Every feature is drawn from the printer's rules through
|
|
84
|
+
@rulecad/fixings, at the kit's figure and a step either side, so the coupon printed again after cad measured is centred
|
|
85
|
+
on yours. The fits are one figure per printer: write the PLA figure, and note the PETG one where it differs. The pull
|
|
86
|
+
bolt measures the plastic, so it is written per plastic. `cad measured` refuses a figure no fit of its kind can be, and
|
|
87
|
+
a strength across the layers above the plastic's strength along them. `cad history` then shows
|
|
88
|
+
each against what the kit drew before.
|
|
89
|
+
|
|
90
|
+
The slot coupon (29 to 33) is 26 loose pieces, each with its figure, the clearance a side, on top: in the front row
|
|
91
|
+
five tongues for slot 6 and five for slot 8 (a T-shaped key, its head on the face and its tongue in the opening), in
|
|
92
|
+
the middle row five carriers for each (a block that slides in the slot holding a hex nut), and at the back three short
|
|
93
|
+
printed slots for each, standing on end. The slot 8 pieces are the larger. Slot 6 is the slot of 20 mm beams, slot 8
|
|
94
|
+
of 30 and 40 mm beams. Every piece is drawn from the slot's rule set, so once 32 is written back the coupon prints from
|
|
95
|
+
your own slot. `cad history` then shows each figure against what the kit drew before.
|
|
96
|
+
|
|
97
|
+
## Sending your figures to the kit
|
|
98
|
+
|
|
99
|
+
`cad measured --export` prints every figure measured in this workspace that the kit does not hold yet, as a change to
|
|
100
|
+
the kit's own rule sets (a diff, the form a pull request takes). Save it (`npx cad measured --export > measured.diff`)
|
|
101
|
+
and send it to the kit, with the printer, the plastic and the spool you printed with: open an issue at
|
|
102
|
+
https://github.com/JoniBach/rulecad/issues and attach the file, or apply it to a copy of the repository and open a pull
|
|
103
|
+
request. Measurements from many printers are how the kit's estimates become figures people can trust.
|
|
104
|
+
|
|
105
|
+
## Words used
|
|
106
|
+
|
|
107
|
+
**Pilot:** a hole sized for a screw to cut its own thread. **Heat-set insert:** a threaded brass sleeve melted into a
|
|
108
|
+
hole. **Hole compensation:** how much smaller a printed hole comes out than it was drawn. **Slot nut:** a nut made to
|
|
109
|
+
slide or drop into an aluminium beam's slot.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Fixings coupons",
|
|
3
|
+
"kind": "fit",
|
|
4
|
+
"description": "The fixings coupon and, behind it on the same plate, the holds coupon: write each result back with cad measured <rule>=<value> (MEASURE.md, rows 22 to 28 and 40 to 47), and cad history keeps it against what the kit drew before. Both fit the X1C's 256 mm bed together, about 195 by 194 mm: the holds coupon 195.3 by 76.8 mm, placed 117 mm behind the fixings coupon's front edge, and the fixings coupon 98.6 by 111.8 mm.",
|
|
5
|
+
"items": [
|
|
6
|
+
{
|
|
7
|
+
"id": "coupon",
|
|
8
|
+
"object": "fixings-coupon"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "holds",
|
|
12
|
+
"object": "holds-coupon",
|
|
13
|
+
"at": [
|
|
14
|
+
0,
|
|
15
|
+
117,
|
|
16
|
+
0
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Slot coupon",
|
|
3
|
+
"kind": "fit",
|
|
4
|
+
"description": "The slot coupon on its own: write each result back with cad measured <rule>=<value> (MEASURE.md, rows 29 to 33), and cad history keeps it against what the kit drew before.",
|
|
5
|
+
"items": [
|
|
6
|
+
{
|
|
7
|
+
"id": "coupon",
|
|
8
|
+
"object": "slot-coupon"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// The fixings coupon: every hole a screw, a nut or an insert needs, at sizes either side of the one the kit draws, so
|
|
2
|
+
// one print settles them for this printer and plastic. Each feature stands in its own boss on a thin base, and every
|
|
3
|
+
// hole ends above the base (the nut slots' screws come in from an edge, lying down, with a teardrop's roof), so the
|
|
4
|
+
// first layer is one plain rectangle and nothing needs a support. Each row is named on the left, and each feature
|
|
5
|
+
// carries the figure to write back (MEASURE.md, rows 22 to 28).
|
|
6
|
+
// Every size comes from v.fixings; each row steps by the printer's hole compensation either side of it.
|
|
7
|
+
import jscad from '@jscad/modeling'
|
|
8
|
+
const { cylinder, cylinderElliptic, roundedRectangle, circle } = jscad.primitives
|
|
9
|
+
const { extrudeLinear } = jscad.extrusions
|
|
10
|
+
const { translate } = jscad.transforms
|
|
11
|
+
const { hull } = jscad.hulls
|
|
12
|
+
const { offset } = jscad.expansions
|
|
13
|
+
const { measureBoundingBox } = jscad.measurements
|
|
14
|
+
|
|
15
|
+
export function main (v) {
|
|
16
|
+
const f = v.fixings, base = v.base, wall = v.wall, step = v.step, seg = v.segments
|
|
17
|
+
const fig = (x) => String(Number(x.toFixed(2))) // a figure as it is labelled and written back
|
|
18
|
+
const around = (centre, n) => Array.from({ length: n }, (_, i) => centre + (i - (n - 1) / 2) * step)
|
|
19
|
+
const width = (text) => { const [lo, hi] = measureBoundingBox(v.shapes.text({ text, height: v.label, stroke: v.stroke })); return hi[0] - lo[0] }
|
|
20
|
+
const say = (text, x, y, z) => translate([x, y, z], extrudeLinear({ height: v.emboss }, v.shapes.text({ text, height: v.label, stroke: v.stroke })))
|
|
21
|
+
// A plain round hole going down from the top, with the lead-in the kit gives a blind hole, its cutter past the top
|
|
22
|
+
const bore = (d, depth, lead, x, y, top) => v.ops.union(
|
|
23
|
+
translate([x, y, top - depth / 2 + 1 / 2], cylinder({ radius: d / 2, height: depth + 1, segments: seg })),
|
|
24
|
+
translate([x, y, top - lead / 2], cylinderElliptic({ height: lead, startRadius: [d / 2, d / 2], endRadius: [d / 2 + lead, d / 2 + lead], segments: seg })))
|
|
25
|
+
// What a feature stands in, its outline rising from the bed to its top, flared at 45° where it meets the base
|
|
26
|
+
const stand = (outline, top) => v.ops.union(extrudeLinear({ height: top }, outline),
|
|
27
|
+
hull(extrudeLinear({ height: base }, offset({ delta: v.root, corners: 'round', segments: seg }, outline)), extrudeLinear({ height: base + v.root }, outline)))
|
|
28
|
+
|
|
29
|
+
// ---------- the features, each { label, across (its footprint, along the row), deep (across it), top, make(x, y) } ----------
|
|
30
|
+
const round = (across, top, cut) => ({ across, deep: across, top, make: (x, y) => ({ solid: stand(circle({ radius: across / 2, center: [x, y], segments: seg }), top), cut: cut(x, y) }) })
|
|
31
|
+
const pilots = (t) => {
|
|
32
|
+
const h = f.holeModel(t, { kind: 'pilot' }), sizes = around(h.diameter, v.pilots)
|
|
33
|
+
return { name: t, items: sizes.map((d) => ({ label: fig(d), ...round(Math.max(...sizes) + 2 * wall, base + h.depth, (x, y) => bore(d, h.depth, h.lead, x, y, base + h.depth)) })) }
|
|
34
|
+
}
|
|
35
|
+
const inserts = (t) => {
|
|
36
|
+
const h = f.holeModel(t, { kind: 'insert' }), sizes = around(h.diameter, v.fits), least = f.fixingModel(t).figures.insert_wall.value
|
|
37
|
+
return { name: `I${t}`, items: sizes.map((d) => ({ label: fig(d), ...round(Math.max(...sizes) + 2 * Math.max(wall, least), base + h.depth, (x, y) => bore(d, h.depth, h.lead, x, y, base + h.depth)) })) }
|
|
38
|
+
}
|
|
39
|
+
// A nut pocket from the top over the screw's clearance hole, as deep again below it so the screw's end passes the nut
|
|
40
|
+
const pockets = (t) => {
|
|
41
|
+
const p = f.nutPocketModel(t), fits = around(p.clearance, v.fits), corner = f.nutPocketModel(t, { fit: Math.max(...fits) }).corner, top = base + 2 * p.depth
|
|
42
|
+
return { name: `N${t}`, items: fits.map((fit) => ({ label: fig(fit), ...round(corner + 2 * wall, top, (x, y) => v.ops.union(f.nutPocket(t, { fit, at: [x, y, top], into: '-z' }), f.hole(t, { depth: top - base, through: false, at: [x, y, top] }))) })) }
|
|
43
|
+
}
|
|
44
|
+
// A cap head's counterbore over its clearance hole, then a pilot: a screw as long as the two seats its head
|
|
45
|
+
const counterbore = (t) => {
|
|
46
|
+
const c = f.counterboreModel(t), p = f.holeModel(t, { kind: 'pilot' }), length = 2 * c.depth, top = base + p.depth + length
|
|
47
|
+
return { name: `C${t}`, items: [{ label: fig(c.diameter), ...round(c.diameter + 2 * wall, top, (x, y) => v.ops.union(f.counterbore(t, { length, at: [x, y, top], into: '-z' }), f.hole(t, { kind: 'pilot', at: [x, y, top - length] }))) }] }
|
|
48
|
+
}
|
|
49
|
+
// A nut slot the nut drops into from the top, across a screw lying along y: the screw comes in through the coupon's
|
|
50
|
+
// back edge, through the nut, and on into the block for its end
|
|
51
|
+
const traps = (t) => {
|
|
52
|
+
const m = f.nutTrapModel(t, { depth: 1, axis: 'y', into: '-z' }), fits = around(m.clearance, v.fits), widest = f.nutTrapModel(t, { depth: 1, axis: 'y', into: '-z', fit: Math.max(...fits) })
|
|
53
|
+
const half = widest.reach - 1, depth = half + wall, axisZ = base + wall + half, top = axisZ + depth, deep = 2 * (wall + m.gap), across = widest.width + 2 * wall
|
|
54
|
+
return { name: `T${t}`, edge: true, items: fits.map((fit) => ({ label: fig(fit), across, deep, top, make: (x, y) => {
|
|
55
|
+
const face = y + deep / 2, slot = face - wall - m.gap / 2 // y is the block's middle; its open face is on the back edge
|
|
56
|
+
return { solid: stand(roundedRectangle({ size: [across, deep], center: [x, y], roundRadius: wall / 2, segments: seg }), top),
|
|
57
|
+
cut: v.ops.union(f.nutTrap(t, { fit, depth, axis: 'y', into: '-z', at: [x, slot, top] }), f.hole(t, { depth: deep - wall, through: false, at: [x, face, axisZ], into: '-y' })) }
|
|
58
|
+
} })) }
|
|
59
|
+
}
|
|
60
|
+
// A printed thread for a bought screw, at three gaps, in the form its flanks are drawn
|
|
61
|
+
const threads = (t, flanks) => {
|
|
62
|
+
const gaps = around(f.holeModel(t, { kind: 'thread', mate: 'bought', flanks }).threaded.clearance, v.fits)
|
|
63
|
+
const made = gaps.map((gap) => f.holeModel(t, { kind: 'thread', mate: 'bought', gap, flanks })), across = Math.max(...made.map((h) => h.diameter)) + 2 * wall
|
|
64
|
+
return { name: `${t}${flanks === 'standard' ? 'S' : 'P'}`, items: gaps.map((gap, i) => ({ label: fig(gap), ...round(across, base + made[i].depth, (x, y) => f.hole(t, { kind: 'thread', mate: 'bought', gap, flanks, at: [x, y, base + made[i].depth] })) })) }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ---------- the rows, front to back ----------
|
|
68
|
+
const rows = [[pockets('M3'), pockets('M4')], [pilots('M2'), pilots('M2.5')], [pilots('M3'), inserts('M2')], [pilots('M4'), inserts('M3')], [pilots('M5'), counterbore('M3')],
|
|
69
|
+
[threads('M6', 'printed'), threads('M10', 'printed')], [threads('M8', 'printed'), threads('M8', 'standard')], [traps('M3'), traps('M4')]]
|
|
70
|
+
const solids = [], cuts = [], labels = []
|
|
71
|
+
let y = v.gap, length = 0
|
|
72
|
+
for (const row of rows) {
|
|
73
|
+
const deep = Math.max(...row.flatMap((g) => g.items.map((it) => it.deep))), line = y + v.label / 2, mid = y + v.label + v.gap + deep / 2
|
|
74
|
+
let x = v.gap
|
|
75
|
+
for (const g of row) {
|
|
76
|
+
const nameWidth = width(g.name)
|
|
77
|
+
labels.push(say(g.name, x + nameWidth / 2, mid, base)); x += nameWidth + v.gap
|
|
78
|
+
for (const it of g.items) {
|
|
79
|
+
const pitch = Math.max(it.across, width(it.label) + v.gap), cx = x + pitch / 2, cy = g.edge ? mid + deep / 2 - it.deep / 2 : mid, m = it.make(cx, cy)
|
|
80
|
+
solids.push(m.solid); cuts.push(m.cut); labels.push(say(it.label, cx, line, base)); x += pitch + v.gap
|
|
81
|
+
}
|
|
82
|
+
x += v.gap
|
|
83
|
+
}
|
|
84
|
+
length = Math.max(length, x); y += deep + v.label + v.gap * 2
|
|
85
|
+
}
|
|
86
|
+
const plate = extrudeLinear({ height: base }, roundedRectangle({ size: [length, y], center: [length / 2, y / 2], roundRadius: v.corner, segments: seg }))
|
|
87
|
+
return v.ops.union(v.ops.subtract(v.ops.union(plate, ...solids), ...cuts), ...labels)
|
|
88
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
3
|
+
"name": "fixings-coupon",
|
|
4
|
+
"title": "Fixings coupon",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"uses": [
|
|
7
|
+
"x1c"
|
|
8
|
+
],
|
|
9
|
+
"engine": "manifold",
|
|
10
|
+
"orientation": "Flat on the bed, every hole opening upward: the base is the first layer",
|
|
11
|
+
"description": "Pilots for M2 to M5 at five sizes, heat-set insert holes for M2 and M3, hex nut pockets and side slots for M3 and M4 at three fits, an M3 counterbore, and printed M6, M8 and M10 threads at three gaps, M8 in both flank forms. Each figure is the one to write back with cad measured (MEASURE.md, rows 22 to 28). Print once per printer and plastic.",
|
|
12
|
+
"variables": {
|
|
13
|
+
"base": { "value": "x1c.layer * 6", "unit": "mm", "rule": "The base every feature stands on: six layers, the floor under every blind hole, and a first layer that is one plain rectangle" },
|
|
14
|
+
"wall": { "value": "x1c.wall_min * 2", "unit": "mm", "rule": "Plastic round every hole, pocket and slot: four print lines, as a design gives a boss" },
|
|
15
|
+
"gap": { "value": "x1c.wall_min", "unit": "mm", "rule": "Between features, between a feature and its figure, and round the edge" },
|
|
16
|
+
"root": { "value": "x1c.chamfer", "unit": "mm", "rule": "The 45° flare where each boss meets the base, so no inside corner is square" },
|
|
17
|
+
"step": { "value": "x1c.hole_comp", "unit": "mm", "rule": "Each row steps by the printer's hole compensation either side of what the kit draws: the amount a printed hole comes out wrong by" },
|
|
18
|
+
"pilots": { "value": 5, "rule": "Five pilots for each thread: the kit's figure and two steps either side" },
|
|
19
|
+
"fits": { "value": 3, "rule": "Three of every other feature: the kit's figure and a step either side" },
|
|
20
|
+
"label": { "value": 2.5, "unit": "mm", "rule": "Figure height: six print lines tall, readable close up, and small enough that a figure is no wider than its feature" },
|
|
21
|
+
"stroke": { "value": "x1c.line", "unit": "mm", "rule": "One print line, for the figures" },
|
|
22
|
+
"emboss": { "value": "x1c.layer * 2", "unit": "mm", "rule": "Two layers proud" },
|
|
23
|
+
"corner": { "value": 3, "unit": "mm", "rule": "The base's corners, rounded so they stay down" },
|
|
24
|
+
"segments": { "value": 48, "rule": "Facets on round holes and bosses" }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// The holds coupon, the fixings coupon's second plate: what holds two parts together without a screw of steel. A plate
|
|
2
|
+
// with a row for each fit, at sizes either side of the one the kit draws: snap pin sockets (S3, S4), holes for a 3 mm
|
|
3
|
+
// steel dowel and for 1.75 mm filament, pressed (D3P, FP) and slipping (D3S, FS), pockets for 6x3 and 8x3 disc magnets
|
|
4
|
+
// pressed in (6x3, 8x3) and held by crush ribs (8x3R), and printed nuts for printed M8 and M10 bolts (M8N, M10N). Beside
|
|
5
|
+
// it, loose: the printed bolts for those nuts, one for each thread gap, a pull bolt to break, and snap pins at three barb
|
|
6
|
+
// depths for each socket row. Every size comes from v.fixings and the printer's rules, so the coupon prints round the
|
|
7
|
+
// figures the kit draws today, and again round yours once they are measured (MEASURE.md, rows 40 to 47).
|
|
8
|
+
// The plate's first layer is one rectangle with a few round holes (the sockets go through it, and each magnet pocket has
|
|
9
|
+
// a hole under it to push the magnet out); every loose piece stands on a plain round or hexagonal foot. Nothing needs a support.
|
|
10
|
+
import jscad from '@jscad/modeling'
|
|
11
|
+
const { cylinder, cylinderElliptic, roundedRectangle, circle, polygon } = jscad.primitives
|
|
12
|
+
const { extrudeLinear, extrudeRotate } = jscad.extrusions
|
|
13
|
+
const { translate } = jscad.transforms
|
|
14
|
+
const { hull } = jscad.hulls
|
|
15
|
+
const { offset } = jscad.expansions
|
|
16
|
+
const { measureBoundingBox } = jscad.measurements
|
|
17
|
+
|
|
18
|
+
export function main (v) {
|
|
19
|
+
const f = v.fixings, base = v.base, wall = v.wall, seg = v.segments
|
|
20
|
+
const fig = (x) => String(Number(x.toFixed(2))) // a figure as it is labelled and written back
|
|
21
|
+
const around = (centre, n, step) => Array.from({ length: n }, (_, i) => Number((centre + (i - (n - 1) / 2) * step).toFixed(v.places)))
|
|
22
|
+
const width = (text) => { const [lo, hi] = measureBoundingBox(v.shapes.text({ text, height: v.label, stroke: v.stroke })); return hi[0] - lo[0] }
|
|
23
|
+
const say = (text, x, y, z) => translate([x, y, z], extrudeLinear({ height: v.emboss }, v.shapes.text({ text, height: v.label, stroke: v.stroke })))
|
|
24
|
+
// the printer as plain values with one figure changed: each feature in a row is drawn as if the printer's rule were its figure
|
|
25
|
+
const printer = (k, x) => ({ ...v.x1c, [k]: x })
|
|
26
|
+
// A feature's stand, its outline rising from the bed to its top, flared at 45° where it meets the base
|
|
27
|
+
const stand = (outline, top) => v.ops.union(extrudeLinear({ height: top }, outline),
|
|
28
|
+
hull(extrudeLinear({ height: base }, offset({ delta: v.root, corners: 'round', segments: seg }, outline)), extrudeLinear({ height: base + v.root }, outline)))
|
|
29
|
+
const round = (across, top, cut) => ({ across, deep: across, top, make: (x, y) => ({ solid: stand(circle({ radius: across / 2, center: [x, y], segments: seg }), top), cut: cut(x, y) }) })
|
|
30
|
+
// A hole down through everything at (x, y): under a magnet's pocket, to push the magnet out with a pin
|
|
31
|
+
const through = (d, x, y, top) => translate([x, y, top / 2], cylinder({ radius: d / 2, height: top + 2, segments: seg }))
|
|
32
|
+
|
|
33
|
+
// ---------- the plate's rows ----------
|
|
34
|
+
// Snap pin sockets: a hole through a boss as thick as the pin's shaft is long, at three clearances round the kit's.
|
|
35
|
+
// The lowest stays a step above 0: a socket's gap has no hole compensation, so at 0 it prints smaller than its peg
|
|
36
|
+
const sockets = (d) => {
|
|
37
|
+
const name = `snap pin ${d}x${v.shaft}`, c0 = f.pinModel(name).hole.clearance / 2, cs = around(Math.max(c0, (v.step * (v.fits + 1)) / 2), v.fits, v.step)
|
|
38
|
+
return { name: `S${d}`, items: cs.map((c) => ({ label: fig(c), ...round(d + 2 * Math.max(...cs) + 2 * wall, v.shaft, (x, y) => f.pinHole(name, { printer: printer('snap_clearance', c), at: [x, y, v.shaft], depth: v.shaft, through: true })) })) }
|
|
39
|
+
}
|
|
40
|
+
// Plain pins: blind holes from the top, pressed (the figure is how much smaller than the pin, before hole_comp) or slipping
|
|
41
|
+
const pins = (pin, label, fit) => {
|
|
42
|
+
const key = fit === 'press' ? 'pin_press' : 'pin_slip', c0 = f.pinModel(pin, { fit }).hole.clearance, x0 = fit === 'press' ? -c0 : c0
|
|
43
|
+
const xs = around(x0, v.fits, fit === 'press' ? v.press_step : v.step), d = f.pinModel(pin, { fit: 'slip', printer: printer('pin_slip', Math.max(...xs)) }).hole.diameter, top = base + v.pin_depth
|
|
44
|
+
return { name: label, items: xs.map((x) => ({ label: fig(x), ...round(d + 2 * wall, top, (cx, cy) => f.pinHole(pin, { fit, printer: printer(key, x), at: [cx, cy, top], depth: v.pin_depth })) })) }
|
|
45
|
+
}
|
|
46
|
+
// Magnet pockets: as deep as the magnet, with the kit's lead-in at the mouth, the plate's base under it and a push-out
|
|
47
|
+
// hole through that. A press pocket is the magnet less the figure, past hole_comp; a ribbed pocket is the kit's glue
|
|
48
|
+
// pocket with three crush ribs whose tips stand the figure inside the magnet. The kit's seat is read once for the
|
|
49
|
+
// figures it draws from (a press either side of the kit's is a test piece, not a design: fixings would rightly fail it),
|
|
50
|
+
// and the pockets are cut with the design's own booleans
|
|
51
|
+
const bore = (d, depth, lead, x, y, top) => v.ops.union(
|
|
52
|
+
translate([x, y, top - depth / 2 + 1 / 2], cylinder({ radius: d / 2, height: depth + 1, segments: seg })),
|
|
53
|
+
translate([x, y, top - lead / 2], cylinderElliptic({ height: lead, startRadius: [d / 2, d / 2], endRadius: [d / 2 + lead, d / 2 + lead], segments: seg })))
|
|
54
|
+
const ribbed = (q, x, y, top) => v.ops.subtract(bore(q.diameter, q.depth, q.lead, x, y, top), ...Array.from({ length: q.ribs.count }, (_, i) => {
|
|
55
|
+
const t = (2 * Math.PI * i) / q.ribs.count + Math.PI / 2, out = q.diameter / 2 + q.ribs.radius - q.ribs.protrude, low = top - q.depth - 1, high = top - q.lead
|
|
56
|
+
return translate([x + out * Math.cos(t), y + out * Math.sin(t), (low + high) / 2], cylinder({ radius: q.ribs.radius, height: high - low, segments: seg / 2 }))
|
|
57
|
+
}))
|
|
58
|
+
const magnets = (size, label, fit) => {
|
|
59
|
+
const name = `disc magnet ${size}`, key = fit === 'press' ? 'magnet_press' : 'magnet_crush', s0 = f.magnetSeatModel(name, { fit }), q0 = s0.pocket
|
|
60
|
+
const x0 = fit === 'press' ? -q0.clearance : s0.rests.find((r) => r.name.endsWith(key)).value, xs = around(x0, v.fits, v.step)
|
|
61
|
+
const top = base + q0.depth, across = q0.nominal[0] + q0.comp + 2 * q0.lead + 2 * wall
|
|
62
|
+
return { name: label, items: xs.map((x) => ({ label: fig(x), ...round(across, top, (cx, cy) => v.ops.union(fit === 'press' ? bore(q0.nominal[0] + q0.comp - x, q0.depth, q0.lead, cx, cy, top)
|
|
63
|
+
: ribbed(f.magnetSeatModel(name, { fit, printer: printer(key, x) }).pocket, cx, cy, top), through(v.push, cx, cy, top))) })) }
|
|
64
|
+
}
|
|
65
|
+
// Printed nuts for printed bolts: a boss a hex nut's height tall (rounded up to whole layers), a thread through it and
|
|
66
|
+
// the plate drawn half the gap off its basic profile (the bolt takes the other half), as deep as printedBoltModel
|
|
67
|
+
// takes a nut's thread to be when it works out the bolt's strength
|
|
68
|
+
const nuts = (t) => {
|
|
69
|
+
const g0 = f.holeModel(t, { kind: 'thread', mate: 'printed' }).threaded.clearance, gaps = around(g0, v.fits, v.step), high = Math.ceil(f.nutModel(t).height / v.x1c.layer - v.tiny) * v.x1c.layer
|
|
70
|
+
const made = gaps.map((gap) => f.holeModel(t, { kind: 'thread', mate: 'printed', gap, depth: high, through: true })), across = Math.max(...made.map((h) => h.diameter)) + 2 * wall
|
|
71
|
+
return { name: `${t}N`, items: gaps.map((gap) => ({ label: fig(gap), ...round(across, high, (x, y) => f.hole(t, { kind: 'thread', mate: 'printed', gap, depth: high, through: true, at: [x, y, high] })) })), gaps, high }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
const n8 = nuts('M8'), n10 = nuts('M10')
|
|
76
|
+
const rows = [[sockets(v.small_pin), sockets(v.large_pin), pins('dowel 3x12', 'D3P', 'press')],
|
|
77
|
+
[pins('filament pin 1.75x12', 'FP', 'press'), pins('filament pin 1.75x12', 'FS', 'slip'), pins('dowel 3x12', 'D3S', 'slip')],
|
|
78
|
+
[magnets('6x3', '6x3', 'press'), magnets('8x3', '8x3', 'press'), magnets('8x3', '8x3R', 'ribs')], [n8, n10]]
|
|
79
|
+
const solids = [], cuts = [], labels = []
|
|
80
|
+
let y = v.gap, length = 0
|
|
81
|
+
for (const row of rows) {
|
|
82
|
+
const deep = Math.max(...row.flatMap((g) => g.items.map((it) => it.deep))), line = y + v.label / 2, mid = y + v.label + v.gap + deep / 2
|
|
83
|
+
let x = v.gap
|
|
84
|
+
for (const g of row) {
|
|
85
|
+
const nameWidth = width(g.name)
|
|
86
|
+
labels.push(say(g.name, x + nameWidth / 2, mid, base)); x += nameWidth + v.gap
|
|
87
|
+
for (const it of g.items) {
|
|
88
|
+
const pitch = Math.max(it.across, width(it.label) + v.gap), cx = x + pitch / 2, m = it.make(cx, mid)
|
|
89
|
+
solids.push(m.solid); cuts.push(m.cut); labels.push(say(it.label, cx, line, base)); x += pitch + v.gap
|
|
90
|
+
}
|
|
91
|
+
x += v.gap
|
|
92
|
+
}
|
|
93
|
+
length = Math.max(length, x); y += deep + v.label + v.gap * 2
|
|
94
|
+
}
|
|
95
|
+
const plate = extrudeLinear({ height: base }, roundedRectangle({ size: [length, y], center: [length / 2, y / 2], roundRadius: v.corner, segments: seg }))
|
|
96
|
+
const out = { plate: v.ops.union(v.ops.subtract(v.ops.union(plate, ...solids), ...cuts), ...labels) }
|
|
97
|
+
|
|
98
|
+
// ---------- the loose pieces, in a row behind the plate ----------
|
|
99
|
+
// Marks: one, two or three notches down the side of a bolt's head or a pin's foot, for the first, second and third figure
|
|
100
|
+
const turn = (v.notch_turn * Math.PI) / v.half_turn
|
|
101
|
+
const notches = (count, radius, height) => Array.from({ length: count }, (_, i) => cylinder({ radius: v.notch, height: 2 * height, center: [radius * Math.cos(i * turn), radius * Math.sin(i * turn), 0], segments: seg / 2 }))
|
|
102
|
+
let x = v.gap, deep = 0
|
|
103
|
+
const place = (name, solid, across) => { out[name] = translate([x + across / 2, y + v.gap + across / 2, 0], solid); x += across + v.gap * 2; deep = Math.max(deep, across) }
|
|
104
|
+
// Printed bolts standing on their heads, one for each of the nuts' gaps, long enough to go through the nut and on
|
|
105
|
+
for (const [t, n] of [['M8', n8], ['M10', n10]]) {
|
|
106
|
+
n.gaps.forEach((gap, i) => {
|
|
107
|
+
const length = Math.round(n.high * v.engaged), b = f.printedBolt(`${t}x${length} hex printed`, { gap }), across = b.screw.headDiameter
|
|
108
|
+
place(`bolt-${t.toLowerCase()}-${fig(gap)}`, v.ops.subtract(b, ...notches(i + 1, (across / 2) * Math.cos(turn / 2), b.screw.headHeight)), across + v.gap)
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
// The pull bolt: an M8 printed bolt for a bought steel nut, its shank turned down to a waist that breaks within the
|
|
112
|
+
// luggage scale's reach. The waist is reached by 45° cones from the shank, so nothing overhangs past the printer's limit
|
|
113
|
+
{
|
|
114
|
+
const b = f.printedBolt(`M8x${v.pull_length} hex printed`, { nut: 'steel' }), k = b.screw.headHeight, R = b.screw.major / 2, r = v.waist / 2, z1 = k + 1, z2 = z1 + (R - r) + v.waist_length + (R - r)
|
|
115
|
+
const keep = extrudeRotate({ segments: seg }, polygon({ points: [[0, z1], [R, z1], [r, z1 + R - r], [r, z2 - (R - r)], [R, z2], [0, z2]] }))
|
|
116
|
+
const ring = v.ops.subtract(translate([0, 0, (z1 + z2) / 2], cylinder({ radius: R + 2, height: z2 - z1, segments: seg })), keep)
|
|
117
|
+
place('pull-bolt', v.ops.subtract(b, ring), b.screw.headDiameter + v.gap)
|
|
118
|
+
}
|
|
119
|
+
// Snap pins standing on their feet, three barb depths for each socket row, the split ending a millimetre above the foot.
|
|
120
|
+
// They are drawn from their plain figures (snapPin, the same solid f.pin draws), not checked as a design's pins are:
|
|
121
|
+
// on a split this short most bend past the strain the kit holds a pin to (pin.strain), and finding which click and
|
|
122
|
+
// which break is what they are printed for
|
|
123
|
+
for (const d of [v.small_pin, v.large_pin]) {
|
|
124
|
+
around(v.barb, v.fits, v.barb_step).forEach((lip, i) => {
|
|
125
|
+
const r = d / 2, rise = r + lip, slot = v.shaft - 1 + lip + rise, p = f.snapPin({ diameter: d, length: v.shaft, lip, slot, head: r }), foot = d * 2
|
|
126
|
+
place(`snap-pin-${d}-${fig(lip)}`, v.ops.subtract(p, ...notches(i + 1, foot / 2, 2)), foot + 2)
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
return out
|
|
130
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
3
|
+
"name": "holds-coupon",
|
|
4
|
+
"title": "Holds coupon",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"uses": [
|
|
7
|
+
"x1c"
|
|
8
|
+
],
|
|
9
|
+
"engine": "manifold",
|
|
10
|
+
"orientation": "Flat on the bed as drawn: the plate on its base with every hole opening upward, the bolts standing on their heads, the snap pins on their feet",
|
|
11
|
+
"description": "The fixings coupon's second plate: snap pin sockets for 3 and 4 mm pins at three clearances, holes for a 3 mm steel dowel and 1.75 mm filament at three press and three slip fits, 6x3 and 8x3 disc magnet pockets at three press fits and an 8x3 with crush ribs at three, and printed nuts, a hex nut's height, for M8 and M10 printed bolts at three thread gaps. Loose beside it: the six printed bolts, a pull bolt to break, and six snap pins at three barb depths. Each figure is the one to write back with cad measured (MEASURE.md, rows 40 to 47). Print it with the fixings coupon, once per printer and plastic.",
|
|
12
|
+
"variables": {
|
|
13
|
+
"base": { "value": "x1c.layer * 6", "unit": "mm", "rule": "The plate every feature stands on: six layers, the floor under every blind hole and pocket, and a first layer that is one plain rectangle but for the socket and push-out holes" },
|
|
14
|
+
"wall": { "value": "x1c.wall_min * 2", "unit": "mm", "rule": "Plastic round every hole and pocket: four print lines, as a design gives a boss" },
|
|
15
|
+
"gap": { "value": "x1c.wall_min", "unit": "mm", "rule": "Between features, between a feature and its figure, between loose pieces, and round the edge" },
|
|
16
|
+
"root": { "value": "x1c.chamfer", "unit": "mm", "rule": "The 45° flare where each boss meets the plate, so no inside corner is square" },
|
|
17
|
+
"step": { "value": "x1c.hole_comp", "unit": "mm", "rule": "Sockets, slip fits, magnet pockets and printed nuts step by the printer's hole compensation either side of what the kit draws: the amount a printed hole comes out wrong by" },
|
|
18
|
+
"press_step": { "value": "x1c.hole_comp / 2", "unit": "mm", "rule": "A pin's press fit steps by half that: a pin grips or splits its boss over a few hundredths of a millimetre" },
|
|
19
|
+
"shaft": { "value": 6, "unit": "mm", "rule": "A snap pin's shaft, and the thickness of its socket's boss from the bed, so the barb clicks out just past the plate's underside" },
|
|
20
|
+
"barb": { "value": 0.4, "unit": "mm", "rule": "The middle snap pin's barb depth, the kit's default; the others are a barb_step either side" },
|
|
21
|
+
"barb_step": { "value": 0.1, "unit": "mm", "rule": "The snap pins' barbs step by a tenth of a millimetre: about a quarter of the barb, enough to feel between a pin that clicks and one that will not go" },
|
|
22
|
+
"pin_depth": { "value": 6, "unit": "mm", "rule": "How deep a dowel or a filament pin goes into its hole: twice a 3 mm dowel's diameter, so it is held straight, and the rest of a 12 mm pin stands out to pull on" },
|
|
23
|
+
"push": { "value": 2, "unit": "mm", "rule": "The hole under each magnet pocket, to push a pressed magnet out with a 1.75 mm filament or a small screwdriver" },
|
|
24
|
+
"engaged": { "value": 2, "rule": "A printed bolt's length as a multiple of its nut's height: it goes right through the nut, with as much again to hold it by" },
|
|
25
|
+
"tiny": { "value": 1e-6, "rule": "What a height may be over a whole number of layers and still count as that number" },
|
|
26
|
+
"pull_length": { "value": 45, "unit": "mm", "rule": "The pull bolt's length under its head: the waist, then 36 mm of full thread, room for blocks up to 20 mm thick (MEASURE.md row 47: an 18 mm plywood offcut), an M8 washer (1.6 mm), a bought M8 nut (6.8 mm at most) and a pitch to start the nut on" },
|
|
27
|
+
"waist": { "value": 3.5, "unit": "mm", "rule": "The pull bolt's waist, across: 9.62 mm², which breaks at about 38 kg if the plastic holds 39 MPa across its layers (less across them in practice), within a 50 kg luggage scale's reach. Thick enough that the bolt prints standing: a sideways push of 1 N at its tip, as the nozzle passes, stresses the waist about 9.9 MPa (16 at 3 mm) and sways the tip about 0.46 mm (1 mm at 3 mm by 6), by beam bending at pla.modulus 2680 MPa: an estimate" },
|
|
28
|
+
"waist_length": { "value": 3.5, "unit": "mm", "rule": "The waist's straight length, one diameter, so it breaks in the waist and not where the cones meet the shank, and short so the bolt sways little as it prints standing" },
|
|
29
|
+
"small_pin": { "value": 3, "unit": "mm", "rule": "The smaller snap pin: the thinnest the kit draws a sampler's pins, above fixings.pin_least (2 mm) by half again" },
|
|
30
|
+
"large_pin": { "value": 4, "unit": "mm", "rule": "The larger snap pin: the size the kit's examples hold a lid with (snap pin 4x6)" },
|
|
31
|
+
"places": { "value": 3, "rule": "Figures in a row are worked to a thousandth of a millimetre, so a step's sum does not leave 0.30000000000000004" },
|
|
32
|
+
"fits": { "value": 3, "rule": "Three of every feature: the kit's figure and a step either side" },
|
|
33
|
+
"notch_turn": { "value": 60, "unit": "°", "rule": "The notches are a sixth of a turn apart, so on a hex head they fall on its flats" },
|
|
34
|
+
"half_turn": { "value": 180, "unit": "°", "rule": "Half a turn, to turn degrees into radians" },
|
|
35
|
+
"notch": { "value": 0.5, "unit": "mm", "rule": "The notches down the side of a loose bolt's head or a snap pin's foot that say which figure it is: one, two or three, for the first, second and third figure in its row" },
|
|
36
|
+
"label": { "value": 2.5, "unit": "mm", "rule": "Figure height: six print lines tall, readable close up, and small enough that a figure is no wider than its feature" },
|
|
37
|
+
"stroke": { "value": "x1c.line", "unit": "mm", "rule": "One print line, for the figures" },
|
|
38
|
+
"emboss": { "value": "x1c.layer * 2", "unit": "mm", "rule": "Two layers proud" },
|
|
39
|
+
"corner": { "value": 3, "unit": "mm", "rule": "The plate's corners, rounded so they stay down" },
|
|
40
|
+
"segments": { "value": 48, "rule": "Facets on round holes, bosses and the pull bolt's waist" }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// The slot coupon: what a printed part needs to slide in a bought beam's slot, for the two slot families most hobby
|
|
2
|
+
// beams have (slot 6 on 20 mm beams, slot 8 on 30 and 40 mm beams). For each: five tongues, the part of a printed
|
|
3
|
+
// fitting that keys into the slot's opening; five printed carriers (@rulecad/frames' carrier, a block holding a hex nut
|
|
4
|
+
// that slides along the slot like a slide-in nut); and three short printed slots, standing on end, that a bought slot
|
|
5
|
+
// nut slides into. Every piece lies loose on the bed with its figure, the clearance a side, on top. Each is drawn from
|
|
6
|
+
// the slot's rule set (v.frames.slotModel): print it again once the slot is measured, and it is drawn from yours.
|
|
7
|
+
// Each piece is a part of its own. Everything stands on a plain first layer and nothing needs a support (MEASURE.md, rows 29 to 33).
|
|
8
|
+
import jscad from '@jscad/modeling'
|
|
9
|
+
const { cuboid, polygon } = jscad.primitives
|
|
10
|
+
const { extrudeLinear } = jscad.extrusions
|
|
11
|
+
const { translate, rotateZ } = jscad.transforms
|
|
12
|
+
const { offset } = jscad.expansions
|
|
13
|
+
const { measureBoundingBox } = jscad.measurements
|
|
14
|
+
|
|
15
|
+
// The families, each with the thread its carriers hold: the largest hex nut a carrier takes in that slot at every
|
|
16
|
+
// clearance tried (an M3 nut leaves too little plastic under it in slot 6 at 0.3 mm a side)
|
|
17
|
+
const FAMILIES = [['slot-6', 'M2.5'], ['slot-8', 'M5']]
|
|
18
|
+
|
|
19
|
+
export function main (v) {
|
|
20
|
+
const fig = (x) => String(Number(x.toFixed(2))) // a figure as it is labelled and written back
|
|
21
|
+
const around = (centre, n, step) => Array.from({ length: n }, (_, i) => centre + (i - (n - 1) / 2) * step)
|
|
22
|
+
const width = (text) => { const [lo, hi] = measureBoundingBox(v.shapes.text({ text, height: v.label, stroke: v.stroke })); return hi[0] - lo[0] }
|
|
23
|
+
const say = (text, x, y, z) => translate([x, y, z], extrudeLinear({ height: v.emboss }, v.shapes.text({ text, height: v.label, stroke: v.stroke })))
|
|
24
|
+
const box = (lo, hi) => translate(lo.map((a, i) => (a + hi[i]) / 2), cuboid({ size: lo.map((a, i) => hi[i] - a) }))
|
|
25
|
+
const wordy = Math.max(...around(v.fit, v.fits, v.step).map((c) => width(fig(c))))
|
|
26
|
+
|
|
27
|
+
// ---------- the pieces, each drawn with its length along x from 0 and centred on y = 0, on the bed ----------
|
|
28
|
+
// A tongue: a head that lies on the beam's face, and under it (printed on top) a tongue as deep as the slot's lips,
|
|
29
|
+
// narrower than the opening by the clearance each side. A V-groove at each side of its root, so no inside corner is
|
|
30
|
+
// square; the head runs on past the tongue to carry its figure
|
|
31
|
+
const tongue = (slot, c) => {
|
|
32
|
+
const w = slot.opening - 2 * c, head = slot.opening + 2 * v.wall, long = v.key + v.gap * 2 + wordy, top = v.base + slot.lip
|
|
33
|
+
const solid = v.ops.union(box([0, -head / 2, 0], [long, head / 2, v.base]), box([0, -w / 2, v.base - v.root], [v.key, w / 2, top]))
|
|
34
|
+
const cut = [1, -1].map((s) => groove(s, w / 2, v.base, v.root, v.key))
|
|
35
|
+
return { long, across: head, solid: v.ops.subtract(solid, ...cut), label: say(fig(c), v.key + v.gap + wordy / 2, 0, v.base) }
|
|
36
|
+
}
|
|
37
|
+
// A carrier for a hex nut, as frames draws it with the clearance as the printer's slot fit, long enough that its
|
|
38
|
+
// figure fits beside the screw's hole
|
|
39
|
+
const carrier = (slot, thread, c) => {
|
|
40
|
+
const printer = { ...v.x1c, slot_fit: c }, m0 = v.frames.carrierModel(slot, { thread, printer })
|
|
41
|
+
const length = Math.ceil(Math.max(m0.length, m0.screwHole + 2 * (wordy + v.gap * 2)))
|
|
42
|
+
const m = v.frames.carrierModel(slot, { thread, printer, length }), high = m.levels.bottom - m.levels.top
|
|
43
|
+
return { long: m.total, across: Math.max(...m.section.map(([y]) => Math.abs(y))) * 2, solid: v.frames.carrier(m, { pose: 'print', printer }), label: say(fig(c), (m.total + m.screwHole) / 2 + v.gap + wordy / 2, 0, high), model: m }
|
|
44
|
+
}
|
|
45
|
+
// A short printed slot standing on end: the slot's outline, opened by the clearance each side (its inside corners
|
|
46
|
+
// round by as much), cut down into a block from the top to a floor, the slot's face on the block's side (y = 0)
|
|
47
|
+
const printed = (slot, c) => {
|
|
48
|
+
const path = v.frames.slotPath(slot).map(([u, d]) => [u, -d]), void2 = polygon({ points: [[path[0][0], v.wall], ...path, [path[path.length - 1][0], v.wall]] })
|
|
49
|
+
const open = offset({ delta: c, corners: 'round', segments: v.segments }, void2), across = slot.cavityWidth + 2 * c + 2 * v.wall, deep = slot.cavityDepth + c + v.wall + v.label + v.gap * 2
|
|
50
|
+
const block = box([-across / 2, -deep, 0], [across / 2, 0, v.tall]), cut = translate([0, 0, v.base], extrudeLinear({ height: v.tall }, open))
|
|
51
|
+
return { long: across, across: deep, centre: -deep / 2, solid: v.ops.subtract(block, cut), label: say(fig(c), 0, -deep + v.gap + v.label / 2, v.tall) }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ---------- the rows, front to back: tongues, carriers, printed slots; slot 6 on the left, slot 8 on the right ----------
|
|
55
|
+
const groups = FAMILIES.map(([name, thread]) => {
|
|
56
|
+
const slot = v.frames.slotModel(name)
|
|
57
|
+
return {
|
|
58
|
+
name,
|
|
59
|
+
tongues: around(v.fit, v.fits, v.step).map((c) => ({ c, ...tongue(slot, c) })),
|
|
60
|
+
carriers: around(v.fit, v.fits, v.step).map((c) => ({ c, ...carrier(slot, thread, c) })),
|
|
61
|
+
slots: around(v.fit, v.slots, v.slot_step).map((c) => ({ c, ...printed(slot, c) }))
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
const out = {} // each piece a part of its own, named for its family, what it is and its clearance: slot-6-tongue-0.15
|
|
65
|
+
let y = v.gap
|
|
66
|
+
for (const row of ['tongues', 'carriers', 'slots']) {
|
|
67
|
+
let x = v.gap, deep = 0
|
|
68
|
+
for (const g of groups) {
|
|
69
|
+
for (const p of g[row]) {
|
|
70
|
+
// tongues and carriers turned to run along y, side by side in x; a printed slot stands as it is
|
|
71
|
+
const turned = row !== 'slots', span = turned ? p.across : p.long, reach = turned ? p.long : p.across
|
|
72
|
+
const place = (s) => turned ? translate([x + span / 2, y, 0], rotateZ(Math.PI / 2, s)) : translate([x + span / 2, y + reach, 0], s)
|
|
73
|
+
out[`${g.name}-${row.slice(0, -1)}-${fig(p.c)}`] = v.ops.union(place(p.solid), place(p.label))
|
|
74
|
+
x += span + v.gap * 2; deep = Math.max(deep, reach)
|
|
75
|
+
}
|
|
76
|
+
x += v.gap * 2
|
|
77
|
+
}
|
|
78
|
+
y += deep + v.gap * 2
|
|
79
|
+
}
|
|
80
|
+
return out
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The V-groove beside a tongue's root, along x: a triangle in y, z with its point down, cut into the head's top beside
|
|
84
|
+
// the tongue's side at y = s × edge
|
|
85
|
+
function groove (s, edge, base, root, key) {
|
|
86
|
+
const tri = s > 0 ? [[edge, base - root], [edge + root, base], [edge, base]] : [[-edge, base - root], [-edge, base], [-edge - root, base]]
|
|
87
|
+
// drawn in x, y as (y, z), extruded along z for the tongue's length, then turned so the extrusion runs along x
|
|
88
|
+
return jscad.transforms.transform([0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1], extrudeLinear({ height: key }, polygon({ points: tri })))
|
|
89
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
3
|
+
"name": "slot-coupon",
|
|
4
|
+
"title": "Slot coupon",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"uses": [
|
|
7
|
+
"x1c"
|
|
8
|
+
],
|
|
9
|
+
"engine": "manifold",
|
|
10
|
+
"orientation": "Loose pieces flat on the bed as drawn: tongues head down, carriers floor down, printed slots standing on end with their floor down",
|
|
11
|
+
"description": "For slot 6 (20 mm beams) and slot 8 (30 and 40 mm beams): five tongues and five printed nut carriers (M2.5 in slot 6, M5 in slot 8) at clearances either side of the printer's fit, and three short printed slots for a bought slot nut. Each piece carries its clearance a side, the figure to write back with cad measured (MEASURE.md, rows 29 to 33). Drawn from the slot's rule set: print it again once the slot is measured.",
|
|
12
|
+
"variables": {
|
|
13
|
+
"base": { "value": "x1c.layer * 6", "unit": "mm", "rule": "A tongue's head and a printed slot's floor: six layers, and a first layer that is one plain piece" },
|
|
14
|
+
"wall": { "value": "x1c.wall_min * 2", "unit": "mm", "rule": "Plastic round a printed slot, and a tongue's head beyond the opening each side: four print lines" },
|
|
15
|
+
"gap": { "value": "x1c.wall_min", "unit": "mm", "rule": "Between pieces, between a feature and its figure, and round the edge" },
|
|
16
|
+
"root": { "value": "x1c.chamfer", "unit": "mm", "rule": "The V-groove each side of a tongue's root, so the tongue meets its head with no square inside corner and the head still lies flat on the beam's face" },
|
|
17
|
+
"fit": { "value": "x1c.fit", "unit": "mm", "rule": "The middle clearance a side: what the kit draws a printed part in a slot with until the slot fit is measured" },
|
|
18
|
+
"step": { "value": "x1c.hole_comp / 2", "unit": "mm", "rule": "Tongues and carriers step by half the printer's hole compensation: a printed width comes out about that far either way, and a slot's opening is held to a tenth or two" },
|
|
19
|
+
"slot_step": { "value": "x1c.hole_comp", "unit": "mm", "rule": "Printed slots step by the printer's hole compensation, the amount a printed hole comes out wrong by" },
|
|
20
|
+
"fits": { "value": 5, "rule": "Five tongues and five carriers: the printer's fit and two steps either side" },
|
|
21
|
+
"slots": { "value": 3, "rule": "Three printed slots: the printer's fit and a step either side" },
|
|
22
|
+
"key": { "value": 12, "unit": "mm", "rule": "A tongue's length along the slot: longer than the opening is wide, so it slides straight and cannot twist" },
|
|
23
|
+
"tall": { "value": 15, "unit": "mm", "rule": "A printed slot's height: longer than a bought slide-in nut, so it slides its whole length" },
|
|
24
|
+
"label": { "value": 2.5, "unit": "mm", "rule": "Figure height: six print lines tall, readable close up, and narrow enough to sit across a carrier's top" },
|
|
25
|
+
"stroke": { "value": "x1c.line", "unit": "mm", "rule": "One print line, for the figures" },
|
|
26
|
+
"emboss": { "value": "x1c.layer * 2", "unit": "mm", "rule": "Two layers proud" },
|
|
27
|
+
"segments": { "value": 48, "rule": "Facets on the rounds of a printed slot's corners" }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "coupons",
|
|
3
|
+
"description": "Test prints that settle the kit's figures on your printer and plastic: the fixings, holds and slot coupons. MEASURE.md says how to read each and the cad measured command that writes the figure back.",
|
|
4
|
+
"material": "PLA",
|
|
5
|
+
"objects": [
|
|
6
|
+
"fixings-coupon",
|
|
7
|
+
"holds-coupon",
|
|
8
|
+
"slot-coupon"
|
|
9
|
+
]
|
|
10
|
+
}
|