@rulecad/fixings 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,82 @@
1
+ # Changelog: @rulecad/fixings
2
+
3
+ What changed in each release, for someone upgrading a workspace. A **printed size** is a dimension of a part you
4
+ print (a hole's diameter, a seat's depth, a part's outline). Each release says whether any printed size moved, and
5
+ why.
6
+
7
+ ## 0.1.5: pins, magnet seats and printed bolts (Fixings 4)
8
+
9
+ ### Added
10
+
11
+ - **Pins** (`pins.mjs`): `pinModel`, `pinHole` and `pin` for a snap pin, a steel dowel (ISO 8734 or ISO 2338), a
12
+ length of 1.75 mm filament or a printed pin, named by a grammar (`snap pin 4x6`, `dowel 3x12`, `filament pin
13
+ 1.75x12`, `printed pin 4x10`): the hole from the printer's rules (press or slip for a plain pin, a teardrop lying on
14
+ its side), mass, shear and bearing, a snap pin's push-in and pull-out forces, and a pin too long or too short for
15
+ its part refused by name. `parsePin`, `isPinName`, `PIN_KINDS`, `PIN_FITS`, `PIN_GRAMMAR`.
16
+ - **Snap pins moved here** from `@rulecad/flexures`: `snapPin`, `snapSocket` and `snapPinModel`, same signatures and
17
+ defaults, with the snap-hook sums written in this package. `snapSocket`'s default clearance reads
18
+ `x1c.snap_clearance` (0.2 mm, the figure it always drew).
19
+ - **Magnets** (`magnets.mjs`): `magnetModel` (a disc or block's pull off steel, at another grade and across a gap),
20
+ `magnetSeatModel` and `magnetSeat` (a press, glued or crush-ribbed pocket from the printer's rules, its floor held
21
+ to three layers, a pull-out finding), `magnet`, `parseMagnet`, `isMagnetName`, `fieldShare`, `MAGNET_GRADES`,
22
+ `MAGNET_FITS`, `MAGNET_SIZES`, `MAGNET_GRAMMAR`.
23
+ - **Printed bolts** (`bolts.mjs`): `printedBoltModel` (breaking load in tension at the root, by how it prints, in
24
+ thread stripping and in head shear; held to `load_margin`; refused below the printer's smallest thread, naming the
25
+ smallest that prints), `printedBolt`, `BOLT_NUTS`. The word printed in a name (`M8x20 hex printed`) makes a screw
26
+ printed, at any length.
27
+ - `DEFAULTS`: `snap_play`, `pin_least`, `magnet_floor`, all estimates. The printer's basics now borrow
28
+ `snap_clearance`, `pin_press`, `pin_slip`, `magnet_press`, `magnet_glue` and `magnet_crush` from the X1C where a
29
+ printer's set lacks them.
30
+ - `materialOf` and `weakest` are exported from `strength.mjs`; `materialOf` also returns `density` and `poisson`.
31
+ - README: sections on pins, printed bolts and magnets, where each thing lives, and measuring the printer's fits with
32
+ the fixings coupon and the new holds coupon.
33
+
34
+ ### Changed
35
+
36
+ - `screwLoad`, `preload`, `torqueFor`, `stripping`, and `seating` with no force given, refuse a printed bolt by name:
37
+ each reads a steel screw's proof load, which a printed bolt does not have.
38
+ - `screwModel` on a printed name (`M8x20 hex printed`) keeps the word printed in its name, says `printed: true`, and
39
+ weighs it in its plastic (`material`, PLA by default: 2.0 g, not 12.46 g of steel). `lengthFor` names a printed
40
+ length as printed too.
41
+ - `magnetSeatModel` with no `fit` gives crush ribs for a disc standing in its pocket, and glue for a disc lying on its
42
+ side or a block: a press warned on its wall for an 8 x 3 disc in PLA and split a 10 x 5 x 2 block's.
43
+ - `magnetModel` and `magnetSeatModel` handed a magnet's model with options build it again from its name with them
44
+ (its own grade, gap, count, load and given pull kept where the options say none). Before, the options were ignored.
45
+
46
+ ### Printed sizes that moved
47
+
48
+ A magnet pocket drawn with no `fit` given: 8.2 mm with ribs for an 8 x 3 disc, where the press was 8 mm (fixings'
49
+ own default only; frames' catch and the coupons name their fit). Otherwise none. Every snap pin and socket the kit drew before (the launcher's, the joints sampler's, the gears tensioner's) is
50
+ byte for byte the same, and frames' magnet catch pocket is 10.2 mm as it was.
51
+
52
+ ### What a workspace should change
53
+
54
+ Nothing is required. To use the new fits on your own printer, print the holds coupon and write each result back with
55
+ `cad measured` (examples/bench/projects/benchmarks/MEASURE.md, rows 40 to 47).
56
+
57
+ ## 0.1.4: the kit reads its screws from fixings (Fixings 3)
58
+
59
+ ### What reads fixings now
60
+
61
+ This package is now where every screw size in the kit comes from:
62
+ - `@rulecad/cad`: `v.fixings` in a design, and the `fasten` relation in an assembly, which follows a screw through the
63
+ parts, chooses its sold length and counts it in `cad list`.
64
+ - `@rulecad/motors`: a motor's mounting screws, their clearance holes and counterbores.
65
+ - `@rulecad/pcb`: a board's mounting holes, named by their thread (`mount('M2', x, y)`).
66
+ - `@rulecad/shapes` does not import this package (that would make a cycle, since this package draws with shapes'
67
+ seats). Its seats take the screw's figures from here as plain numbers.
68
+
69
+ ### Changed
70
+
71
+ - `screwGroup(places, o).turns` is `null` when the twist about a single screw rounds to 0 N m at the thousandth it is
72
+ given in. It used to be `0`, and cad then warned "a twist of 0 N m about the one screw is held by friction alone"
73
+ on a part held by one screw whose own weight sits a hair off the screw's axis. A test holds this.
74
+
75
+ ### Printed sizes that moved
76
+
77
+ None. No hole, seat or piece of hardware this package draws changed size or shape.
78
+
79
+ ### What a workspace should change
80
+
81
+ Nothing is required. Code that tested `screwGroup(...).turns > 0` keeps working; code that tested `turns !== null`
82
+ to mean "a twist" now skips a twist that rounds to nothing, which is the intent.
package/README.md CHANGED
@@ -5,8 +5,9 @@ a screw thread: the thread itself (`M3`), a whole screw (`M3x12 cap`), a nut, a
5
5
  threaded brass bush melted into plastic). You name the fixing, and this package looks its dimensions up from rules and
6
6
  gives you the model, the hole, the seat and the solid. It also draws a real thread to print where one is worth it,
7
7
  and does the first sums on a joint: how much thread is engaged, the load that strips it, the clamp force from a
8
- tightening torque, the pressure under a head, and the sold length that fits. Every figure says how far to trust it
9
- and where it comes from.
8
+ tightening torque, the pressure under a head, and the sold length that fits. It holds what fastens two parts with no
9
+ steel screw as well: pins (a printed snap pin, a steel dowel, a length of filament), magnets in printed pockets, and
10
+ bolts printed with their thread. Every figure says how far to trust it and where it comes from.
10
11
  The figures live in [`@rulecad/rules`](https://github.com/JoniBach/rulecad/tree/main/packages/rules) as open data,
11
12
  one rule set per thread, and this package holds no screw's numbers of its own. Needs JSCAD. Part of
12
13
  [rulecad](https://github.com/JoniBach/rulecad).
@@ -65,8 +66,28 @@ and stresses in MPa.
65
66
  | [Reference hardware](#reference-hardware) | `screw`, `nut`, `washer`, `insert` |
66
67
  | [Threads cut for printing](#threads-cut-for-printing) | `thread`, `threadModel` |
67
68
  | [Strength and length](#strength-and-length) | `engagement`, `stripping`, `preload`, `torqueFor`, `seating`, `lengthFor`, `screwGroup`, `screwLoad` |
69
+ | [Pins](#pins) | `pinModel`, `pinHole`, `pin`, `snapPin`, `snapSocket`, `snapPinModel`, `parsePin`, `isPinName` |
70
+ | [Printed bolts](#printed-bolts) | `printedBoltModel`, `printedBolt` |
71
+ | [Magnets](#magnets) | `magnetModel`, `magnetSeatModel`, `magnetSeat`, `magnet`, `parseMagnet`, `isMagnetName`, `fieldShare` |
72
+ | [Measuring the printer's fits](#measuring-the-printers-fits) | the fixings coupon and the holds coupon |
68
73
  | [Refusals and printability](#refusals-and-printability) | `printable` |
69
74
 
75
+ ## Where each thing lives
76
+
77
+ Anything whose job is to hold two parts together is here, where it is sized, its hole takes its fit from the
78
+ printer's rules, it goes on the shopping list and the build steps, and a coupon measures it. Some near neighbours
79
+ live elsewhere, each for a reason:
80
+
81
+ | Thing | Where | Why |
82
+ |---|---|---|
83
+ | Screws, nuts, washers, inserts, their holes and seats | here | they are the fixings |
84
+ | Snap pins (`snapPin`, `snapSocket`, `snapPinModel`), plain pins | here | moved from `@rulecad/flexures`, which passes the three snap pin functions on unchanged |
85
+ | Magnets and their pockets | here | `@rulecad/frames`' magnet catch takes its pocket and pull from `magnetSeatModel` |
86
+ | Printed bolts | here | a screw named with the word printed |
87
+ | Snap hooks, ratchets, pin joints printed in place, travel and angle stops | `@rulecad/flexures` | their bending is their job |
88
+ | A countersink, a nut pocket and a nut trap from plain figures, crush ribs, a teardrop hole | `@rulecad/shapes` | shapes draws from plain numbers and reads no rule sets; this package calls the same shapes with a thread's figures, so moving them would make a cycle |
89
+ | Slot nuts, carriers, brackets, hinges, latches, cable clips | `@rulecad/frames` | each is shaped to a beam's slot |
90
+
70
91
  ## Start here: a plate with four counterbored holes and an insert boss
71
92
 
72
93
  Install the package and JSCAD (`npm install @rulecad/fixings @jscad/modeling`), and this is a whole part: a plate
@@ -118,6 +139,7 @@ word = "cap" | "button" | "countersunk" | "hex" | "set" | "pan" a screw'
118
139
  | [ "hex" | "square" | "lock" ] "nut" a nut (hex if not said)
119
140
  | "washer" | "insert" a plain washer, a heat-set insert
120
141
  | a variant of the thread's rule set torx, on a PT screw
142
+ | "printed" a screw or nut printed with its thread, not bought
121
143
  ```
122
144
 
123
145
  | You write | You get |
@@ -485,6 +507,211 @@ as `petg` has), the weaker of the two is taken; where it has none (`pla`), the f
485
507
  a torque scatters by a quarter to a third either way. Take the results as a first check, keep a working load to half
486
508
  of what they give, and test a joint that matters.
487
509
 
510
+ ## Pins
511
+
512
+ A pin holds two printed parts together with no thread. Four kinds are drawn and sized here:
513
+
514
+ - a **snap pin**, a printed peg split down its middle with a barb at its tip, which clicks through its hole and holds;
515
+ - a **dowel**, a bought steel pin (ISO 8734, hardened and ground, or ISO 2338, unhardened);
516
+ - a **filament pin**, a cut length of the printer's 1.75 mm filament, with nothing to buy;
517
+ - a **printed pin**, a plain printed peg.
518
+
519
+ `pinModel(name, options)` gives a pin's numbers by name: the hole it goes in, its mass, what it carries in shear and
520
+ what the printed hole takes in bearing, and for a snap pin the force to push it in and pull it out. `pinHole` is the
521
+ hole to subtract (round standing up, a teardrop lying on its side) and `pin` the pin's own solid. A plain pin is
522
+ pressed in (`fit: 'press'`, the default: it grips) or slides in (`fit: 'slip'`: it turns, a hinge pin). Each hole
523
+ takes its size from the printer's rules: a snap pin's socket is the peg plus `snap_clearance` each side, as drawn; a
524
+ plain pin's hole is the pin plus `hole_comp`, less `pin_press` or plus `pin_slip`. All three are estimates until the
525
+ holds coupon measures them (see [Measuring the printer's fits](#measuring-the-printers-fits)). A snap pin's barb is
526
+ 0.4 mm past its peg unless its name says another; the holds coupon prints three, and `x1c.snap_barb` records the one
527
+ that won. Given the `thickness` it goes through, a pin that does not fit its part is refused by
528
+ name: a plain pin longer than the parts stands proud, and a snap pin's shaft must be as long as the parts and at most
529
+ `snap_play` (0.5 mm) longer, or its barb never clicks out or rattles.
530
+
531
+ A pin's name is read by this grammar:
532
+
533
+ ```
534
+ pin = kind diameter "x" length { word } snap pin 4x6, dowel 3x12, filament pin 1.75x12, printed pin 4x10
535
+ kind = "snap pin" | "dowel" | "filament pin" | "printed pin" ("pins" and "dowel pin" are read too)
536
+ diameter = number mm: the peg's, below a snap pin's barb
537
+ length = number [ "mm" ] mm: a snap pin's shaft from its foot to its barb; a plain pin's whole length
538
+ word = "barb" number a snap pin's barb past its peg (default 0.4)
539
+ | "ISO 8734" | "ISO 2338" a dowel's standard: hardened and ground (the default), or unhardened
540
+ ```
541
+
542
+ ```js
543
+ import { pinModel, pinHole, pin } from '@rulecad/fixings';
544
+
545
+ const snap = pinModel('snap pin 4x6', { thickness: 6, pull: 2 });
546
+ console.log(snap.hole.diameter, snap.snap.insertion, snap.snap.removal, snap.grams);
547
+ for (const fit of ['press', 'slip']) console.log(fit, pinModel('dowel 3x12', { fit }).hole.diameter);
548
+ const dowel = pinModel('dowel 3x12', { thickness: 12, load: 30 });
549
+ console.log(dowel.shear, dowel.bearing, dowel.margin, dowel.governs);
550
+ const cut = pinHole('dowel 3x12', { fit: 'slip', axis: 'x', depth: 8 }), solid = pin('snap pin 4x6');
551
+ console.log(cut.model.hole.teardrop, solid.model.name);
552
+ try { pinModel('dowel 3x20', { thickness: 12 }); } catch (e) { console.log(e.message.slice(0, 96)); }
553
+ ```
554
+
555
+ ```text
556
+ 4.4 6.22 6.22 0.191
557
+ press 3.05
558
+ slip 3.3
559
+ 1122.5 702 23.4 bearing
560
+ true snap pin 4x6
561
+ pinModel: dowel 3x20 is 20 mm long, and the parts it goes in hold 12 mm of it: it is too long fo
562
+ ```
563
+
564
+ `snapPin`, `snapSocket` and `snapPinModel` draw and size a snap pin from plain figures (diameter, shaft length, barb,
565
+ slot, gap, lead and back angles, head), as `@rulecad/flexures` drew them before they moved here. Flexures re-exports
566
+ them unchanged, so `v.flexures.snapPin` draws the same pin it always has. `parsePin` reads a name and `isPinName`
567
+ says whether a text is one. In an assembly, a fit's `fastener` can name pins (`{ "pin": "snap pin 4x6", "count": 2 }`):
568
+ `cad check` finds their holes, checks them against these figures and the pins' length against the parts, and `cad
569
+ list` and `cad order` name them.
570
+
571
+ ## Printed bolts
572
+
573
+ A printed bolt is a screw printed with its thread, standing on its head, where a bought one will not do or is not to
574
+ hand. Name it as a screw with the word printed, `'M8x20 hex printed'`: it is then printed at any length, not held to
575
+ the lengths screws are sold in. `printedBoltModel(name, options)` gives its strength in the plastic it is printed in,
576
+ and `printedBolt` its solid (the screw with its thread drawn, as `screw(m, { display: 'thread' })` draws it).
577
+
578
+ It breaks at the least of three loads:
579
+
580
+ - **in tension across its root**, its root diameter as drawn, at the plastic's strength across its layers when it
581
+ stands on its head (`strength_z`; a plastic with none, as PLA's set, uses its strength along them and says so) or
582
+ along them when it lies on a flat (`axis: 'x'` or `'y'`, its section less the flat);
583
+ - **its teeth sheared off in the nut**, over 0.75 π D1 Le (the bolt's teeth at the nut's minor diameter) and, in a
584
+ printed nut, the nut's own 0.875 π d Le, whichever is less, at the plastic's shear strength (its strength over √3);
585
+ - **its head sheared off its shank**, over π d k, k the head's height.
586
+
587
+ A printed bolt goes in a printed nut or a thread printed in the part (`nut: 'printed'`, the default), each taking half
588
+ the printer's `thread_gap`, or in a bought steel nut (`nut: 'steel'`), the bolt then taking the whole gap, so its
589
+ root is smaller. `depth` is the thread engaged (default the thread's hex nut height), and `load`, the pull along it, is
590
+ held to `load_margin`. Below the smallest pitch the printer resolves it is refused by name, as a thread is, naming the
591
+ smallest thread that prints: M6 at 0.2 mm layers.
592
+
593
+ ```js
594
+ import { printedBoltModel, printedBolt } from '@rulecad/fixings';
595
+
596
+ const pair = printedBoltModel('M8x20 hex printed', { load: 200 });
597
+ console.log(pair.root, pair.rootArea, pair.tension.load, pair.strip.load, pair.breaking, pair.governs, pair.margin);
598
+ const inSteel = printedBoltModel('M8x20 hex printed', { nut: 'steel' }), lying = printedBoltModel('M8x20 hex printed', { axis: 'x' });
599
+ console.log(inSteel.root, inSteel.breaking, lying.rootArea, lying.tension.rule);
600
+ const solid = printedBolt('M10x30 hex printed'); // its thread drawn: print it standing on its head
601
+ console.log(solid.model.name, solid.model.grams);
602
+ try { printedBoltModel('M5x20 hex printed'); } catch (e) { console.log(e.message.split('. ')[1]); }
603
+ ```
604
+
605
+ ```text
606
+ 6.446 32.63 1272.7 2397.9 1272.7 tension 6.36
607
+ 6.246 1195 29.67 pla.strength
608
+ M10x30 hex printed 4.206
609
+ The smallest metric thread that would print is M6 (1 mm pitch)
610
+ ```
611
+
612
+ The first line reads: an M8 printed bolt in PLA, in a printed nut, has a 6.446 mm root drawn (the basic 6.646 mm less
613
+ its half of the 0.2 mm gap each side), 32.63 mm² of section, which breaks at 39 MPa × 32.63 mm² = 1272.7 N before its
614
+ teeth shear (2397.9 N): 6.36 times a 200 N pull. Do a printed bolt up by hand: its thread takes no wrench's torque.
615
+ In an assembly, a fasten's `screw` can name one (`"M8x20 hex printed"`): `cad check` holds it to its load with these
616
+ sums, and `cad list` lists it as a printed part, not a bought screw. `screwLoad`, `preload`, `torqueFor`, `stripping` and
617
+ `seating` with no force given refuse a printed bolt by name and point here: each reads a steel screw's proof load,
618
+ which a printed bolt does not have. A printed nut is read by them as usual, since the screw in it is a bought one.
619
+
620
+ PLA's rule set has no strength across its layers, so a PLA bolt standing on its head is taken at its strength along
621
+ them, 39 MPa, which overstates it. The holds coupon's pull bolt measures it: written back with `cad measured`, it
622
+ becomes the plastic's `strength_z`, and every printed bolt standing in that plastic is worked out from it.
623
+
624
+ ## Magnets
625
+
626
+ A magnet holds two parts together with no screw: a lid, a door's catch, a tool on a board. `magnetModel(name,
627
+ options)` gives a disc or block neodymium magnet's pull straight off steel and its mass; `magnetSeatModel` its pocket
628
+ in a printed part; `magnetSeat` the pocket to subtract, and `magnet` the magnet's solid for an assembly.
629
+
630
+ **The pull.** The kit's `magnets` rule set holds six discs (6 x 2, 6 x 3, 8 x 3, 10 x 2, 10 x 3 and 12 x 3 mm) and
631
+ two blocks (10 x 5 x 2 and 20 x 10 x 2 mm), each with its seller's pull straight off thick mild steel and the grade
632
+ it was sold in. Another grade is scaled from it by the square of the middle of the two grades' remanence; with no
633
+ grade named, N35, the weakest sold, so a pull is not overstated. Across a gap (`gap`, or the floor under the pocket
634
+ when the steel is on that side) the pull is taken as the pull touching times the square of the field on the magnet's
635
+ axis there, over the field at its face: an estimate. `count` magnets share a `load`, held to `load_margin`. For a size
636
+ the set has no figure for, give its maker's pull (`{ pull: 12 }`, in N).
637
+
638
+ **The pocket.** Each fit takes its size from the printer's rules, all estimates until the holds coupon measures
639
+ them: a press (`fit: 'press'`) is the magnet plus `hole_comp` less `magnet_press`; a glued fit (`fit: 'glue'`) plus
640
+ `magnet_glue`; crush ribs (`fit: 'ribs'`) are a glued pocket with three ribs a line wide whose tips stand
641
+ `magnet_crush` inside the magnet, so a magnet anywhere in its ±0.1 mm goes in and grips. With no fit given, a disc
642
+ standing in its pocket gets crush ribs, and a disc lying on its side (where ribs would hang from the roof) or a block
643
+ is glued: each of those passes for every size the set holds, in PLA and PETG. A press grips hardest, but it stretches
644
+ the wall: an 8 x 3 disc in PLA at 24.6 MPa round the hoop, past half of PLA's 39 MPa, and a 10 x 5 x 2 block at 39.4
645
+ MPa, which splits it. A block's pocket
646
+ has its corners relieved by round cuts, so no inside corner is square. Given the part's `thickness`, the floor left
647
+ under the pocket is held to `magnet_floor` (three layers). The magnet's own pull draws it out of a pocket that faces its
648
+ steel: a press grips by its interference (p = E i / d / (1 + ν), with friction over its wall), crush ribs by the
649
+ plastic's strength over the ribs, and glue by the glue, which is not checked here. A press also stretches the pocket's
650
+ wall at that pressure, which a magnet at the top of its tolerance can split.
651
+
652
+ Refused by name: a size the set has no pull for, a floor too thin to print, a pocket opening on the bed wider than
653
+ the printer bridges, a block's pocket or crush ribs lying on their side.
654
+
655
+ A magnet's name is read by this grammar:
656
+
657
+ ```
658
+ magnet = shape size [ grade ] disc magnet 8x3, disc magnet 10x3 N52, block magnet 10x5x2
659
+ shape = "disc magnet" | "block magnet" | "magnet" (a magnet alone is a disc; "magnets" is read too)
660
+ size = diameter "x" thickness a disc, in mm, magnetised through its thickness
661
+ | length "x" width "x" thickness a block, in mm, magnetised through its thickness
662
+ grade = "N35" | "N38" | "N40" | "N42" | "N45" | "N48" | "N50" | "N52" (default magnets.grade, N35)
663
+ ```
664
+
665
+ ```js
666
+ import { magnetModel, magnetSeatModel, magnetSeat, magnet } from '@rulecad/fixings';
667
+
668
+ const lid = magnetModel('disc magnet 8x3', { count: 2, load: 10 });
669
+ console.log(lid.name, lid.touching, lid.total, lid.margin, lid.grams);
670
+ for (const fit of ['press', 'glue', 'ribs']) { const s = magnetSeatModel('disc magnet 8x3', { fit, thickness: 5 }); console.log(fit, s.pocket.diameter, s.floor, s.hold); }
671
+ const through = magnetSeatModel('disc magnet 8x3 N52', { thickness: 4, recess: 0.4, facing: 'floor' });
672
+ console.log(through.magnet.gap, through.magnet.pull);
673
+ const cut = magnetSeat('block magnet 10x5x2', { at: [0, 0, 4] }), solid = magnet('disc magnet 8x3');
674
+ console.log(cut.model.pocket.size, solid.model.thickness);
675
+ try { magnetSeatModel('disc magnet 8x3', { thickness: 3.4 }); } catch (e) { console.log(e.message.slice(0, 98)); }
676
+ ```
677
+
678
+ ```text
679
+ disc magnet 8x3 N35 11.51 23.01 2.3 1.131
680
+ press 8 2 557.2
681
+ glue 8.2 2 null
682
+ ribs 8.2 2 44.2
683
+ 0.6 12.77
684
+ [ 10.2, 5.2 ] 3
685
+ magnetSeatModel: a pocket 3 mm deep in a part 3.4 mm thick there leaves a floor of 0.4 mm under th
686
+ ```
687
+
688
+ The first line reads: a lid held by two 8 x 3 mm discs. The seller's N45 disc pulls 14.7 N; as N35 it pulls 14.7 ×
689
+ (1.19 / 1.345)² = 11.51 N, and two pull 23.01 N, 2.3 times a 10 N pull. A 5 mm thick lid leaves a 2 mm floor under
690
+ each 3 mm pocket. Put the magnets' poles the right way round before they go in: two magnets facing each other repel
691
+ if they are put in alike. `parseMagnet` reads a name, `isMagnetName` says whether a text is one, and `fieldShare(m, z)`
692
+ is the field on a magnet's axis at z from its face over the field at its face. In an assembly, a fit's `fastener` can
693
+ name magnets (`{ "magnet": "disc magnet 8x3", "count": 2 }`): `cad check` finds their pockets and reports their pull,
694
+ and `cad list` lists them as bought.
695
+
696
+ ## Measuring the printer's fits
697
+
698
+ Every clearance a hole, a seat or a pocket is drawn with is a rule of the printer's, and most are estimates until two
699
+ coupons measure them, printed together on one plate (`examples/bench/projects/benchmarks/MEASURE.md` says how to read
700
+ each):
701
+
702
+ - the **fixings coupon** (`objects/fixings-coupon`, rows 22 to 28): pilots, insert holes, nut pockets and slots, a
703
+ counterbore, and printed threads for bought bolts, writing `pilot_m3` and its kin, `insert_m3`, `nut_fit`,
704
+ `nut_slip`, `thread_gap` and `thread_flank`;
705
+ - the **holds coupon** (`objects/holds-coupon`, rows 40 to 47): snap pin sockets and three barbs (`snap_clearance`,
706
+ `snap_barb`), a 3 mm dowel's and 1.75 mm filament's press and slip holes (`pin_press`, `pin_slip`), 6 x 3 and 8 x 3
707
+ magnet pockets pressed and ribbed (`magnet_press`, `magnet_crush`), printed nuts and bolts for M8 and M10 (a second
708
+ reading of `thread_gap`), and a pull bolt whose waist breaks across its layers (the plastic's `strength_z`).
709
+
710
+ Each feature on a coupon is drawn by this package from the printer's rules, at the kit's figure and a step either side,
711
+ and labelled with its figure. Write the best one back with `cad measured benchmarks/fixings-test x1c.pin_press=0.1`: it
712
+ goes into the workspace's copy of the printer's set, marked measured with the date, and every design drawn after it
713
+ uses it. `cad measured` refuses a figure no fit of its kind can be (a press of 3 mm), naming what it accepts.
714
+
488
715
  ## Refusals and printability
489
716
 
490
717
  Bad input is refused by name before any geometry is made, with what would be accepted:
@@ -499,6 +726,7 @@ Bad input is refused by name before any geometry is made, with what would be acc
499
726
  | A material with no rule set (`'nylon'`) | The materials there are |
500
727
  | A printed thread too fine for the printer, or on its side with no flat | The smallest thread that would print; the flat |
501
728
  | A stack no sold screw fits | The nearest length and by how much it misses |
729
+ | A pin too long or too short for its part (`thickness`), a dowel size not sold, a pin thinner than `pin_least` | How long the pin is against the parts, the nearest sizes |
502
730
 
503
731
  `printable(x)` gives what a printer can make of anything this package draws, as findings: pass a model or the solid
504
732
  made from it. A hole, a seat or a printed thread gives its `.printable` finding for the direction it was drawn for
@@ -548,13 +776,15 @@ hole: depth is a number above 0, in mm (got -2)
548
776
  - **Standards** (`spec`): threads, clearance holes, heads, nuts, washers, lengths and proof stresses, each from its
549
777
  standard as tabulated on the pages its rule names. The thread profiles are ISO 68-1's and ISO 2904's formulas.
550
778
  - **Measured**: the X1C's M3 pilot (`x1c.pilot_m3`, 2.9 mm, from the kit's fit bar). It is the only measured figure
551
- so far. The fixings coupon (`examples/bench/projects/benchmarks/objects/fixings-coupon`) measures the rest, per
552
- printer and plastic, and `cad measured` writes each result to the printer's rule set.
553
- - **Community**: heat-set inserts (CNC Kitchen's sheet), pilots for M2 to M4 (Bambu Lab's figures for PLA) and for
779
+ so far. The fixings coupon and the holds coupon measure the rest, per printer and plastic, and `cad measured`
780
+ writes each result to the printer's rule set (see [Measuring the printer's fits](#measuring-the-printers-fits)).
781
+ - **Community**: magnets' pulls straight off steel (the seller's figures, supermagnete) and the grades' remanence, heat-set inserts (CNC Kitchen's sheet), pilots for M2 to M4 (Bambu Lab's figures for PLA) and for
554
782
  the PT screws (the maker's factor for ABS), the engagement rules, the printer's `hole_comp`, `fit` and `bridge`,
555
783
  the two layers a nut pocket is sunk, and the three quarters of proof load a fully tightened screw is taken to carry.
556
784
  - **Estimates**: pilots for M1.6, M5 and up, and every inch size (nobody has published one); the printer's `slip`,
557
- `press` and `thread_gap`; the layers and line a printed thread needs; the layer left over a nut put in mid-print;
785
+ `press`, `thread_gap`, `snap_clearance`, `pin_press`, `pin_slip`, `magnet_press`, `magnet_glue` and `magnet_crush`; a steel dowel's shear strength and the play a
786
+ snap pin's shaft may have; a magnet's pull at a grade other than its seller's and across a gap, the grip of a press
787
+ or of crush ribs on a magnet, the three layers under a magnet's pocket, and every strength of a printed bolt; the layers and line a printed thread needs; the layer left over a nut put in mid-print;
558
788
  a material's shear strength (its tensile strength over √3) and what it bears under a head (its strength); the nut
559
789
  factor K (0.2); the diameter of thread asked in an insert; the millimetre kept at a screw's tip; and every mass.
560
790
  A mass comes from the part's outline, with no socket and no knurls, and an insert's alloy is assumed.
@@ -597,6 +827,20 @@ with its `rule`, `kind` and `source`.
597
827
  | Pull on each screw of a group | P = Fz / n + b x + c y, with Σ P y = Mx and Σ P x = -My about the centroid; screws in a line tip about the clamped face's edge, P = M / (n × pivot) | An estimate of this package: the plane through the centroid holds while the parts stay pressed together. No source was read for it |
598
828
  | A screw under its load | the screw: (Fp + k P)² + 3 (k S)² = proof load²; the thread: Fp + k P = strip load; the clamp: μ (Fp - k P) = k S; the margin is the least k of the first two | Von Mises on the stress area; the screw takes the whole pull and the clamp loses the whole pull, each the safe side for a part far softer than the screw. μ is `fixings.clamp_friction`, an estimate |
599
829
  | A screw's length | grip = stack + washer - sunk; engaged = length - grip; fits where need ≤ engaged ≤ room | Geometry, with the rules for need and room in the table under `lengthFor` |
830
+ | A snap pin's half | k = E w t³ / 4L³, with L the slot, t = (d - gap) / 2, w = 0.8 d; strain at the root 3 t y / 2 L² for the barb y | The cantilever snap-fit (BASF and Bayer snap-fit design guides), as `@rulecad/flexures` models a snap hook |
831
+ | Push in and pull out | W = 2 k y (μ + tan α) / (1 - μ tan α), α the lead or back angle; holds where α is 90° or μ tan α ≥ 1 | The same guides |
832
+ | A pin's shear | F = τ π d² / 4 × planes, a snap pin's area less its slot (gap × d); τ = strength / √3, or `pins.dowel_shear` for steel | Von Mises; the dowel's figure is an estimate that understates a hardened pin |
833
+ | The hole's bearing | F = strength × d × grip, the grip half the parts' thickness unless given | Projected area, as a screw's seat is taken; an estimate |
834
+ | A pin's mass | m = ρ π d² / 4 L, a snap pin's from its drawn solid | Geometry, with the plastic's or steel's density |
835
+ | A printed bolt in tension | F = strength × (π/4) dr², dr the root as drawn (the basic d - 1.0825 P less the bolt's share of thread_gap each side); strength across the layers standing (strength_z), along them lying; lying, the section less the segment past its flat | ISO 68-1 basic profile; the plastic's rule set. An estimate |
836
+ | Its teeth sheared in the nut | the bolt's A = 0.75 π D1 Le, D1 = d - 1.0825 P (its tooth is 0.75 P wide where the nut's crest flat, P/4, ends); a printed nut's A = 0.875 π d Le; F = (strength / √3) × the lesser | The same derivation as the internal thread's shear area above, at basic sizes; an estimate |
837
+ | Its head sheared off | F = (strength / √3) × π d k, k the head's height | Geometry; an estimate |
838
+ | A magnet's pull at another grade | F = F_sold × (Br / Br_sold)², each Br the middle of its grade's range | The force on an iron face, F = B² A / 2μ0 (Wikipedia, Force between magnets), with B in proportion to Br; remanence from supermagnete's physical magnet data. An estimate |
839
+ | A magnet's pull across a gap | F(z) = F(0) × (B(z) / B(0))²; a disc's B(z) = Br/2 [(D + z) / √(R² + (D + z)²) - z / √(R² + z²)], a block's Br/π [atan(LW / (2z √(4z² + L² + W²))) - atan(LW / (2(D + z) √(4(D + z)² + L² + W²)))] | supermagnete, How do you calculate the magnetic flux density? (the formulas); the square as above. An estimate |
840
+ | A magnet's pocket | press: d + hole_comp - magnet_press; glue: d + hole_comp + magnet_glue; ribs: the glue pocket, three ribs' tips at d + hole_comp - magnet_crush | The printer's rules, estimates until the coupon measures them |
841
+ | A press's grip on a magnet | p = E i / d / (1 + ν), i = magnet_press; hold = μ p π d h; the pocket's wall stretched round its hoop at p | A rigid disc pressed into a hole in a wide plate (Lamé's thick cylinder with an infinite outer radius); μ is clamp_friction. An estimate, which creep lowers |
842
+ | Crush ribs' grip | hold = μ × strength × n w h, n ribs a line w wide, crushed to the plastic's strength | An estimate of this package |
843
+ | A magnet's mass | m = 7.5 g/cm³ × its volume | magnets.density, worked from sellers' weights |
600
844
 
601
845
  VDI 2230 and Machinery's Handbook are named because the plan asked for them. Neither was read at first hand for
602
846
  this package: the handbook's thread shear area and stress area are applied as the pages above give them, and VDI
@@ -640,6 +884,7 @@ Each figure's own source is in its rule (`m.figures.<name>.source`, and `DEFAULT
640
884
  - [Bolted joint](https://en.wikipedia.org/wiki/Bolted_joint), Wikipedia: torque and preload, the nut factor, and how tightening methods scatter.
641
885
  - [Bolt group capacity](https://steelcalculator.pages.dev/reference/bolt-group-capacity/), the elastic method: direct and torsional shear in a group.
642
886
  - [Von Mises yield criterion](https://en.wikipedia.org/wiki/Von_Mises_yield_criterion), Wikipedia: shear yield from tensile yield.
887
+ - [How do you calculate the magnetic flux density?](https://www.supermagnete.de/eng/faq/How-do-you-calculate-the-magnetic-flux-density), supermagnete: the field on a disc's and a block's axis; [Physical magnet data](https://www.supermagnete.de/eng/physical-magnet-data), supermagnete: each grade's remanence; and [Force between magnets](https://en.wikipedia.org/wiki/Force_between_magnets), Wikipedia: the force on an iron face, F = B² A / 2μ0. Read on 2026-11-21; each magnet's pull is its seller's page, named in its rule.
643
888
 
644
889
  All were read on 2026-11-15. The plan for this package is [issue 212](https://github.com/JoniBach/rulecad/issues/212),
645
890
  and its specification is `docs/fixings-and-frames.md` in the repository. In `@rulecad/cad` the package is to become
package/bolts.d.mts ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @typedef {{ kind: 'printed-bolt', name: string, thread: string, head: string, length: number, nut: 'printed' | 'steel', axis: 'x' | 'y' | 'z', material: string,
3
+ * root: number, rootArea: number, engaged: number, tension: { strength: number, load: number, rule: string }, strip: { area: number, shear: number, load: number, nutArea: number | null },
4
+ * headShear: number | null, breaking: number, governs: 'tension' | 'strip' | 'head', load: number | null, margin: number | null, grams: number, threaded: object, rests: object[], findings: object[] }} PrintedBolt
5
+ * root: the bolt's root diameter as drawn, mm; rootArea: its section there (less its flat, lying), mm²; engaged: thread in the nut, mm;
6
+ * tension: the plastic's strength the root is pulled at (across its layers standing, along them lying) and the load it breaks at, N;
7
+ * strip: the shear area of the bolt's teeth in the nut (and of a printed nut's own), the shear strength and the load they shear at;
8
+ * headShear: the load that shears the head off the shank; breaking: the least of the three, N, governs: which
9
+ */
10
+ /**
11
+ * A printed bolt's strength: the load along it that breaks it, from the plastic's strength by how it prints, and that
12
+ * load against the one it carries. Standing on its head (axis z, the way it prints with no support), the pull goes
13
+ * across its layers; lying on a flat (axis x or y), along them.
14
+ * @param {string | object} m a screw's name or model ('M8x20 hex printed', or 'M8x20 hex'), or a thread with { length, head }
15
+ * @param {{ material?: string | object, printer?: object, nut?: 'printed' | 'steel', depth?: number, axis?: 'x' | 'y' | 'z', load?: number, length?: number, head?: string,
16
+ * gap?: number, sets?: object }} [o]
17
+ * material: the plastic (default PLA); nut: printed (a printed nut or a thread printed in the part, the default) or
18
+ * steel (a standard thread: a bought nut, a heat-set insert or a tapped hole); depth: thread engaged in the nut, mm (default the thread's hex nut height); axis: how it
19
+ * prints, z standing on its head (the default), or x or y lying on a flat; load: the pull along it, N, held to
20
+ * fixings.load_margin; gap: in place of the printer's thread_gap
21
+ * @returns {PrintedBolt}
22
+ */
23
+ export function printedBoltModel(m: string | object, o?: {
24
+ material?: string | object;
25
+ printer?: object;
26
+ nut?: "printed" | "steel";
27
+ depth?: number;
28
+ axis?: "x" | "y" | "z";
29
+ load?: number;
30
+ length?: number;
31
+ head?: string;
32
+ gap?: number;
33
+ sets?: object;
34
+ }): PrintedBolt;
35
+ /**
36
+ * A printed bolt's solid: the screw with its thread drawn (screw's display: 'thread'), turned over to stand on its head
37
+ * as it prints: the head's top on the bed at z = 0, its tip up.
38
+ * @param {string | object} m as printedBoltModel @param {object} [o] as printedBoltModel @param {{ union: Function, subtract: Function }} [ops]
39
+ * @returns {object} a JSCAD geom3 with .model holding printedBoltModel's numbers
40
+ */
41
+ export function printedBolt(m: string | object, o?: object, ops?: {
42
+ union: Function;
43
+ subtract: Function;
44
+ }): object;
45
+ /** What a printed bolt can go in: a printed nut or a thread printed in the part (half the gap each), or a standard thread, 'steel': a bought nut, a heat-set insert or a tapped hole (the bolt takes the whole gap). */
46
+ export const BOLT_NUTS: string[];
47
+ /**
48
+ * root: the bolt's root diameter as drawn, mm; rootArea: its section there (less its flat, lying), mm²; engaged: thread in the nut, mm;
49
+ * tension: the plastic's strength the root is pulled at (across its layers standing, along them lying) and the load it breaks at, N;
50
+ * strip: the shear area of the bolt's teeth in the nut (and of a printed nut's own), the shear strength and the load they shear at;
51
+ * headShear: the load that shears the head off the shank; breaking: the least of the three, N, governs: which
52
+ */
53
+ export type PrintedBolt = {
54
+ kind: "printed-bolt";
55
+ name: string;
56
+ thread: string;
57
+ head: string;
58
+ length: number;
59
+ nut: "printed" | "steel";
60
+ axis: "x" | "y" | "z";
61
+ material: string;
62
+ root: number;
63
+ rootArea: number;
64
+ engaged: number;
65
+ tension: {
66
+ strength: number;
67
+ load: number;
68
+ rule: string;
69
+ };
70
+ strip: {
71
+ area: number;
72
+ shear: number;
73
+ load: number;
74
+ nutArea: number | null;
75
+ };
76
+ headShear: number | null;
77
+ breaking: number;
78
+ governs: "tension" | "strip" | "head";
79
+ load: number | null;
80
+ margin: number | null;
81
+ grams: number;
82
+ threaded: object;
83
+ rests: object[];
84
+ findings: object[];
85
+ };
package/bolts.mjs ADDED
@@ -0,0 +1,106 @@
1
+ // Printed bolts: a screw printed with its thread, standing on its head, as a fixing with a strength of its own. Its
2
+ // thread is threadModel's (refused below the smallest pitch the printer resolves, naming the smallest that prints), and
3
+ // its strength is the plastic's: the bolt breaks in tension across its root, or its teeth shear off in the nut, or its
4
+ // head shears off its shank, whichever comes first. A printed bolt goes in a printed nut (or a thread printed in the
5
+ // part), each taking half the printer's thread_gap, or in a bought steel nut, the bolt then taking the whole gap. It is
6
+ // named as a screw with the word printed: 'M8x20 hex printed'. Units: mm, N, MPa, grams.
7
+ import jscad from '@jscad/modeling';
8
+ import { DEFAULTS, fixingOf, nutOf, cite, rest, finding, positive, oneOf, mm, r3, a } from './model.mjs';
9
+ import { optionsOf } from './holes.mjs';
10
+ import { materialOf, weakest } from './strength.mjs';
11
+ import { threadModel } from './threads.mjs';
12
+ import { screwModel, screw } from './hardware.mjs';
13
+
14
+ const { translate, rotateX } = jscad.transforms;
15
+
16
+ const an = (w) => `${/^[aeiou]/i.test(w) ? 'an' : 'a'} ${w}`; // (a plain word's article: model's a() is for thread names)
17
+ const n1 = (x) => +x.toFixed(1), n2 = (x) => +x.toFixed(2);
18
+ /** What a printed bolt can go in: a printed nut or a thread printed in the part (half the gap each), or a standard thread, 'steel': a bought nut, a heat-set insert or a tapped hole (the bolt takes the whole gap). */
19
+ export const BOLT_NUTS = ['printed', 'steel'];
20
+
21
+ // The area of a circle of radius r less the segment past a chord f from its centre (a bolt lying on its side, on its flat)
22
+ const segmentless = (r, f) => (f == null || f >= r ? Math.PI * r * r : Math.PI * r * r - (r * r * Math.acos(f / r) - f * Math.sqrt(r * r - f * f)));
23
+
24
+ /**
25
+ * @typedef {{ kind: 'printed-bolt', name: string, thread: string, head: string, length: number, nut: 'printed' | 'steel', axis: 'x' | 'y' | 'z', material: string,
26
+ * root: number, rootArea: number, engaged: number, tension: { strength: number, load: number, rule: string }, strip: { area: number, shear: number, load: number, nutArea: number | null },
27
+ * headShear: number | null, breaking: number, governs: 'tension' | 'strip' | 'head', load: number | null, margin: number | null, grams: number, threaded: object, rests: object[], findings: object[] }} PrintedBolt
28
+ * root: the bolt's root diameter as drawn, mm; rootArea: its section there (less its flat, lying), mm²; engaged: thread in the nut, mm;
29
+ * tension: the plastic's strength the root is pulled at (across its layers standing, along them lying) and the load it breaks at, N;
30
+ * strip: the shear area of the bolt's teeth in the nut (and of a printed nut's own), the shear strength and the load they shear at;
31
+ * headShear: the load that shears the head off the shank; breaking: the least of the three, N, governs: which
32
+ */
33
+
34
+ /**
35
+ * A printed bolt's strength: the load along it that breaks it, from the plastic's strength by how it prints, and that
36
+ * load against the one it carries. Standing on its head (axis z, the way it prints with no support), the pull goes
37
+ * across its layers; lying on a flat (axis x or y), along them.
38
+ * @param {string | object} m a screw's name or model ('M8x20 hex printed', or 'M8x20 hex'), or a thread with { length, head }
39
+ * @param {{ material?: string | object, printer?: object, nut?: 'printed' | 'steel', depth?: number, axis?: 'x' | 'y' | 'z', load?: number, length?: number, head?: string,
40
+ * gap?: number, sets?: object }} [o]
41
+ * material: the plastic (default PLA); nut: printed (a printed nut or a thread printed in the part, the default) or
42
+ * steel (a standard thread: a bought nut, a heat-set insert or a tapped hole); depth: thread engaged in the nut, mm (default the thread's hex nut height); axis: how it
43
+ * prints, z standing on its head (the default), or x or y lying on a flat; load: the pull along it, N, held to
44
+ * fixings.load_margin; gap: in place of the printer's thread_gap
45
+ * @returns {PrintedBolt}
46
+ */
47
+ export function printedBoltModel(m, o = {}) {
48
+ const what = 'printedBoltModel';
49
+ optionsOf(what, o, '{ material: \'pla\', load: 100 }');
50
+ const fx = fixingOf(what, m, { ...o, anyLength: true });
51
+ if (!['screw', 'thread'].includes(fx.item)) throw new Error(`${what}: ${fx.name} is ${an(fx.item)}, not a bolt: name a screw ('${fx.thread}x20 hex printed')`);
52
+ const nut = oneOf(what, 'nut', o.nut ?? 'printed', BOLT_NUTS), axis = oneOf(what, 'axis', o.axis ?? 'z', ['x', 'y', 'z']), mat = materialOf(what, o.material ?? 'pla', o.sets);
53
+ if (mat.cls !== 'plastic') throw new Error(`${what}: ${mat.name} is ${an(mat.cls)}, not a plastic: a printed bolt is printed in a plastic (pla, petg, or a plastic's rule set)`);
54
+ const form = o.head ?? fx.head?.form ?? (fx.made.heads.includes('hex') ? 'hex' : fx.made.heads[0]), sc = screwModel(fx, { length: o.length ?? fx.length ?? undefined, head: form, anyLength: true, ...(fx.printed ? { material: o.material ?? 'pla', sets: o.sets } : {}) }); // (a printed name is weighed in its plastic by screwModel)
55
+ const out = [], rests = [];
56
+ // Its thread, as it prints: refused where the printer cannot resolve the pitch, naming the smallest thread that prints
57
+ const shank = r3(sc.length - sc.sink), t = threadModel(fx, { what, length: shank, printer: o.printer, sets: o.sets, mate: nut === 'printed' ? 'printed' : 'bought', gap: o.gap, top: '-z', axis, flat: axis !== 'z' ? true : undefined });
58
+ rests.push(...t.rests); out.push(...t.findings.filter((f) => f.code !== 'thread.overlap'));
59
+ const depth = o.depth != null ? positive(what, 'depth (thread engaged in the nut)', o.depth) : nutOf(what, fx, 'hex').height;
60
+ if (o.depth == null) rests.push(rest(cite(fx, 'nut_height'), fx.figures.nut_height));
61
+ // Tension across the root as drawn: standing, the pull goes across the layers; lying, along them
62
+ const root = t.drawn.minor, rootArea = segmentless(root / 2, t.flat), w = weakest(mat), sTension = axis === 'z' ? w.f : mat.strength, tensionLoad = sTension.value * rootArea;
63
+ rests.push(rest(sTension.name, sTension));
64
+ // The teeth in the nut, on the basic profile: the bolt's at the nut's minor diameter D1 = d - 1.0825 P, a tooth 0.75 P
65
+ // wide there (the nut's crest flat is P/4); a printed nut's own at the bolt's major d, 0.875 P wide (the bolt's crest is P/8)
66
+ const P = fx.pitch, d = fx.major, D1 = d - (5 / 8) * Math.sqrt(3) * P, ratio = DEFAULTS.shear_ratio.value, tau = w.f.value * ratio;
67
+ const boltArea = 0.75 * Math.PI * D1 * depth, nutArea = nut === 'printed' ? 0.875 * Math.PI * d * depth : null, stripArea = Math.min(boltArea, nutArea ?? Infinity), stripLoad = tau * stripArea;
68
+ rests.push(rest(w.f.name, w.f), rest('fixings.shear_ratio', DEFAULTS.shear_ratio));
69
+ // The head off its shank: a cylinder the bolt's diameter, the head's height tall, across the layers
70
+ const headShear = form === 'set' ? null : tau * Math.PI * d * Math.max(sc.headHeight, 1e-9);
71
+ const caps = { tension: tensionLoad, strip: stripLoad, ...(headShear != null ? { head: headShear } : {}) };
72
+ const governs = /** @type {'tension' | 'strip' | 'head'} */ (Object.entries(caps).sort((x, y) => x[1] - y[1])[0][0]), breaking = caps[governs];
73
+ const across = axis === 'z' ? `across its layers (it prints standing on its head)${w.note}` : 'along its layers (it prints lying on a flat)';
74
+ out.push(finding('info', `${a(fx.thread)} printed bolt in ${mat.name} breaks at about ${mm(n1(breaking))} N, ${governs === 'tension' ? 'pulled apart across its root' : governs === 'strip' ? 'its teeth sheared off in the nut' : 'its head sheared off'}: its ${mm(root)} mm root, ${mm(n2(rootArea))} mm², pulled ${across} at ${sTension.name} ${mm(sTension.value)} MPa, ${mm(n1(tensionLoad))} N; ${mm(depth)} mm of thread in a ${nut} nut shears its ${nut === 'printed' ? 'weaker teeth' : 'teeth'} over ${mm(n2(stripArea))} mm² (0.75 π D1 Le${nut === 'printed' ? ', the nut\'s own 0.875 π d Le' : ''}) at ${mm(n2(tau))} MPa, ${mm(n1(stripLoad))} N${headShear != null ? `; its ${mm(sc.headHeight)} mm head shears off at ${mm(n1(headShear))} N` : ''}. Every strength is an estimate: test one that matters`,
75
+ 'bolt.strength', { values: { breaking: n1(breaking), tension: n1(tensionLoad), strip: n1(stripLoad), head: headShear != null ? n1(headShear) : null, governs }, refs: { thread: fx.thread, material: mat.name, nut, axis, kind: 'estimate' } }));
76
+ const load = o.load != null ? positive(what, 'load (the pull along the bolt, in N)', o.load) : null, want = DEFAULTS.load_margin.value;
77
+ let margin = null;
78
+ if (load != null) {
79
+ margin = n2(breaking / load); rests.push(rest('fixings.load_margin', DEFAULTS.load_margin));
80
+ out.push(finding(margin >= want ? 'pass' : margin >= 1 ? 'warn' : 'fail', `a pull of ${mm(load)} N on the printed bolt is held ${mm(margin)} times over${margin >= want ? '' : margin >= 1 ? `, under the ${mm(want)} times fixings.load_margin asks` : ': it breaks'} (${governs} first). Do it up by hand: a printed thread takes no wrench's torque`, 'bolt.load', { values: { load, margin, breaking: n1(breaking) } }));
81
+ }
82
+ if (nut === 'steel') out.push(finding('info', `in a standard thread (a bought steel nut, a heat-set insert or a tapped hole), the printed bolt takes the whole of the thread's gap and the nut's teeth hold: the bolt's teeth shear first`, 'bolt.nut', { values: { nut } }));
83
+ // Its mass: the outline screwModel weighs, at the plastic's density
84
+ if (!mat.density) throw new Error(`${what}: ${mat.name} has no density in its rule set, so the bolt cannot be weighed`);
85
+ const grams = fx.printed ? sc.mass : r3((sc.mass / DEFAULTS.steel_density.value) * mat.density.value);
86
+ rests.push(rest(mat.density.name, mat.density));
87
+ const name = fx.printed ? sc.name : `${sc.name} printed`;
88
+ out.push(finding('info', `${name} weighs ${mm(grams)} g of ${mat.name}, an estimate from its outline`, 'bolt.mass', { values: { grams } }));
89
+ return { kind: 'printed-bolt', name, thread: fx.thread, head: form, length: sc.length, nut, axis, material: mat.name, root, rootArea: n2(rootArea), engaged: depth,
90
+ tension: { strength: sTension.value, load: n1(tensionLoad), rule: sTension.name }, strip: { area: n2(stripArea), shear: n2(tau), load: n1(stripLoad), nutArea: nutArea != null ? n2(nutArea) : null },
91
+ headShear: headShear != null ? n1(headShear) : null, breaking: n1(breaking), governs, load, margin, grams, threaded: t, rests, findings: out };
92
+ }
93
+
94
+ /**
95
+ * A printed bolt's solid: the screw with its thread drawn (screw's display: 'thread'), turned over to stand on its head
96
+ * as it prints: the head's top on the bed at z = 0, its tip up.
97
+ * @param {string | object} m as printedBoltModel @param {object} [o] as printedBoltModel @param {{ union: Function, subtract: Function }} [ops]
98
+ * @returns {object} a JSCAD geom3 with .model holding printedBoltModel's numbers
99
+ */
100
+ export function printedBolt(m, o = {}, ops) {
101
+ const b = printedBoltModel(m, o), fx = fixingOf('printedBolt', m, { ...o, anyLength: true });
102
+ if (b.axis !== 'z') throw new Error('printedBolt: the solid is drawn standing on its head (axis z); a bolt lying on its flat is thread(..., { axis, flat: true }) with a head of your own');
103
+ const g = screw(fx, { length: b.length, head: b.head, anyLength: true, display: 'thread', printer: o.printer, sets: o.sets, mate: b.nut === 'printed' ? 'printed' : 'bought', gap: o.gap }, ...(ops ? [ops] : []));
104
+ // (turned over onto its head, the head's top on the bed at z = 0 and its tip up)
105
+ return Object.assign(translate([0, 0, g.model.top], rotateX(Math.PI, g)), { model: b, screw: g.model });
106
+ }
package/fixings.d.mts CHANGED
@@ -33,3 +33,6 @@ export { counterboreModel, counterbore, countersinkModel, countersink, nutPocket
33
33
  export { screwModel, screw, nutModel, nut, washerModel, washer, insertModel, insert } from "./hardware.mjs";
34
34
  export { threadModel, thread, THREAD_FORMS } from "./threads.mjs";
35
35
  export { engagement, stripping, preload, torqueFor, seating, lengthFor, screwGroup, screwLoad, MATERIALS, MATERIAL_CLASSES, ENDS } from "./strength.mjs";
36
+ export { pinModel, pinHole, pin, snapPin, snapSocket, snapPinModel, parsePin, isPinName, PIN_KINDS, PIN_FITS, PIN_GRAMMAR } from "./pins.mjs";
37
+ export { printedBoltModel, printedBolt, BOLT_NUTS } from "./bolts.mjs";
38
+ export { magnetModel, magnetSeatModel, magnetSeat, magnet, parseMagnet, isMagnetName, fieldShare, MAGNET_GRADES, MAGNET_FITS, MAGNET_SIZES, MAGNET_GRAMMAR } from "./magnets.mjs";