@rulecad/cad 0.7.75 → 0.7.78

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 CHANGED
@@ -126,13 +126,14 @@ variable says which rule it comes from. Follow these steps; they're what makes a
126
126
  measurement (and its date): report it as it says. A `join.drop` is a prediction for a beam held by one join, to
127
127
  measure and write back with `cad measured`, never a figure to tune. `frame.deflection` gives each sag twice, on
128
128
  the joins' springs and with the joins rigid: report the first with what it rests on (`refs.restsOn`), never the
129
- rigid one alone. Say where the frame stands with `"frame": { "supports" }` or fitted feet, not by moving beams.
129
+ rigid one alone. Say where the frame stands with `"frame": { "supports" }` or fitted feet, not by moving beams. A `frame.solve` warning that its supports are guessed means neither is given.
130
130
  `frame.rack` gives the racking stiffness each way and the gain each change (gussets, a brace, a panel) solves to:
131
131
  report the stiffness, the gain and the change it advises, and say the push and the joins' springs are estimates.
132
132
  `frame.frequency` gives the lowest mode against what the machine excites: report it with its pose, and look at
133
133
  `<assembly>.frame-mode.svg` from `cad beams` to see what moves. To choose profiles, give `"frame": { "size": {
134
134
  "profiles": [...] } }` and read `frame.size` (or `npx cad frame <project>/<assembly> --size`): report each group's
135
- profile with the limit that set it and its margin, never pick a profile by hand where the sizing can; write it with
135
+ profile with the limit that set it (or the join a lighter profile could not make) and its margin, never pick a
136
+ profile by hand where the sizing can; give `"rack"` to hold racking too; write it with
136
137
  `--size --write` and check again, as its joins and lengths change. A task on a guide counts the beam's sag (the
137
138
  frame's own figure where the frame is solved), straightness and twist in `task.accuracy`: report the biggest term
138
139
  as it is named. `frame.heat` (given `"frame": { "heat": { "air": 45 } }`) says how much the frame grows and holds
package/CHANGELOG.md CHANGED
@@ -5,6 +5,49 @@ print (a hole's diameter, a seat's depth, a part's outline). Each release lists
5
5
  its reason. A **fasten** is an entry in an assembly's `"fasten"` list: one screwed joint, naming the screw by thread
6
6
  and head, the parts it passes through and the part it ends in.
7
7
 
8
+ ## 0.7.78: frames solved under their joints' loads, sized with joins that fit (#302, #303, #304)
9
+
10
+ ### Added
11
+
12
+ - The frame checks carry each `"loads"` entry on a joint (a force on a slide, a torque on a hinge) and a belt guide's
13
+ push at its carriage's acceleration into the beam the joint is mounted on, as a force and its moment at that node,
14
+ solved one way and then the other in every pose (#302). `frame.solve` names them (`refs.onJoints`).
15
+ - `frame.size` holds every join of a grouped beam to fit the profiles chosen (#303): a blind join's screw must pass
16
+ the other beam's slot opening and its button head sit under the lips; an end-tap's cap head must not fall through
17
+ the far face's slot; a bought fitting must fit both profiles. A group whose next lighter profile breaks a join says
18
+ so as what set it ("set by a join").
19
+ - Racking as a sizing limit (#303): with `"frame": { "rack" }` or `"size": { "limits": { "rack": mm } }`, the side
20
+ push each way across, alone, is a case of its own, and the sway at each top node is held to the limit. A way nothing
21
+ holds the frame is said and left out.
22
+ - `frame.solve`, `frame.rack`, `frame.buckling` and `frame.frequency` say how a frame moves where nothing holds it
23
+ ("the frame tips over along y", "x1 spins on its own axis", `refs.how`), with the freedoms that show it, where
24
+ they named a freedom at a node (#304).
25
+
26
+ ### Changed
27
+
28
+ - A moving joint mounted on a beam is swept through its travel: each end and its quarters between
29
+ (`FRAME_CHECK.sweep`, 4), where a slide was solved at its ends and middle and a hinge at its ends (#302). A
30
+ carriage's worst place for the sag at a point off a span's middle lies between the two: on the riding test's
31
+ 600 mm beam, 325 mm along where the far end was taken before. Frames with a moving joint now say more poses.
32
+ - A frame stood on its lowest ends with nothing saying so (no feet, no `"frame": { "supports" }`) now warns in
33
+ `frame.solve` even where those ends, pinned, hold it (#304); before, only a guess that changed how they are held
34
+ warned. Give a frame feet or supports to clear it.
35
+ - `"frame": { "supports": {} }` is refused by name: it names nowhere the frame is held (#304).
36
+ - The sizing table's example in the README: the table's legs and short rails are 2020, not 1515 OpenBeam, whose joins
37
+ to the 2040 rails and 2020 legs do not go together.
38
+
39
+ ## 0.7.77: a leg's gait for the streamer (#199)
40
+ ### Added
41
+
42
+ - `cad machine <project>/<assembly>` on an assembly with a `gait` and no `task`: a legged machine, an axis for each
43
+ motor's shaft the gait turns, ordered by the CNC shield slot (X, Y, Z) its motor is wired to, each with its `slot`.
44
+ - `cad plot <project>/<assembly>` with no drawing, on an assembly with a gait: the gait as a step file for the streamer,
45
+ `exports/<project>/<assembly>-gait.steps.json`, from the pose shown (`--pose` for another) through `--cycles` (3) and
46
+ back, at the gait's period or `--period`, and a picture of each axis through the run in `.preview/`. A motor wired to
47
+ a slot out of the streamer's order fails (`stream.wiring`); more than three axes is a warning (`stream.axes`). The
48
+ bench stand's gait plays at 2.89 s a cycle against its 2 s period: its knee would need 11712 steps/s, past the 5333
49
+ of a 17HS4401 at 200 rpm and 1/8 steps.
50
+
8
51
  ## 0.7.75: parts milled, cast or printed in a powder bed
9
52
  ### Added
10
53
 
package/README.md CHANGED
@@ -818,7 +818,8 @@ address stands for the faces near it, as `item@anchor` does (`"within"`, 10 mm b
818
818
  load, a named point or a support meets it), where it is held, the poses solved, and each join's spring with what
819
819
  it rests on. A join puts the end of `a` on a node at `b`'s axis through a rigid link (the end stands half `b`'s
820
820
  width off that axis) and its spring (`join.stiffness`) at that end. It is held where `"frame": { "supports": {
821
- "z1.a": "pinned", "z2.a": "fixed" } }` says; else at the beam ends a foot, levelling foot, castor plate or
821
+ "z1.a": "pinned", "z2.a": "fixed" } }` says (an empty `"supports": {}` is refused by name: it names nowhere the
822
+ frame is held); else at the beam ends a foot, levelling foot, castor plate or
822
823
  stacking foot (printed or bought) is fitted to; else at its lowest beam ends. Feet and lowest ends are pinned: held
823
824
  from moving and free to turn, as a foot stands on a floor. Where lowest ends pinned would leave the frame free to
824
825
  move (two posts and a rail leaning over out of their plane, a beam on the floor rolling with a post on it), a beam
@@ -827,14 +828,18 @@ address stands for the faces near it, as `item@anchor` does (`"within"`, 10 mm b
827
828
  feet would leave it free (the portal tipping over out of its plane, below), so `frame.solve` warns: it names the
828
829
  freedoms pinned feet would leave (`refs.free`) and the ends held in their place (`refs.guessed`), says that every
829
830
  sag, rack, buckling and frequency figure rests on them, and asks for feet or `"frame": { "supports" }`.
830
- `frame.rack`, `frame.buckling` and `frame.frequency` each say they rest on the guess (`refs.guessed`). Beams no support holds through joins are left out by
831
+ `frame.rack`, `frame.buckling` and `frame.frequency` each say they rest on the guess (`refs.guessed`). Lowest ends
832
+ guessed and left pinned (a frame they hold) are a guess too: `frame.solve` warns that nothing says where the frame
833
+ stands, names the ends (`refs.guessed`) and asks for feet or supports. Beams no support holds through joins are left out by
831
834
  name, and so is what is mounted only on them, as not weighed (`refs.off`). A beam that rides a moving joint (a
832
835
  gantry's cross beam on its carriages) is a load on the frame, named as riding (`refs.riding`), not part of it;
833
836
  lying across two parallel beams at one level (a gantry's beam on its two side beams), its weight is shared between
834
837
  them by the lever rule, though its joint is on one, and `refs.riding` gives each share. Where part of the frame can
835
838
  move with nothing resisting it (a frame in one plane on pinned feet sways out of that plane; a beam pinned at both
836
839
  ends spins on its own axis) and its loads do not move it that way, it is held there for the sag and the stresses,
837
- and `frame.solve` names each such freedom (`refs.held`); `frame.rack` then warns that a push that way finds it
840
+ and `frame.solve` says how it moves there (`refs.how`: "the frame tips over along y" where its top moves across
841
+ and its feet stay, "x1 spins on its own axis" where a beam only turns) with the freedoms that show it
842
+ (`refs.held`); `frame.rack` then warns that a push that way finds it
838
843
  free. The modes and buckling count it free: `frame.frequency` gives a lowest mode of 0 Hz and warns, and where
839
844
  the frame's squeezed beams lean it that way (a portal on pinned feet), `frame.buckling` fails it as tipping over
840
845
  before anything buckles, at a factor of 0 (`refs.tipped`).
@@ -843,7 +848,16 @@ address stands for the faces near it, as `item@anchor` does (`"within"`, 10 mm b
843
848
  centre, as a force and a moment at the node where its chain of mounts meets the beam; a riding beam's sheet weight
844
849
  at its middle the same way) and each `mass` in `"loads"`.
845
850
  A mass on a moving joint mounted on a beam, such as a carriage on a guide, is solved at each end of its travel
846
- (a slide in its middle too), at every named pose and as drawn; the worst is named.
851
+ and at its quarters between (`frame.sweep`, 4 steps), at every named pose and as drawn; the worst is named. A
852
+ carriage's worst place for the sag at a point off a span's middle lies between the point and the middle, which
853
+ the ends alone miss.
854
+ Each `"loads"` entry on a joint (a force on a slide, a torque on a hinge) and a belt guide's push at its
855
+ carriage's acceleration is carried through the joint, held by its motor, into the beam the joint's chain is
856
+ mounted on: a slide's force along its axis through the joint's place, as a force and its moment at that node, a
857
+ hinge's torque as a moment. Nothing says which way such a load acts, so each pose is solved with them one way and
858
+ then the other (`as drawn, joint loads +`, `... joint loads -`), and `frame.solve` names them (`refs.onJoints`).
859
+ A belt's share of its carriage's own weight along the travel is that weight, already on the frame, and is not
860
+ counted again.
847
861
  - `frame.deflection`: the sag at each load's point, at each place in `"frame": { "points": ["x2.top@50%"] }` and
848
862
  along every guide's travel, with the joins' springs and with the joins rigid, and the load's own share. The first
849
863
  rests on the joins' springs, estimates until the joint rig measures them, and the finding says so (`refs.restsOn`:
@@ -1126,29 +1140,44 @@ joins' springs, the loads and mounted items):
1126
1140
  - `"groups"`: `{ "rails": ["x1", "x2", "y1", "y2"] }`, beams that take one profile together. The rest group by
1127
1141
  themselves: beams of one profile lying the same way whose lengths agree within 0.5 mm (`FRAME_SIZING.match`), so a
1128
1142
  table's four legs are one group and each pair of rails another.
1143
+ - Joins that fit: a design is only solved where every join of a grouped beam still goes together with the profiles
1144
+ chosen. A blind join needs a bore in a's end and a slot in b's face whose opening passes the bore's screw and holds
1145
+ its button head under the lips, the head no wider than the slot is under them; an end-tap join a bore in a's end,
1146
+ and a cap head wider than the opening of a slot on b's far face; a bought fitting must fit both profiles (its set's
1147
+ `fitting.fit`). A printed fitting is drawn for the profiles it joins. A group whose next lighter profile breaks a
1148
+ join says so as what set it ("set by a join": with 1515-openbeam, an M5 screw from a 2040's bore does not pass
1149
+ OpenBeam's 3.2 mm slot opening).
1150
+ - Racking: where the assembly gives `"frame": { "rack" }` or `"limits": { "rack": mm }`, each way across the side
1151
+ push `frame.rack` uses, alone and with no weight, is a case of its own, and the sway at each top node is held to
1152
+ the limit `frame.rack` uses (or `limits.rack`). A way nothing holds the frame (one plane on pinned feet) is said and
1153
+ left out: a brace or fixed feet hold it, not a profile. The joins' springs are as drawn and do not grow with the
1154
+ profile, so a frame that racks on its joins' bending may meet the limit with no profile in the list: the sizing then
1155
+ gives the nearest and says racking is what it misses.
1129
1156
  - `"limits"`: in place of the checks' own. Left out, each is the check's: the sag at each load, named point and guide
1130
1157
  as `frame.deflection` holds it (a guide's rail parallelism, `frame.limit`, the task's accuracy, else the span over
1131
1158
  360; a load that moves with a joint anywhere along its beam), each beam's stress with the joins' springs and with
1132
1159
  them rigid against its alloy's strength `frame.margin` (2) times over, the frame's first buckling factor and each
1133
1160
  grouped beam's Euler load (K 1) the same, and the lowest mode at twice the task's moves where it has a task.
1134
- `"deflection"` (mm, at every load, point and guide), `"stress"` and `"buckling"` (margins) and `"frequency"` (Hz)
1135
- replace them.
1161
+ `"deflection"` (mm, at every load, point and guide), `"stress"` and `"buckling"` (margins), `"frequency"` (Hz) and
1162
+ `"rack"` (the sway allowed at the top, mm) replace them.
1136
1163
  - `"by"`: `mass`. No profile set in the kit gives a price per metre yet, so `cost` is refused by name.
1137
1164
 
1138
1165
  `cad check` gives `frame.size`: each group's profile, its mass, the limit that set it and how many times inside that
1139
1166
  limit it stands. `cad frame <project>/<assembly> --size` prints the table:
1140
1167
 
1141
1168
  ```
1142
- sized: 2.56 kg of grouped beams (drawn 2.74 kg), 66 designs solved (every design ranked by mass)
1169
+ sized: 3.348 kg of grouped beams (drawn 2.74 kg), 14 designs solved (every design ranked by mass)
1143
1170
  group | profile | kg | set by | margin
1144
- z1, z2, z3, z4 | 1515-openbeam (drawn 2020-misumi-hfs5) | 0.855 | buckling: with 1010-makerbeam, the frame's buckling factor breaks its limit 2.68 times over | 1.28x
1145
- x1, x2 | 2040-misumi-hfs5 turned (drawn 2020-misumi-hfs5) | 1.408 | deflection: with 2020-misumi-hfs5, the sag at x2@400 breaks its limit 2.31 times over | 2.41x
1146
- y1, y2 | 1515-openbeam (drawn 2020-misumi-hfs5) | 0.297 | deflection: with 1010-makerbeam, the sag at y2@250 breaks its limit 2.39 times over | 1.17x
1171
+ z1, z2, z3, z4 | 2020-misumi-hfs5 | 1.44 | a join: with 1515-openbeam, blind join of x1.a to z1.back@710 does not go together (an M5 screw (2040-misumi-hfs5's bore) does not pass 1515-openbeam's 3.2 mm slot opening) | 7.29x
1172
+ x1, x2 | 2040-misumi-hfs5 turned (drawn 2020-misumi-hfs5) | 1.408 | deflection: with 2020-misumi-hfs5, the sag at x1@400 breaks its limit 1.96 times over | 2.56x
1173
+ y1, y2 | 2020-misumi-hfs5 | 0.5 | a join: with 1515-openbeam, blind join of y1.a to z1.top@710 does not go together (an M3 button head, 5.7 mm across, pulls through 2020-misumi-hfs5's 6 mm slot opening) | 3.33x
1147
1174
  ```
1148
1175
 
1149
1176
  "Set by" is the limit the group's next lighter profile breaks, the other groups as chosen: what stops it being any
1150
- lighter. A group already at the lightest in the list says so. With `"limits": { "deflection": 6 }` the long rails
1151
- drop to 2020 and the grouped beams to 1.95 kg.
1177
+ lighter, or the join it would not make. A group already at the lightest in the list says so. With `"limits": {
1178
+ "deflection": 6 }` the long rails drop to 2020 and the grouped beams to 2.74 kg. Without the joins held to fit, the
1179
+ legs and short rails came out 1515 OpenBeam, whose M3 ends and 3.2 mm slots take neither the 2040 rails' M5 screws
1180
+ nor a 2020 leg's slot.
1152
1181
 
1153
1182
  `--write` writes the profiles into the assembly: each grouped beam's profile, a quarter `roll` where it was turned,
1154
1183
  and its printed end fittings drawn for it. A generated frame is written out expanded, as `--expand` does, since a
@@ -1158,8 +1187,8 @@ join at an end that now has two bores (a 2040) becomes a join a bore. A drawn be
1158
1187
  the end of the beam it meets (a rail flush with its legs' tops, now a 2060) moves along that beam by as much, so its
1159
1188
  face there stays where it was, if the move fits at its other end too; where it does not, nothing is written and the
1160
1189
  refusal names the join and the beam. Otherwise beams keep their lines. Check the
1161
- written frame: its join checks say where a profile's screws do not fit another's slots, so choose the list from one
1162
- family whose joins fit each other (MISUMI HFS5's 2020 to 2080 share one slot and one end thread).
1190
+ written frame: its join checks hold every screw, nut and length, where the sizing held each join's screw and head to
1191
+ its slot.
1163
1192
 
1164
1193
  What it rests on: the joins' springs are as drawn (an estimate until the joint rig measures them) and do not change
1165
1194
  with the profile; the sizing solves the drawn layout, with each beam's line where it is drawn, so a figure on the
@@ -1705,7 +1734,7 @@ module and read `pip`'s variables) and name them in the assembly's `"printInPlac
1705
1734
  together, so the assembly order never takes them apart from each other. `cad order` fits them as one step and
1706
1735
  `cad list` gives them one printed row, the one print's grams and minutes.
1707
1736
 
1708
- An assembly with a `gait` (EXAMPLES chapter 14) plays too: `cad animate <project>/<assembly>` writes the cycle as an animated SVG in `.preview/` (a side view of the legs and a plan of the feet and what they stand on) and its data as JSON. The model page plays the same cycle in its Motion panel.
1737
+ An assembly with a `gait` (EXAMPLES chapter 14) plays too: `cad animate <project>/<assembly>` writes the cycle as an animated SVG in `.preview/` (a side view of the legs and a plan of the feet and what they stand on) and its data as JSON. The model page plays the same cycle in its Motion panel. `cad machine <project>/<assembly>` on such an assembly describes it as a legged machine, an axis for each motor's shaft in the order the shield's slots are wired, and `cad plot <project>/<assembly>` with no drawing writes the gait as a step file for the streamer: `--cycles` of it (3) from a pose (`--pose`, by default the one shown) and back, every axis in each block, slowed where a motor cannot keep to the gait's period (`--period` to set it) and where a joint turns back, with a picture of each axis through the run in `.preview/`. A motor wired to a shield slot out of the streamer's order (X, Y, Z) fails by name.
1709
1738
 
1710
1739
  An assembly with a motor, or with gears that follow a joint, plays its drive: `cad animate <project>/<assembly>` writes `<assembly>-drive.svg`, the gears cut across their shafts through their teeth (up to three cuts side by side, a compound planetary's two rings each in its own), each part turning and moving as it does, the part with the load picked out. It turns the drive until the slowest part has moved about 60° (one to six turns; `--turns n` to choose). Each part's outline is drawn once and moved, so a gearbox stays a few hundred kilobytes.
1711
1740
 
package/bin/cad.mjs CHANGED
@@ -111,6 +111,8 @@ const HELP = `cad: JSCAD designs you can trace, check, share and print (rulecad)
111
111
  cad machine <project>/<assembly> the machine as plain data: axes, steps, limits, homing, the task, in exports/
112
112
  cad plot <project>/<assembly> <drawing.svg> plans a drawing on the machine: a step file in exports/, an animation in
113
113
  .preview/, and any stroke refused [--calibrate: the calibration drawing] [--tol 0.1] [--json]
114
+ cad plot <project>/<assembly> on an assembly with a gait: its cycle as a step file in exports/ for the streamer, from a pose and
115
+ back to it, and a picture of each axis through the run in .preview/ [--cycles 3] [--period s] [--pose <start>] [--json]
114
116
  cad order <project>/<assembly> the order it goes together in, each step with its fasteners; a frame from bars to square: cut, drill, sides built flat, nuts to load, joins with their torque, diagonals [--preview: an exploded picture of each step in .preview/]
115
117
  cad plates <project>/<assembly> every printed part on beds, by material and filament, spaced by the first-layer rule: written as plate assemblies and checked; a changed part re-packs only its plate; a frame's jigs on plates of their own [--gap mm] [--no-jigs] [--json]
116
118
  cad kit <project>/<assembly> the folder to build it from without the model, in exports/: README.md (checks, what to buy and print, cut list, drilling, the build step by step), buy.csv, the plates' 3MFs, the jigs, each beam's sheet [--pictures] [--json]
@@ -164,7 +166,7 @@ const COMMANDS = ['new', 'remove', 'move', 'import-kle', 'clone', 'agents', 'tru
164
166
  const OPTIONS = ['table', 'calibrate', 'check', 'turns', 'preview', 'gap', 'no-steps', 'all', 'along', 'at', 'bump', 'depth', 'dry-run', 'explode', 'force', 'fresh', 'json', 'licence', 'license', 'long', 'm', 'material', 'md', 'name', 'new',
165
167
  'no-models', 'no-pictures', 'no-rules', 'note', 'open', 'part', 'place', 'pose', 'profile', 'progress', 'push', 'result', 'rules', 'samples', 'set', 'short', 'source', 'steps',
166
168
  'sweep', 'tol', 'trailer', 'ttl', 'version', 'watch', 'line',
167
- 'unit', 'rule', 'label', 'from', 'out', 'jigs', 'no-jigs', 'expand', 'size', 'write', 'pictures', // cad set, cad rules, cad beams, cad frame, cad plates, cad kit
169
+ 'unit', 'rule', 'label', 'from', 'out', 'jigs', 'no-jigs', 'expand', 'size', 'write', 'pictures', 'cycles', 'period', // cad set, cad rules, cad beams, cad frame, cad plates, cad kit, cad plot
168
170
  'a', 'b', 'min', 'max', 'poses', 'id', 'type', 'parent', 'child', 'follow', 'value', 'ratio', 'object', 'assembly', 'variant', 'rotate', 'to', 'roll', // cad add
169
171
  'screw', 'through', 'into', 'holes', 'nut', 'washer', 'length', 'torque', 'from-fits', // cad add fasten
170
172
  'kind', 'fitting', // cad add join
@@ -1115,7 +1117,8 @@ async function machineCommand(what, ref) {
1115
1117
  const m = await import('../lib/machine.mjs'), s = await buildAssembly(ref);
1116
1118
  if (what === 'machine') { const out = m.machineOf(s), file = m.writeMachine(s, out); (await import('../lib/buildpage.mjs')).writeWiring(s); return console.log(opt('json') ? JSON.stringify(out, null, 2) : file); }
1117
1119
  const source = positional()[2], tol = opt('tol') != null ? Number(opt('tol')) : undefined;
1118
- if (!source && !opt('calibrate')) throw new Error('usage: cad plot <project>/<assembly> <drawing.svg> [--calibrate]');
1120
+ if (!source && !opt('calibrate') && s.gait && !s.task?.sheet) return gaitPlot(m, s, ref);
1121
+ if (!source && !opt('calibrate')) throw new Error('usage: cad plot <project>/<assembly> <drawing.svg> [--calibrate], or cad plot <project>/<assembly> on an assembly with a gait');
1119
1122
  const { sheetFrame } = await import('@rulecad/robots'), f = s.task?.sheet ? sheetFrame(s.task.sheet) : null;
1120
1123
  const svg = opt('calibrate') ? m.CALIBRATION(f?.width ?? 148, f?.height ?? 210) : fs.readFileSync(source, 'utf8'), base = `${s.name}-${opt('calibrate') ? 'calibration' : path.basename(source, path.extname(source))}`;
1121
1124
  const r = m.plot(s, svg, { tolerance: tol, name: base });
@@ -1126,6 +1129,18 @@ async function machineCommand(what, ref) {
1126
1129
  process.exitCode = failed ? 1 : 0;
1127
1130
  }
1128
1131
 
1132
+ // A gait as a step file: --cycles (3), --period (s a cycle; default the gait's), --pose (where it starts and ends; default the one shown)
1133
+ async function gaitPlot(m, s, ref) {
1134
+ const cycles = opt('cycles') != null ? Number(opt('cycles')) : 3, period = opt('period') != null ? Number(opt('period')) : undefined;
1135
+ if (!Number.isInteger(cycles) || cycles < 1) throw new Error(`--cycles is a whole number, 1 or more (got ${opt('cycles')})`);
1136
+ if (period != null && !(period > 0)) throw new Error(`--period is the seconds of one cycle, above 0 (got ${opt('period')})`);
1137
+ const r = m.plotGait(s, { cycles, period, from: opt('pose') });
1138
+ if (opt('json')) { console.log(JSON.stringify({ ok: r.ok, findings: r.findings, time: r.time, ...(r.ok ? { file: m.writeGait(s, r).file } : {}) }, null, 2)); process.exitCode = r.ok ? 0 : 1; return; }
1139
+ report(r.findings, { assembly: ref, title: `${ref}: its gait` });
1140
+ if (r.ok) { const w = m.writeGait(s, r); console.log(path.relative(WS, w.file)); console.log(path.relative(WS, w.preview)); }
1141
+ process.exitCode = r.ok ? 0 : 1;
1142
+ }
1143
+
1129
1144
  async function platesCommand(what, ref) {
1130
1145
  if (!isAssembly(ref)) throw new Error(`cad ${what} works on an assembly (<project>/<assembly>), and there is no "${ref}"`);
1131
1146
  const s = await buildAssembly(ref);
@@ -53,6 +53,7 @@ export const FRAME_CHECK = {
53
53
  order: { value: ['gusset', 'brace', 'panel'], unit: '', rule: 'The changes that stiffen a bay against racking, cheapest first: gussets at its corners (four printed or bought plates), one diagonal brace (a length of the bay\'s own profile and two fittings), a panel (a sheet and its clips). The first in this order that brings the sway under the limit is advised, in one bay before every bay that way', kind: 'default', source: 'A working order of @rulecad/cad, by the parts each needs; cad list prices them', checked: '2026-11-17' },
54
54
  clip: { value: 200, unit: 'N/mm', rule: 'How stiffly one panel clip holds the sheet\'s edge from sliding along the beam: the clip grips the sheet by friction and its edge sits half a millimetre off the step, so this is a guess at the friction\'s stiffness, the weak link of a panel as a shear web', kind: 'estimate', source: 'A working guess of @rulecad/cad, with no measurement behind it: a panel on the joint rig would measure it', checked: '2026-11-17' },
55
55
  band: { value: 0.2, unit: '', rule: 'A mode within this share of a frequency the machine dwells at (a stepper\'s full-step rate at its working speed) is near enough to ring', kind: 'estimate', source: 'A working figure of @rulecad/cad: a lightly damped mode amplifies a forcing within about ±20% of it several times over', checked: '2026-11-17' },
56
+ sweep: { value: 4, unit: 'steps', rule: 'A moving joint mounted on a beam is solved at each end of its travel and at this many equal steps of it between (its quarters), so a worst place between the ends is found: a carriage between two supports at its middle, an arm on a hinge where it lies level', kind: 'default', source: 'A working figure of @rulecad/cad: quarters hold a middle and the quarter points, each step one more solve of every check', checked: '2026-11-24' },
56
57
  ramp: { value: 500, unit: 'mm/s²', rule: 'Where the task gives no accel, the acceleration a move ramps at: a move at the task\'s speed ramps for speed over this many seconds, and shakes the frame at about one over that time', kind: 'default', source: 'The same default as cad machine\'s task.accel (lib/machine.mjs)', checked: '2026-11-17' },
57
58
  };
58
59
 
@@ -123,6 +124,36 @@ function webOf(bay, sheet, t, clips, id) {
123
124
  element: { id: `panel ${id}`, a: bay.corners[0], b: bay.corners[2], section: { A, Iy: A * (d / 10) ** 2, Iz: A * (d / 10) ** 2, J: A * (d / 10) ** 2 }, material: { E: WEB_E, G: WEB_E / 2.6, density: 0 }, ends: { a: 'ball', b: 'pinned' } } };
124
125
  }
125
126
 
127
+ // How a frame moves where nothing holds it, in words, from each way @rulecad/fea finds it moves (frame().mechanisms,
128
+ // each node's six, its largest movement 1): its top moving across "down" with its feet still is the frame tipping over
129
+ // that way (named by the world axis nearest), a movement mostly along "down" a beam dropping, and a way that only
130
+ // turns a beam spinning on its own axis (or turning about the axis nearest, where that is not its own). Each said once,
131
+ // with the freedoms that showed it.
132
+ const beamOfNode = (n) => String(n).split(/[.@#/]/)[0];
133
+ function howFree(fm, ways) {
134
+ const out = new Map();
135
+ for (const w of ways ?? []) {
136
+ const sh = w.shape ?? {};
137
+ let lead = null, most = 0, spin = null, turn = 0;
138
+ for (const [n, v] of Object.entries(sh)) { const t = Math.hypot(v[0], v[1], v[2]), r = Math.hypot(v[3], v[4], v[5]); if (t > most) { most = t; lead = n; } if (r > turn) { turn = r; spin = n; } }
139
+ const nearest = (v) => 'xyz'[[0, 1, 2].reduce((p, q) => (Math.abs(v[q]) > Math.abs(v[p]) ? q : p), 0)];
140
+ let says;
141
+ if (lead && most > 1e-6) {
142
+ const d = sh[lead].slice(0, 3), v = dot(d, fm.down), h = sub(d, scale(fm.down, v));
143
+ says = Math.hypot(...h) >= Math.abs(v) ? `the frame tips over along ${nearest(h)}` : `${beamOfNode(lead)} drops at ${lead}`;
144
+ } else if (spin) {
145
+ const r = sh[spin].slice(3), b = fm.beams.get(beamOfNode(spin));
146
+ says = b && Math.abs(Math.abs(dot(unitv(r), b.u)) - 1) < 1e-3 ? `${b.id} spins on its own axis` : `it turns about ${nearest(r)} at ${spin}`;
147
+ } else says = `it moves at ${w.node} (${w.freedom})`;
148
+ out.set(says, [...(out.get(says) ?? []), { node: w.node, freedom: w.freedom }]);
149
+ }
150
+ return [...out].map(([says, at]) => ({ says, at }));
151
+ }
152
+ // the ways in one clause each, and where each is free: "the frame tips over along y (free at z2.b: rx)"
153
+ const howSaid = (hs) => hs.map((h) => `${h.says} (free at ${[...h.at.reduce((m, l) => m.set(l.node, [...(m.get(l.node) ?? []), l.freedom]), new Map())].map(([n, fr]) => `${n}: ${fr.join(', ')}`).join('; ')})`).join(', and ');
154
+ // the mechanisms of a solved frame that match freedoms named (a refusal's or buckling's), by node and freedom
155
+ const waysAt = (solved, ls) => (solved?.mechanisms ?? []).filter((m) => ls.some((l) => l.node === m.node && l.freedom === m.freedom));
156
+
126
157
  // what a join's spring rests on, in a few words
127
158
  const restsWord = (k) => (k.measured?.bending && k.measured?.twist ? 'measured' : k.fitting ? 'a printed fitting by finite elements' : k.bought?.own ? `${k.bought.set}'s own figures, ${k.kind}` : 'an estimate');
128
159
 
@@ -152,7 +183,7 @@ export function frameModelOf(s, helpers) {
152
183
  const movesWith = (k) => { for (let i = k, n = 0; n < 99; n++) { const j = byChild.get(i); if (!j) return false; if (moving(j)) return true; i = j.parent; } return false; };
153
184
  const down = (() => { const g = motion.gravity || [0, 0, -1], l = Math.hypot(...g) || 1; return g.map((c) => c / l); })();
154
185
  // the beams: still ones only (a beam on a carriage is a load, not the frame: its weight is carried below)
155
- const beams = new Map(), left = [], riding = [];
186
+ const beams = new Map(), left = [], riding = [], loose = [];
156
187
  for (const o of s.objects) {
157
188
  if (!o.beam || o.unplaced) continue;
158
189
  const k = ids.indexOf(o.id);
@@ -196,19 +227,31 @@ export function frameModelOf(s, helpers) {
196
227
  return [{ mount: mt, part: p1, s: s1 }, { mount: { ...mt, beam: b, sign, shift }, part: 1 - p1, s: s2 }];
197
228
  };
198
229
 
199
- // the poses: as drawn, each named pose, and each moving joint mounted on a beam at either end of its travel (a slide in
200
- // its middle too)
201
- const cases = [{ label: 'as drawn', values: base }];
202
- for (const p of Object.keys(motion.poses || {})) cases.push({ label: `pose ${p}`, values: jointValues(motion, p) });
203
- const movers = motion.joints.filter((j) => moving(j) && beams.has(ids[j.parent]) && j.dofs?.length === 1);
204
- // (a slide also at the middle of its travel, where a carriage between two supports bends its beam most, unless drawn there)
230
+ // the poses: as drawn, each named pose, and each moving joint mounted on a beam swept through its travel: each end and
231
+ // frame.sweep steps between (a step where it is drawn is the drawn pose)
232
+ const poses = [{ label: 'as drawn', values: base }];
233
+ for (const p of Object.keys(motion.poses || {})) poses.push({ label: `pose ${p}`, values: jointValues(motion, p) });
234
+ const movers = motion.joints.filter((j) => moving(j) && beams.has(ids[j.parent]) && j.dofs?.length === 1), steps = FRAME_CHECK.sweep.value;
205
235
  for (const j of movers) {
206
- const [lo, hi] = j.dofs[0], mid = (lo + hi) / 2, drawn = base[j.id]?.[0];
207
- for (const v of [lo, hi, ...(j.type === 'prismatic' && !(drawn != null && Math.abs(drawn - mid) < 1e-6) ? [mid] : [])]) cases.push({ label: `${j.id} at ${n3(v, 1)}`, values: { ...base, [j.id]: [v] } });
236
+ const [lo, hi] = j.dofs[0], drawn = base[j.id]?.[0], between = Array.from({ length: steps - 1 }, (_, k) => lo + ((hi - lo) * (k + 1)) / steps).filter((v) => !(drawn != null && Math.abs(drawn - v) < 1e-6));
237
+ for (const v of [lo, hi, ...between]) poses.push({ label: `${j.id} at ${n3(v, 1)}`, values: { ...base, [j.id]: [v] } });
208
238
  }
239
+ // what a joint must push or turn against ("loads" on joints: a force on a slide, a torque on a hinge, and a belt's
240
+ // push at its carriage's acceleration), carried through the joint, held by its motor, into the beam its chain is
241
+ // mounted on: each in every pose, one way and then the other (none says which way it acts). A belt's share of its
242
+ // carriage's own weight along the travel is that weight, already on the frame, so it is not counted again
243
+ const onJoints = [];
244
+ for (const l of motion.loads || []) {
245
+ if (l.joint == null || l.beltWeight || !(Math.abs(l.value) > 0)) continue;
246
+ const j = motion.joints.find((x) => x.id === l.joint), mt = j ? mountOf(j.child) : null;
247
+ if (!j) continue;
248
+ if (!mt) { loose.push(`the load on ${j.id}`); continue; }
249
+ onJoints.push({ joint: j, value: Math.abs(l.value), unit: j.type === 'prismatic' ? 'N' : 'N m', note: l.note ?? null, belt: l.belt ?? null, mount: mt });
250
+ }
251
+ const cases = onJoints.length ? poses.flatMap((c) => [{ ...c, label: `${c.label}, joint loads +`, push: 1 }, { ...c, label: `${c.label}, joint loads -`, push: -1 }]) : poses;
209
252
 
210
253
  // what weighs on the frame: items (beams' own weight is the elements'), and the masses of "loads"
211
- const masses = massesOf(s, { placeItems, jointValues }), carried = [], loose = [], unknown = [];
254
+ const masses = massesOf(s, { placeItems, jointValues }), carried = [], unknown = [];
212
255
  // a panel (not a door) on a bay of frame beams is a shear web of the frame: its weight goes to its bay's corners; on
213
256
  // beams that make no bay, its weight is spread along those of the frame
214
257
  const sheets = (s.panels ?? []).filter((p) => !p.door && p.bay?.some((id) => beams.has(id))).map((p) => ({ ...p, kg: (p.model?.grams ?? 0) / 1000 }));
@@ -243,7 +286,7 @@ export function frameModelOf(s, helpers) {
243
286
  if (!mt) { loose.push(`load ${i + 1} (${where})`); return; }
244
287
  loads.push({ index: i, kg: l.mass, where, item: l.item, point, mount: mt, note: l.note });
245
288
  });
246
- for (const c of [...carried, ...loads.filter((l) => l.mount)]) for (const cs of cases) snap(c.mount.beam, mountStation(c.mount, cs.values));
289
+ for (const c of [...carried, ...loads.filter((l) => l.mount), ...onJoints]) for (const cs of poses) snap(c.mount.beam, mountStation(c.mount, cs.values));
247
290
  // named points, and every guide's travel
248
291
  const points = (opts.points ?? []).map((p, i) => {
249
292
  const t = String(p), id = t.split('.')[0], b = beams.get(id);
@@ -261,6 +304,7 @@ export function frameModelOf(s, helpers) {
261
304
  const supports = [];
262
305
  if (opts.supports != null) {
263
306
  if (typeof opts.supports !== 'object' || Array.isArray(opts.supports)) throw new Error(`frame.supports is { "z1.a": "pinned", "z2.a": "fixed" } (got ${shown(opts.supports)})`);
307
+ if (!Object.keys(opts.supports).length) throw new Error('frame.supports names no support: give at least one place the frame is held, as { "z1.a": "pinned" }, or leave supports out to stand the frame on its feet or its lowest ends');
264
308
  for (const [addr, how] of Object.entries(opts.supports)) {
265
309
  const id = addr.split('.')[0], b = beams.get(id);
266
310
  if (!b) throw new Error(`frame.supports: "${addr}" is on a beam of the frame, as z1.a or x1.bottom@50% (beams: ${[...beams.keys()].join(', ')})`);
@@ -358,7 +402,7 @@ export function frameModelOf(s, helpers) {
358
402
  let free = [];
359
403
  // (in the model as solved and in the pieces modes and buckling are solved in, where a freedom can show that
360
404
  // rounding hid in the whole: either says the frame is free)
361
- for (const rigid of [false, true]) for (const m of [withSprings(rigid), subdivide(withSprings(rigid), 4)]) try { free.push(...solveFrame(m).loose); } catch { /* refused: said by the solve itself */ }
405
+ for (const rigid of [false, true]) for (const m of [withSprings(rigid), subdivide(withSprings(rigid), 4)]) try { free.push(...solveFrame(m).mechanisms); } catch { /* refused: said by the solve itself */ }
362
406
  if (free.length) {
363
407
  for (const x of guessed) {
364
408
  const lies = supports.some((y) => y !== x && y.beam === x.beam) && axisOfBeam(x.beam) >= 0, stands = Math.abs(dot(x.beam.u, down)) > 1 - 1e-6;
@@ -367,19 +411,28 @@ export function frameModelOf(s, helpers) {
367
411
  }
368
412
  mapSupports();
369
413
  const seen = new Set();
370
- guess = { free: free.filter((l) => { const k = `${l.node} ${l.freedom}`; return !seen.has(k) && seen.add(k); }).map(({ node, freedom }) => ({ node, freedom })),
414
+ const ways = free.filter((l) => { const k = `${l.node} ${l.freedom}`; return !seen.has(k) && seen.add(k); });
415
+ guess = { free: ways.map(({ node, freedom }) => ({ node, freedom })), ways,
371
416
  supports: guessed.filter((x) => x.why !== 'a lowest end').map((x) => ({ where: x.where, how: x.how, why: x.why })) };
372
417
  if (!guess.supports.length) guess = null; // (nothing changed: the guess stays pinned, and the solve says what is free)
373
418
  }
374
419
  }
375
420
  // the loads at each pose: every carried item's and load's weight as a force and a moment at its node
376
- const nodeLoads = (values, only) => {
421
+ const nodeLoads = (values, only, push) => {
377
422
  const W = placeItems(motion, values), out = [];
378
423
  const put = (b, z, C, kg) => { const n = nodeAt(b, z); if (!n) throw new Error(`frame: no node on ${b.id} at ${n3(z)} mm for a load (a pose this check did not foresee)`); const F = scale(down, kg * G); out.push({ node: n, force: F, moment: cross(sub(C, nodes[n]), F) }); };
379
424
  for (const c of only ? [] : carried.filter(keep)) put(c.mount.beam, mountStation(c.mount, values), rowsAt(W[c.item], c.centre), c.kg);
380
425
  for (const l of loads.filter(keep)) { if (only && only !== l) continue; const C = rowsAt(W[l.item], l.point); if (l.beam) put(l.beam, l.z, C, l.kg); else put(l.mount.beam, mountStation(l.mount, values), C, l.kg); }
381
426
  for (const p of only ? [] : heldSheets) for (const n of bays[p.bay].corners) out.push({ node: n, force: scale(down, (p.kg / 4) * G), moment: [0, 0, 0] });
382
427
  for (const p of only ? [] : laid) for (const id of p.beams) { const b = beams.get(id), w = scale(down, ((p.kg / p.beams.length) * G) / b.L); for (const q of elements) if (q.of === id) out.push({ element: q.id, spread: w }); }
428
+ // a joint's load, one way (push 1) or the other (-1): a slide's force along its axis through the joint's place, a
429
+ // hinge's torque about its axis, each at the node where its chain meets the beam
430
+ for (const x of only || !push ? [] : onJoints.filter(keep)) {
431
+ const n = nodeAt(x.mount.beam, mountStation(x.mount, values));
432
+ if (!n) throw new Error(`frame: no node on ${x.mount.beam.id} for the load on ${x.joint.id} (a pose this check did not foresee)`);
433
+ const { O, Z } = axisOf(motion, W, x.joint, mul), F = x.unit === 'N' ? scale(Z, push * x.value) : [0, 0, 0];
434
+ out.push({ node: n, force: F, moment: x.unit === 'N' ? cross(sub(O, nodes[n]), F) : scale(Z, push * x.value * 1000) });
435
+ }
383
436
  return out;
384
437
  };
385
438
  // the same masses for a modal solve: each at the node it is carried at, in kg (its offset's rotary inertia left out)
@@ -396,7 +449,7 @@ export function frameModelOf(s, helpers) {
396
449
  // what is mounted only on beams left out (not held by a support through joins): not weighed, and named
397
450
  const off = [...new Map([...carried, ...loads].filter((c) => !keep(c) && !kept.has(c.id)).map((c) => [c.id ?? `load ${c.index + 1} at ${c.where}`, (c.mount?.beam ?? c.beam).id]))].map(([id, on]) => ({ id, on }));
398
451
  return { beams, left, missing, loose, unknown, off, riding: rides.filter((x) => kept.has(x.id)), carried: carried.filter(keep), loads: loads.filter(keep), points, guides: guides.filter(keep), supports: supports.filter(keep), joins: joins.filter((x) => beams.has(x.A.id)),
399
- cases, down, nodes, nodeAt, guess, model: withSprings(false), rigid: withSprings(true), nodeLoads, nodeMasses, bays, webs, sheets: heldSheets, laid, elements, mountStation, worlds, axisOf: (j) => axisOf(motion, worlds, j, mul) };
452
+ cases, poses, onJoints: onJoints.filter(keep), down, nodes, nodeAt, guess, model: withSprings(false), rigid: withSprings(true), nodeLoads, nodeMasses, bays, webs, sheets: heldSheets, laid, elements, mountStation, worlds, axisOf: (j) => axisOf(motion, worlds, j, mul) };
400
453
  }
401
454
 
402
455
  // the downward movement of a node, and along a beam between two stations (the worst of the element stations there)
@@ -421,6 +474,8 @@ export function frameChecks(s, f, helpers) {
421
474
  if (solved.error) { const guessed = fm.supports.every((x) => x.why.startsWith('a lowest end')); f(guessed ? 'info' : 'warn', `the frame is not solved: ${solved.error}. Its supports: ${fm.supports.map((x) => `${x.where} (${x.why})`).join(', ') || 'none'}${guessed ? '. Say where it is held: "frame": { "supports": { "z1.a": "pinned" } }, or fit its feet' : ''}`, guessed ? null : 'frame: not solved', { code: 'frame.solve', refs: { supports: fm.supports.map((x) => x.where), code: solved.code } }); return null; }
422
475
  const { results } = solved, down = fm.down, margin = FRAME_CHECK.margin.value, held = solved.loose ?? [];
423
476
  const heldList = [...held.reduce((m, l) => m.set(l.node, [...(m.get(l.node) ?? []), l.freedom]), new Map())].map(([n, fr]) => `${n} (${fr.join(', ')})`).join(', ');
477
+ // how it moves there, in words: the frame tipping over along y, a beam spinning on its axis
478
+ const heldHow = howFree(fm, solved.mechanisms), heldSaid = howSaid(heldHow);
424
479
  // what the joins rest on, counted by kind
425
480
  const kinds = new Map();
426
481
  for (const x of fm.joins) { const key = `${x.j.kind}${x.j.fitting ? ` (${x.j.fitting})` : ''}: ${restsWord(x.k)}`; kinds.set(key, (kinds.get(key) ?? 0) + 1); }
@@ -434,15 +489,17 @@ export function frameChecks(s, f, helpers) {
434
489
  const and = (xs) => (xs.length > 1 ? `${xs.slice(0, -1).join(', ')} and ${xs[xs.length - 1]}` : xs[0] ?? '');
435
490
  const posts = guess ? guess.supports.filter((x) => x.how === 'fixed').map((x) => x.where) : [], lying = guess ? guess.supports.filter((x) => x.how !== 'fixed').map((x) => x.where) : [];
436
491
  const guessHeld = [posts.length ? `${and(posts)} fixed, standing on ${posts.length > 1 ? 'their end faces' : 'its end face'}` : null, lying.length ? `${and(lying)} resting, held from twisting as ${lying.length > 1 ? 'ends of beams' : 'an end of a beam'} lying on its face` : null].filter(Boolean).join(', and ');
437
- const guessFree = guess ? listFree(guess.free) : '';
492
+ const guessFree = guess ? listFree(guess.free) : '', guessHow = guess ? howFree(fm, guess.ways) : [], guessSaid = howSaid(guessHow);
493
+ // supports guessed at the lowest ends and left pinned: nothing in the assembly says the frame stands there
494
+ const pinnedGuess = fm.supports.filter((x) => x.why === 'a lowest end').map((x) => x.where), guessedOnly = fm.supports.length > 0 && fm.supports.every((x) => x.why.startsWith('a lowest end'));
438
495
  if (guess) {
439
496
  const said = f;
440
497
  f = (level, text, card, extra = {}) => (['frame.rack', 'frame.buckling', 'frame.frequency'].includes(extra.code)
441
- ? said(level, `${text}. This rests on supports guessed, not given: ${guessHeld}, where pinned feet would leave the frame free at ${guessFree}`, card, { ...extra, refs: { ...extra.refs, guessed: guess.supports.map((x) => x.where) } })
498
+ ? said(level, `${text}. This rests on supports guessed, not given: ${guessHeld}, where on pinned feet nothing would hold it: ${guessSaid}`, card, { ...extra, refs: { ...extra.refs, guessed: guess.supports.map((x) => x.where) } })
442
499
  : said(level, text, card, extra));
443
500
  }
444
- f(guess ? 'warn' : 'info', `the frame is solved as ${fm.beams.size} beam${fm.beams.size > 1 ? 's' : ''} on ${Object.keys(fm.nodes).length} nodes, held at ${fm.supports.map((x) => `${x.where} (${x.how}, ${x.why})`).join(', ')}, under its own weight${fm.carried.length ? `, ${new Set(fm.carried.map((c) => c.id)).size} item${new Set(fm.carried.map((c) => c.id)).size > 1 ? 's' : ''} mounted on it` : ''}${fm.loads.length ? ` and ${fm.loads.length} load${fm.loads.length > 1 ? 's' : ''}` : ''}, in ${fm.cases.length} pose${fm.cases.length > 1 ? 's' : ''}; ${restsJoins}${estimates ? `, ${estimates} of them an estimate until the joint rig (issue 264) measures it, so each figure is given with the joins rigid too` : ''}${fm.riding.length ? `. ${fm.riding.map((x) => `${x.id} rides on ${x.joint}, its ${n3(x.kg, 3)} kg weighed on the frame${x.on.length > 1 ? `, shared as it lies: ${x.on.map((q) => `${n3(q.share * 100, 0)}% on ${q.beam}`).join(', ')}` : `, all of it on ${x.on[0].beam}, the beam its joint is on`}`).join('; ')}` : ''}${fm.webs.length ? `. ${fm.webs.map((w) => `${w.id} is a shear web on its bay, ${n3(w.k, 0)} N/mm along its diagonal (${w.clips} clips, their grip an estimate)`).join('; ')}` : ''}${fm.laid.length ? `. ${fm.laid.map((p) => `${p.id} lies on ${p.beams.join(', ')}, which are not joined round it as a bay: its ${n3(p.kg, 3)} kg is spread along them, and it is no shear web`).join('; ')}` : ''}${held.length ? `. Nothing holds it at ${heldList}: it can move there with nothing resisting (a frame in one plane on pinned feet sways out of that plane; a beam pinned at both ends spins on its own axis). Its loads do not move it that way, so it is held there for the sag and the stresses; its modes and buckling count it free (frame.frequency, frame.buckling), and a push that way finds it free (frame.rack). Hold it with "frame": { "supports" } fixed or resting, or join it into a box` : ''}${fm.left.length ? `. Left out: ${fm.left.join(', ')} (not held by a support through joins)` : ''}${fm.off.length ? `. Not weighed on the frame, as the beam carrying it is left out: ${fm.off.map((x) => `${x.id} (on ${x.on})`).join(', ')}` : ''}${fm.loose.length ? `. Not on a beam, so not weighed on the frame: ${fm.loose.join(', ')}` : ''}${fm.unknown.length ? `. No mass known for ${fm.unknown.join(', ')}` : ''}${guess ? `. Its supports are guessed: nothing says where it is held (no feet, no "frame": { "supports" }), and on its lowest ends pinned, as a foot stands on a floor, it would be free at ${guessFree}. So it is solved with ${guessHeld}, and every sag, rack, buckling and frequency figure rests on those ends held from turning, which nothing in the assembly gives. Give it feet, or say how it is held in "frame": { "supports" }` : ''}`, guess ? 'frame: supports guessed' : null,
445
- { code: 'frame.solve', values: { beams: fm.beams.size, nodes: Object.keys(fm.nodes).length, cases: fm.cases.length, joins: fm.joins.length, estimates }, refs: { supports: fm.supports.map((x) => x.where), ...(guess ? { guessed: guess.supports.map((x) => x.where), free: guess.free } : {}), left: fm.left, off: fm.off, held, laid: fm.laid.map((p) => ({ id: p.id, kg: r3(p.kg), beams: p.beams })), riding: fm.riding.map((x) => ({ ...x, kg: r3(x.kg) })), loose: fm.loose, rests } });
501
+ f(guessedOnly ? 'warn' : 'info', `the frame is solved as ${fm.beams.size} beam${fm.beams.size > 1 ? 's' : ''} on ${Object.keys(fm.nodes).length} nodes, held at ${fm.supports.map((x) => `${x.where} (${x.how}, ${x.why})`).join(', ')}, under its own weight${fm.carried.length ? `, ${new Set(fm.carried.map((c) => c.id)).size} item${new Set(fm.carried.map((c) => c.id)).size > 1 ? 's' : ''} mounted on it` : ''}${fm.loads.length ? ` and ${fm.loads.length} load${fm.loads.length > 1 ? 's' : ''}` : ''}${fm.onJoints.length ? `, with ${fm.onJoints.map((x) => `${n3(x.value, 3)} ${x.unit} on ${x.joint.id}${x.belt ? ` (${x.note})` : ''}`).join(', ')} carried into ${[...new Set(fm.onJoints.map((x) => x.mount.beam.id))].join(', ')} through ${fm.onJoints.length > 1 ? 'their joints, each' : 'its joint,'} one way and then the other` : ''}, in ${fm.poses.length} pose${fm.poses.length > 1 ? 's' : ''}${fm.onJoints.length ? ` (${fm.cases.length} cases)` : ''}; ${restsJoins}${estimates ? `, ${estimates} of them an estimate until the joint rig (issue 264) measures it, so each figure is given with the joins rigid too` : ''}${fm.riding.length ? `. ${fm.riding.map((x) => `${x.id} rides on ${x.joint}, its ${n3(x.kg, 3)} kg weighed on the frame${x.on.length > 1 ? `, shared as it lies: ${x.on.map((q) => `${n3(q.share * 100, 0)}% on ${q.beam}`).join(', ')}` : `, all of it on ${x.on[0].beam}, the beam its joint is on`}`).join('; ')}` : ''}${fm.webs.length ? `. ${fm.webs.map((w) => `${w.id} is a shear web on its bay, ${n3(w.k, 0)} N/mm along its diagonal (${w.clips} clips, their grip an estimate)`).join('; ')}` : ''}${fm.laid.length ? `. ${fm.laid.map((p) => `${p.id} lies on ${p.beams.join(', ')}, which are not joined round it as a bay: its ${n3(p.kg, 3)} kg is spread along them, and it is no shear web`).join('; ')}` : ''}${held.length ? `. Nothing holds it one way: ${heldSaid}, with nothing resisting. Its loads do not move it that way, so it is held there for the sag and the stresses; its modes and buckling count it free (frame.frequency, frame.buckling), and a push that way finds it free (frame.rack). Hold it with "frame": { "supports" } fixed or resting, or join it into a box` : ''}${fm.left.length ? `. Left out: ${fm.left.join(', ')} (not held by a support through joins)` : ''}${fm.off.length ? `. Not weighed on the frame, as the beam carrying it is left out: ${fm.off.map((x) => `${x.id} (on ${x.on})`).join(', ')}` : ''}${fm.loose.length ? `. Not on a beam, so not weighed on the frame: ${fm.loose.join(', ')}` : ''}${fm.unknown.length ? `. No mass known for ${fm.unknown.join(', ')}` : ''}${guess ? `. Its supports are guessed: nothing says where it is held (no feet, no "frame": { "supports" }), and on its lowest ends pinned, as a foot stands on a floor, nothing would hold it: ${guessSaid}. So it is solved with ${guessHeld}${pinnedGuess.length ? ` (${and(pinnedGuess)} pinned, a guess too)` : ''}, and every sag, rack, buckling and frequency figure rests on those ends held from turning, which nothing in the assembly gives. Give it feet, or say how it is held in "frame": { "supports" }` : guessedOnly ? `. Its supports are guessed: nothing says where it is held (no feet, no "frame": { "supports" }), so it stands on its lowest ends, ${and(pinnedGuess)}, pinned, as feet stand on a floor, and every figure rests on that. Give it feet, or say how it is held in "frame": { "supports" }` : ''}`, guessedOnly ? 'frame: supports guessed' : null,
502
+ { code: 'frame.solve', values: { beams: fm.beams.size, nodes: Object.keys(fm.nodes).length, cases: fm.cases.length, poses: fm.poses.length, joins: fm.joins.length, estimates }, refs: { supports: fm.supports.map((x) => x.where), ...(guess ? { guessed: [...guess.supports.map((x) => x.where), ...pinnedGuess], free: guess.free, how: guessHow.map((h) => h.says) } : guessedOnly ? { guessed: pinnedGuess } : {}), left: fm.left, off: fm.off, onJoints: fm.onJoints.map((x) => ({ joint: x.joint.id, value: r3(x.value), unit: x.unit, beam: x.mount.beam.id, note: x.note })), held, ...(held.length ? { how: heldHow.map((h) => h.says) } : {}), laid: fm.laid.map((p) => ({ id: p.id, kg: r3(p.kg), beams: p.beams })), riding: fm.riding.map((x) => ({ ...x, kg: r3(x.kg) })), loose: fm.loose, rests } });
446
503
 
447
504
  // ---- frame.deflection: each load's point, each named point, every guide ----
448
505
  const worst = (fn) => { let w = null; for (const r of results) { const v = fn(r.spring, r), v0 = fn(r.rigid, r); if (!w || v.sag > w.sag) w = { ...v, rigid: v0.sag, case: { ...r.case, alone: r.alone } }; } return w; };
@@ -545,13 +602,14 @@ export function frameChecks(s, f, helpers) {
545
602
  { code: 'frame.buckling', at: r4(add(low.b.A, scale(low.b.u, low.b.L / 2))), values: { compression: r3(low.N), euler: r3(low.Pcr), margin: r3(low.margin), beams: okSq.length }, refs: { beam: low.b.id } });
546
603
  }
547
604
  try {
548
- const drawn = results[0], bk = solveFrame(subdivide(fm.model, 4)).buckling({ loads: drawn.loads, count: 1 }), factor = bk.factors[0];
605
+ const drawn = results[0], fine = solveFrame(subdivide(fm.model, 4)), bk = fine.buckling({ loads: drawn.loads, count: 1 }), factor = bk.factors[0];
549
606
  const shape = bk.modes[0].shape, lead = Object.entries(shape).reduce((p, q) => (Math.hypot(...q[1].slice(0, 3)) > Math.hypot(...p[1].slice(0, 3)) ? q : p)), beam = lead[0].split(/[.@#/]/)[0];
550
607
  const listed = (ls) => [...ls.reduce((m, l) => m.set(l.node, [...(m.get(l.node) ?? []), l.freedom]), new Map())].map(([n, fr]) => `${n} (${fr.join(', ')})`).join(', ');
551
608
  if (bk.tipped) {
552
609
  // nothing holds the frame where it is free, and its loads as drawn lean it further that way: it tips over before anything buckles
553
- f('fail', `the whole frame tips over under its load as drawn before anything buckles: nothing holds it at ${listed(bk.tipped)}, and its squeezed beams lean it further that way (a frame in one plane on pinned feet leans over out of that plane), ${beam} moving most. Its buckling factor is 0. Hold it with "frame": { "supports" } fixed, brace it out of its plane, or join it into a box`, 'frame tips over',
554
- { code: 'frame.buckling', at: r4(fm.nodes[lead[0]] ?? fm.nodes[Object.keys(fm.nodes)[0]]), values: { factor: 0 }, refs: { beam, restsOn, tipped: bk.tipped } });
610
+ const how = howFree(fm, waysAt(fine, bk.tipped));
611
+ f('fail', `the whole frame tips over under its load as drawn before anything buckles: nothing holds it one way, ${how.length ? howSaid(how) : `free at ${listed(bk.tipped)}`}, and its squeezed beams lean it further that way, ${beam} moving most. Its buckling factor is 0. Hold it with "frame": { "supports" } fixed, brace it out of its plane, or join it into a box`, 'frame tips over',
612
+ { code: 'frame.buckling', at: r4(fm.nodes[lead[0]] ?? fm.nodes[Object.keys(fm.nodes)[0]]), values: { factor: 0 }, refs: { beam, restsOn, tipped: bk.tipped, how: how.map((h) => h.says) } });
555
613
  } else {
556
614
  const level = factor < 1 ? 'fail' : factor < margin ? 'warn' : 'pass', rests = bk.rests ?? [];
557
615
  f(level, `the whole frame, with the joins' springs, buckles first at ${rests.length ? 'no more than ' : ''}${n3(factor, 1)} times its load as drawn, ${beam} moving most: ${level === 'pass' ? 'far from it' : 'too near it: brace it, or a stiffer profile'} (rests on ${restsJoins})${rests.length ? `. Nothing holds it at ${listed(rests)}, where its loads pull it back as a hanging frame's do: the figure is with it held there, so the true one may be lower` : ''}`, level === 'pass' ? null : `frame buckles at ${n3(factor, 1)}×`,
@@ -559,7 +617,7 @@ export function frameChecks(s, f, helpers) {
559
617
  }
560
618
  } catch (e) { if (e.code !== 'fea.frame.compression') f('info', `the frame's own buckling factor is not found: ${e.message}`, null, { code: 'frame.buckling' }); }
561
619
  try { rackCheck(s, fm, f, { restsJoins, restsOn }); } catch (e) { f('info', `the frame's racking is not found: ${e.message}`, null, { code: 'frame.rack' }); }
562
- try { frequencyCheck(s, fm, f, { restsJoins, restsOn, heldList }); } catch (e) { f('info', `the frame's modes are not found: ${e.message}`, null, { code: 'frame.frequency' }); }
620
+ try { frequencyCheck(s, fm, f, { restsJoins, restsOn, heldSaid }); } catch (e) { f('info', `the frame's modes are not found: ${e.message}`, null, { code: 'frame.frequency' }); }
563
621
  const ctx = { results, limitFor, sagAt, sagAlong, excitesOf, restsJoins, restsOn, margin };
564
622
  try { couponChecks(s, fm, f, ctx); } catch (e) { f('info', `the beam coupon's figures are not predicted: ${e.message}`, null, { code: 'beam.coupon' }); }
565
623
  if (s.a.frame?.printed != null) try { printableCheck(s, fm, f, ctx); } catch (e) { f('info', `which beams can be printed is not found: ${e.message}`, null, { code: 'beam.printable' }); }
@@ -567,7 +625,7 @@ export function frameChecks(s, f, helpers) {
567
625
  }
568
626
 
569
627
  // the two directions across "down" a frame is racked in, each named by the world axis it is nearest
570
- function sideways(down) {
628
+ export function sideways(down) {
571
629
  const flat = (v) => sub(v, scale(down, dot(v, down))), x = flat([1, 0, 0]), e1 = Math.hypot(...x) > 0.5 ? unitv(x) : unitv(flat([0, 1, 0])), e2 = unitv(cross(down, e1));
572
630
  const name = (v) => { const k = [0, 1, 2].reduce((p, q) => (Math.abs(v[q]) > Math.abs(v[p]) ? q : p), 0); return `along ${'xyz'[k]}`; };
573
631
  return [e1, e2].map((v) => ({ dir: v, name: name(v) }));
@@ -582,14 +640,30 @@ const RACK_PANEL = { sheet: 'acrylic', thickness: 3 };
582
640
  * best bay that way alone and in every open bay that way, each solved, with its gain; the cheapest that brings the sway
583
641
  * under the limit advised.
584
642
  */
585
- function rackCheck(s, fm, f, { restsJoins, restsOn }) {
643
+ /**
644
+ * How a frame is racked: the side push (frame.rack.load, else frame.push), the nodes at its top it is shared among (its
645
+ * bays' top corners, else its highest nodes), its height above its supports, and the sway allowed (frame.rack.limit,
646
+ * the task's accuracy, else its height over frame.sway). Null where it has no height to rack. frame.rack and the
647
+ * sizing's racking limit both read it. @param {object} s a built assembly @param {object} fm frameModelOf's
648
+ * @returns {{ F: number, loadFrom: string, top: string[], H: number, lim: { value: number, from: string } } | null}
649
+ */
650
+ export function rackOf(s, fm) {
586
651
  const opts = s.a.frame?.rack ?? {}, F = opts.load != null ? s.num(opts.load) : FRAME_CHECK.push.value, down = fm.down, height = (n) => -dot(fm.nodes[n], down);
587
652
  const feet = fm.supports.map((sp) => fm.nodeAt(sp.beam, sp.z)).filter(Boolean);
588
653
  const pool = fm.bays.length ? [...new Set(fm.bays.flatMap((b) => b.corners))] : Object.keys(fm.nodes), topH = Math.max(...pool.map(height)), top = pool.filter((n) => height(n) > topH - 1);
589
654
  const H = topH - Math.min(...feet.map(height));
590
- if (!(H > 1) || !top.length) return;
655
+ if (!(H > 1) || !top.length) return null;
591
656
  const lim = opts.limit != null ? { value: s.num(opts.limit), from: 'the assembly\'s frame.rack.limit' } : s.task?.accuracy != null ? { value: s.task.accuracy, from: 'the task\'s accuracy' } : { value: H / FRAME_CHECK.sway.value, from: `its height, ${n3(H, 1)} mm, over ${FRAME_CHECK.sway.value} (frame.sway)` };
592
- const loadFrom = opts.load != null ? 'frame.rack.load' : `frame.push, an estimate`;
657
+ return { F, loadFrom: opts.load != null ? 'frame.rack.load' : `frame.push, an estimate`, top, H, lim };
658
+ }
659
+
660
+ /** How a frame moves where nothing holds it, in words (see howFree): for the sizing's racking limit. @param {object} fm @param {object[]} ways frame().mechanisms */
661
+ export const freeSaid = (fm, ways) => howSaid(howFree(fm, ways));
662
+
663
+ function rackCheck(s, fm, f, { restsJoins, restsOn }) {
664
+ const rk = rackOf(s, fm);
665
+ if (!rk) return;
666
+ const { F, top, H, lim, loadFrom } = rk, down = fm.down;
593
667
  const swayOf = (model, dir) => { const r = solveFrame(model).statics({ loads: top.map((n) => ({ node: n, force: scale(dir, F / top.length) })), gravity: [0, 0, 0] }); return top.reduce((t, n) => t + dot(r.displacements[n].slice(0, 3), dir), 0) / top.length; };
594
668
  const base = fm.model, els = base.elements;
595
669
  // the changes, each as the model's elements with it made
@@ -615,9 +689,9 @@ function rackCheck(s, fm, f, { restsJoins, restsOn }) {
615
689
  try { sway = swayOf(base, dir); rigid = swayOf(fm.rigid, dir); } catch (e) {
616
690
  if (e.code !== 'fea.frame.mechanism' || !e.driven) throw e;
617
691
  // a frame free to move this way (one plane on pinned feet, pushed across it): the push finds nothing to hold it
618
- const at = e.loose.map((l) => `${l.node} (${l.freedom})`).join(', ');
619
- f('warn', `racked ${name}: nothing holds the frame that way, so ${n3(F, 1)} N pushed at the top (${loadFrom}) moves it with nothing resisting, free at ${at}. Fix its feet ("frame": { "supports" } fixed), or join beams across it to make a bay that way and brace it`, `racks ${name}: nothing holds it`,
620
- { code: 'frame.rack', at: r4(fm.nodes[top[0]]), values: { load: r3(F), limit: r3(lim.value), height: r3(H) }, refs: { direction: name, dir: r4(dir), top, free: e.loose, limit: lim.from, load: loadFrom, restsOn, advise: null } });
692
+ const at = e.loose.map((l) => `${l.node} (${l.freedom})`).join(', '), how = howFree(fm, waysAt(solveFrame(base), e.loose));
693
+ f('warn', `racked ${name}: nothing holds the frame that way, ${how.length ? howSaid(how) : `free at ${at}`}, so ${n3(F, 1)} N pushed at the top (${loadFrom}) moves it with nothing resisting. Fix its feet ("frame": { "supports" } fixed), or join beams across it to make a bay that way and brace it`, `racks ${name}: nothing holds it`,
694
+ { code: 'frame.rack', at: r4(fm.nodes[top[0]]), values: { load: r3(F), limit: r3(lim.value), height: r3(H) }, refs: { direction: name, dir: r4(dir), top, free: e.loose, how: how.map((h) => h.says), limit: lim.from, load: loadFrom, restsOn, advise: null } });
621
695
  continue;
622
696
  }
623
697
  const k = F / sway, k0 = F / rigid;
@@ -662,10 +736,10 @@ export function excitesOf(s) {
662
736
  * speed (a mode near it rings while the motor runs at that speed), and the task's moves (a move ramping in t seconds
663
737
  * shakes the frame at about 1/t, and the lowest mode should stand twice that clear).
664
738
  */
665
- function frequencyCheck(s, fm, f, { restsJoins, restsOn, heldList }) {
739
+ function frequencyCheck(s, fm, f, { restsJoins, restsOn, heldSaid }) {
666
740
  const solveIn = (model, values, count) => solveFrame(subdivide({ ...model, masses: fm.nodeMasses(values) }, 4)).modes({ count });
667
741
  let worst = null;
668
- for (const c of fm.cases) { const r = solveIn(fm.model, c.values, 3); if (!worst || r.frequencies[0] < worst.r.frequencies[0]) worst = { c, r }; }
742
+ for (const c of fm.poses) { const r = solveIn(fm.model, c.values, 3); if (!worst || r.frequencies[0] < worst.r.frequencies[0]) worst = { c, r }; }
669
743
  const hz = worst.r.frequencies, low = hz[0], rigid = solveIn(fm.rigid, worst.c.values, 1).frequencies[0];
670
744
  const shape = worst.r.modes[0].shape, lead = Object.entries(shape).reduce((p, q) => (Math.hypot(...q[1].slice(0, 3)) > Math.hypot(...p[1].slice(0, 3)) ? q : p)), beam = lead[0].split(/[.@#/]/)[0];
671
745
  const carried = Object.values(fm.nodeMasses(worst.c.values)).reduce((t, x) => t + x, 0), own = [...fm.beams.values()].reduce((t, b) => t + b.grams / 1000, 0);
@@ -678,7 +752,7 @@ function frequencyCheck(s, fm, f, { restsJoins, restsOn, heldList }) {
678
752
  const level0 = !excites.length ? 'info' : (moves.length && low < need / margin) ? 'fail' : (low < need || near.length) ? 'warn' : 'pass', level = free && (level0 === 'info' || level0 === 'pass') ? 'warn' : level0;
679
753
  const target = Math.max(need, ...near.map((x) => x.Hz * (1 + band)));
680
754
  const advice = free ? `. Hold it there with "frame": { "supports" } fixed, brace it, or join it into a box: then it has a mode to lift` : level === 'warn' || level === 'fail' ? `. To lift it to ${n3(target, 1)} Hz takes about ${n3((target / low) ** 2, 2)} times the stiffness where ${beam} moves (a deeper profile, a shorter span, stiffer joins or a brace), or as many times less mass moving with it` : '';
681
- const text = `the lowest mode is ${n3(low, 1)} Hz${free ? `: nothing holds the frame${heldList ? ` at ${heldList}` : ''}, so it moves that way with nothing resisting${free > 1 ? ` (${free} such modes)` : ''}` : ''}${fm.cases.length > 1 ? `, worst ${worst.c.label}` : ''}, ${beam} moving most${fm.joins.length ? `, with the joins' springs; ${n3(rigid, 1)} Hz with the joins rigid` : ''}. Its next: ${hz.slice(1).map((h) => `${n3(h, 1)} Hz`).join(', ')}. With ${n3(own, 3)} kg of beams and ${n3(carried, 3)} kg carried, each item's mass at the node it is carried at (its rotary inertia left out); it rests on ${restsJoins}. ${excites.length
755
+ const text = `the lowest mode is ${n3(low, 1)} Hz${free ? `: nothing holds the frame one way${heldSaid ? `, ${heldSaid}` : ''}, so it moves that way with nothing resisting${free > 1 ? ` (${free} such modes)` : ''}` : ''}${fm.poses.length > 1 ? `, worst ${worst.c.label}` : ''}, ${beam} moving most${fm.joins.length ? `, with the joins' springs; ${n3(rigid, 1)} Hz with the joins rigid` : ''}. Its next: ${hz.slice(1).map((h) => `${n3(h, 1)} Hz`).join(', ')}. With ${n3(own, 3)} kg of beams and ${n3(carried, 3)} kg carried, each item's mass at the node it is carried at (its rotary inertia left out); it rests on ${restsJoins}. ${excites.length
682
756
  ? `The machine excites: ${excites.map((x) => `${x.what}, ${n3(x.Hz, 1)} Hz`).join('; ')}. ${near.length ? `A mode within ${band * 100}% of ${near.map((x) => `${x.what} (the mode${x.modes.length > 1 ? 's' : ''} at ${x.modes.join(' and ')} Hz)`).join(', ')}: it rings while the motor runs at that speed` : ''}${near.length && moves.length ? '; ' : ''}${moves.length ? (low < need ? `under ${margin} times the moves' ${n3(need / margin, 1)} Hz` : `${n3(low / (need / margin), 1)} times over the moves' ${n3(need / margin, 1)} Hz, where ${margin} is wanted`) : ''}`
683
757
  : 'Nothing named excites it: no stepper drives a joint and the assembly has no task'}${advice}`;
684
758
  f(level, text.replace(/\. $/, ''), level === 'warn' || level === 'fail' ? `frame mode ${n3(low, 1)} Hz` : null, { code: 'frame.frequency', at: r4(fm.nodes[lead[0]] ?? fm.nodes[Object.keys(fm.nodes)[0]]),
@@ -698,13 +772,13 @@ export function frameMode(s, helpers) {
698
772
  if (!fm || fm.empty) return null;
699
773
  try {
700
774
  let worst = null;
701
- for (const c of fm.cases) { const m = subdivide({ ...fm.model, masses: fm.nodeMasses(c.values) }, 4), r = solveFrame(m).modes({ count: 1 }); if (!worst || r.frequencies[0] < worst.r.frequencies[0]) worst = { c, r, m }; }
775
+ for (const c of fm.poses) { const m = subdivide({ ...fm.model, masses: fm.nodeMasses(c.values) }, 4), r = solveFrame(m).modes({ count: 1 }); if (!worst || r.frequencies[0] < worst.r.frequencies[0]) worst = { c, r, m }; }
702
776
  const shape = worst.r.modes[0].shape, pts = Object.values(worst.m.nodes), size = Math.max(...[0, 1, 2].map((k) => Math.max(...pts.map((p) => p[k])) - Math.min(...pts.map((p) => p[k])))), k = size / 10;
703
777
  const move = (n) => scale((shape[n] ?? [0, 0, 0]).slice(0, 3), k);
704
778
  const lines = worst.m.elements.map((e) => ({ id: String(e.id), a: worst.m.nodes[e.a], b: worst.m.nodes[e.b], da: move(e.a), db: move(e.b) }));
705
779
  const lead = Object.entries(shape).reduce((p, q) => (Math.hypot(...q[1].slice(0, 3)) > Math.hypot(...p[1].slice(0, 3)) ? q : p)), beam = lead[0].split(/[.@#/]/)[0];
706
780
  const Hz = worst.r.frequencies[0];
707
- return { Hz, pose: worst.c.label, beam, lines, scale: k, label: `lowest mode ${n3(Hz, 1)} Hz${fm.cases.length > 1 ? `, ${worst.c.label}` : ''}, ${beam} moving most; its movement drawn as a tenth of the frame's size (scaled)` };
781
+ return { Hz, pose: worst.c.label, beam, lines, scale: k, label: `lowest mode ${n3(Hz, 1)} Hz${fm.poses.length > 1 ? `, ${worst.c.label}` : ''}, ${beam} moving most; its movement drawn as a tenth of the frame's size (scaled)` };
708
782
  } catch { return null; }
709
783
  }
710
784
 
@@ -758,11 +832,11 @@ function solveAll(fm) {
758
832
  try { results = solveCases(fm, fs, fr); } catch (e) { if (e.code !== 'fea.frame.mechanism') throw e; return { error: e.message, code: e.code }; }
759
833
  // each element's start along its beam, for sagAlong
760
834
  for (const r of results) for (const res of [r.spring, r.rigid]) for (const e of res.elements) if (e.of != null) { const b = fm.beams.get(e.of), el = fm.model.elements.find((q) => q.id === e.id); e._from = dot(sub(fm.nodes[el.a], b.A), b.u); }
761
- return { results, loose: fs.loose };
835
+ return { results, loose: fs.loose, mechanisms: fs.mechanisms };
762
836
  }
763
837
  function solveCases(fm, fs, fr) {
764
838
  const results = fm.cases.map((c) => {
765
- const loads = fm.nodeLoads(c.values), spring = fs.statics({ loads }), rigid = fr.statics({ loads }), out = { case: c, loads, spring, rigid, values: c.values };
839
+ const loads = fm.nodeLoads(c.values, null, c.push), spring = fs.statics({ loads }), rigid = fr.statics({ loads }), out = { case: c, loads, spring, rigid, values: c.values };
766
840
  { out.alone = new Map(); for (const l of fm.loads) { const ll = fm.nodeLoads(c.values, l), n = ll[0]?.node; if (!n) continue; out.alone.set(l, { sag: sagAt(fs.statics({ loads: ll, gravity: [0, 0, 0] }), n, fm.down), rigid: sagAt(fr.statics({ loads: ll, gravity: [0, 0, 0] }), n, fm.down) }); } }
767
841
  return out;
768
842
  });
@@ -94,7 +94,7 @@ const alongOf = (b, ctx) => ({ what: `${b.id} along its length`, beam: b, from:
94
94
  function drawnSags(fm, ctx, targets) {
95
95
  const solver = solveFrame(fm.model), out = new Map(), all = [...targets, ...[...fm.beams.values()].map((b) => alongOf(b, ctx))];
96
96
  for (const cs of fm.cases) {
97
- const res = stamp(fm, fm.model, solver.statics({ loads: fm.nodeLoads(cs.values) }));
97
+ const res = stamp(fm, fm.model, solver.statics({ loads: fm.nodeLoads(cs.values, null, cs.push) }));
98
98
  for (const t of all) out.set(`${t.what}|${cs.label}`, t.node ? ctx.sagAt(res, t.node(cs.values), fm.down) : ctx.sagAlong(res, t.beam, t.from, t.to, fm.down).sag);
99
99
  }
100
100
  const missed = [];
@@ -115,7 +115,7 @@ function evaluate(s, fm, ctx, cands, targets, drawn) {
115
115
  let def = null, creepSag = null;
116
116
  const per = new Map(cands.map((c) => [c.b.id, { stress: 0, compression: 0, case: null }]));
117
117
  for (const cs of fm.cases) {
118
- const loads = fm.nodeLoads(cs.values), res = stamp(fm, model, solver.statics({ loads })), cr = stamp(fm, creep, creeper.statics({ loads }));
118
+ const loads = fm.nodeLoads(cs.values, null, cs.push), res = stamp(fm, model, solver.statics({ loads })), cr = stamp(fm, creep, creeper.statics({ loads }));
119
119
  for (const t of all) {
120
120
  // where the frame as drawn already misses this sag, the printed beam is held to the drawn frame's own figure
121
121
  const base = drawn.get(`${t.what}|${cs.label}`) ?? 0, missed = base > t.limit.value + 1e-12, lim = missed ? base * (1 + DRAWN_SLACK) : t.limit.value;
@@ -129,7 +129,7 @@ function evaluate(s, fm, ctx, cands, targets, drawn) {
129
129
  const moves = ctx.excitesOf(s).filter((x) => x.kind === 'move');
130
130
  if (moves.length) {
131
131
  const need = Math.max(...moves.map((x) => x.Hz)) * margin;
132
- for (const cs of fm.cases) { const low = solveFrame(subdivide({ ...model, masses: fm.nodeMasses(cs.values) }, 4)).modes({ count: 1 }).frequencies[0]; if (!freq || low < freq.low) freq = { low, need, margin: low / need, case: cs.label }; }
132
+ for (const cs of fm.poses) { const low = solveFrame(subdivide({ ...model, masses: fm.nodeMasses(cs.values) }, 4)).modes({ count: 1 }).frequencies[0]; if (!freq || low < freq.low) freq = { low, need, margin: low / need, case: cs.label }; }
133
133
  }
134
134
  const out = new Map();
135
135
  for (const c of cands) {
package/lib/framesize.mjs CHANGED
@@ -8,9 +8,10 @@
8
8
  // change. The result is a table: each group's profile, the limit that set it (the one its next lighter profile breaks)
9
9
  // and the margin, written into the assembly by cad frame --size --write.
10
10
  // Units: mm, N, MPa, kg, Hz.
11
- import { sizing } from '@rulecad/fea/frame';
12
- import { profileModel, profileChoices } from '@rulecad/frames';
13
- import { frameModelOf, FRAME_CHECK, excitesOf } from './framecheck.mjs';
11
+ import { sizing, frame as solveFrame } from '@rulecad/fea/frame';
12
+ import { profileModel, profileChoices, beamModel, boughtFittingModel, JOINS } from '@rulecad/frames';
13
+ import { fixingModel } from '@rulecad/fixings';
14
+ import { frameModelOf, FRAME_CHECK, excitesOf, rackOf, sideways, freeSaid } from './framecheck.mjs';
14
15
  import { framesContext } from './beams.mjs';
15
16
  import { givenFor } from './frames.mjs';
16
17
 
@@ -24,7 +25,7 @@ export const FRAME_SIZING = {
24
25
  };
25
26
 
26
27
  const SIZE_KEYS = ['profiles', 'groups', 'limits', 'by'];
27
- const LIMIT_KEYS = ['deflection', 'stress', 'buckling', 'frequency'];
28
+ const LIMIT_KEYS = ['deflection', 'stress', 'buckling', 'frequency', 'rack'];
28
29
 
29
30
  /**
30
31
  * frame.size read and refused by name: { profiles, groups, limits, by }.
@@ -41,8 +42,8 @@ export function sizeOption(s) {
41
42
  if (typeof groups !== 'object' || Array.isArray(groups)) throw new Error(`frame.size.groups is { "legs": ["z1", "z2", "z3", "z4"] }: beams that must take one profile, by name (got ${shown(o.groups)})`);
42
43
  for (const [g, list] of Object.entries(groups)) if (!Array.isArray(list) || !list.length || !list.every((x) => typeof x === 'string')) throw new Error(`frame.size.groups.${g} is a list of beams by name (got ${shown(list)})`);
43
44
  const limits = o.limits ?? {};
44
- if (typeof limits !== 'object' || Array.isArray(limits)) throw new Error(`frame.size.limits is { "deflection": mm, "stress": margin, "buckling": factor, "frequency": Hz } (got ${shown(o.limits)})`);
45
- for (const k of Object.keys(limits)) if (!LIMIT_KEYS.includes(k)) throw new Error(`frame.size.limits has no "${k}": it takes deflection (mm), stress (a margin), buckling (a factor) and frequency (Hz)`);
45
+ if (typeof limits !== 'object' || Array.isArray(limits)) throw new Error(`frame.size.limits is { "deflection": mm, "stress": margin, "buckling": factor, "frequency": Hz, "rack": mm } (got ${shown(o.limits)})`);
46
+ for (const k of Object.keys(limits)) if (!LIMIT_KEYS.includes(k)) throw new Error(`frame.size.limits has no "${k}": it takes deflection (mm), stress (a margin), buckling (a factor), frequency (Hz) and rack (the sway allowed at the top, mm)`);
46
47
  const out = {};
47
48
  for (const [k, v] of Object.entries(limits)) { const x = s.num(v); if (!(x > 0)) throw new Error(`frame.size.limits.${k} is above 0 (got ${shown(v)})`); out[k] = x; }
48
49
  if (o.by != null && !['mass', 'cost'].includes(o.by)) throw new Error(`frame.size.by is mass or cost (got ${shown(o.by)})`);
@@ -50,6 +51,56 @@ export function sizeOption(s) {
50
51
  return { profiles, groups, limits: out, by: o.by ?? 'mass' };
51
52
  }
52
53
 
54
+ // The world direction a beam's face looks, from its section's normal: x across its width, y up its height, turned by roll
55
+ const faceAxes = (b, roll) => { const X = [b.W[0], b.W[4], b.W[8]], Y = [b.W[1], b.W[5], b.W[9]], c = Math.cos((roll * Math.PI) / 180), sn = Math.sin((roll * Math.PI) / 180); return { X: X.map((v, k) => c * v + sn * Y[k]), Y: Y.map((v, k) => c * v - sn * X[k]) }; };
56
+ const looks = (ax, n) => ax.X.map((v, k) => v * n[0] + ax.Y[k] * n[1]);
57
+
58
+ /**
59
+ * Whether a join still goes together when its beams take other profiles: a's end on b's face where the drawn join
60
+ * meets it (the face of b's new profile that looks the same way in the world). A blind join needs a bore in a's end and
61
+ * a slot in b's face whose opening passes the screw (the bore's thread) and holds its button head under the lips, the
62
+ * head no wider than the slot's cavity; an end-tap join a bore in a's end and, where b's far face has a slot, a cap
63
+ * head wider than its opening. A bought fitting must fit both profiles (its set's fitting.fit). A printed fitting is
64
+ * drawn for the profiles it joins, so it goes with any; a join whose fitting comes later is not held to one. Null where
65
+ * it fits, else why not. @param {object} x a frame join (frameModelOf's joins) @param {{ model: object, roll: number }} pa a's profile as sized
66
+ * @param {{ model: object, roll: number }} pb b's @param {object} given the workspace's sets
67
+ * @returns {string | null}
68
+ */
69
+ export function joinFit(x, pa, pb, given) {
70
+ const kind = x.j.kind, A = pa.model, Bm = pb.model, name = (m) => m.name.replace(/^profile-/, '');
71
+ if (x.j.fitting && x.j.fitting !== 'printed' && JOINS[kind]?.bought) {
72
+ let fm;
73
+ try { fm = boughtFittingModel(x.j.fitting, { given, profile: Bm, other: A, join: kind }); } catch (e) { return String(e.message).replace(/^\w+: /, ''); }
74
+ const bad = fm.findings.find((f) => f.code === 'fitting.fit' && f.level === 'fail');
75
+ return bad ? `${x.j.fitting} does not fit ${name(A)} to ${name(Bm)}: ${bad.text}` : null;
76
+ }
77
+ if (!['blind', 'end-tap'].includes(kind)) return null;
78
+ const e = String(x.j.end ?? 'a')[0], bores = A.bores ?? [];
79
+ if (!bores.length) return `${name(A)} has no bore in its ends to tap, and a ${kind} join screws into one`;
80
+ // b's face where the join meets it, in the world, and the place of the new profile that looks that way
81
+ const drawn = x.B.m.places.find((q) => q.name === x.j.model.b.place);
82
+ if (!drawn) return null;
83
+ const n = looks(faceAxes(x.B, 0), drawn.normal), B = beamModel(Bm, { length: x.B.L }), ax = faceAxes(x.B, pb.roll);
84
+ const place = B.places.filter((q) => { const w = looks(ax, q.normal); return w[0] * n[0] + w[1] * n[1] + w[2] * n[2] > 0.99; })[0];
85
+ const thread = bores[0].thread;
86
+ if (!thread) return `${name(A)}'s bores name no thread`;
87
+ const head = (form) => { try { return fixingModel(`${thread} ${form}`); } catch { return null; } };
88
+ if (kind === 'blind') {
89
+ if (!place?.slot) return `${name(Bm)}'s face there is closed, and a blind join's head sits in a slot`;
90
+ const sl = Bm.slots[place.slot], fx = head('button');
91
+ if (!sl || !fx) return null;
92
+ if (fx.major > sl.opening) return `${a(thread)} ${thread} screw (${name(A)}'s bore) does not pass ${name(Bm)}'s ${sl.opening} mm slot opening`;
93
+ if (fx.head.across <= sl.opening) return `${a(thread)} ${thread} button head, ${fx.head.across} mm across, pulls through ${name(Bm)}'s ${sl.opening} mm slot opening`;
94
+ if (fx.head.across > sl.cavityWidth) return `${a(thread)} ${thread} button head, ${fx.head.across} mm across, does not go into ${name(Bm)}'s slot, ${sl.cavityWidth} mm wide under its lips`;
95
+ return null;
96
+ }
97
+ // end-tap: the screw through b, its cap head on b's far face
98
+ const far = place ? B.places.find((q) => Math.abs(q.normal[0] + place.normal[0]) < 1e-9 && Math.abs(q.normal[1] + place.normal[1]) < 1e-9) : null, fx = head('cap');
99
+ if (far?.slot && fx && Bm.slots[far.slot] && fx.head.across <= Bm.slots[far.slot].opening) return `${a(thread)} ${thread} cap head, ${fx.head.across} mm across, falls through ${name(Bm)}'s ${Bm.slots[far.slot].opening} mm slot opening on its far face`;
100
+ return null;
101
+ }
102
+ const a = () => 'an'; // (a metric thread's name is said em: an M5, an M3)
103
+
53
104
  /**
54
105
  * The frame's sizing: frameModelOf's frame, its beams grouped, each group given the lightest profile from the list that
55
106
  * meets the frame's limits. Null where the assembly has no frame to solve. Refused by name: frame.size as sizeOption
@@ -80,7 +131,7 @@ export function frameSizing(s, helpers, given) {
80
131
  }
81
132
  for (const x of auto) groups[x.ids.join(', ')] = x.ids;
82
133
  // the choices, from the workspace's sets before the kit's
83
- const context = framesContext(), choices = [];
134
+ const context = framesContext(), choices = [], models = new Map(), modelOf = (name) => { if (!models.has(name)) models.set(name, profileModel(name, {}, givenFor(context, name))); return models.get(name); };
84
135
  for (const name of opt.profiles) {
85
136
  let m;
86
137
  try { m = profileModel(name, {}, givenFor(context, name)); } catch (e) { throw new Error(`frame.size.profiles: ${String(e.message).replace(/^profileModel: /, '')}`); }
@@ -108,17 +159,55 @@ export function frameSizing(s, helpers, given) {
108
159
  limitRows.push({ limit: 'buckling', where: 'the frame and each grouped beam (Euler, K 1)', value: factor, from: opt.limits.buckling != null ? 'frame.size.limits.buckling' : 'frame.margin' });
109
160
  const moves = excitesOf(s).filter((x) => x.kind === 'move'), Hz = opt.limits.frequency ?? (moves.length ? Math.max(...moves.map((x) => x.Hz)) * margin : null);
110
161
  if (Hz != null) limitRows.push({ limit: 'frequency', where: 'the frame', value: Hz, from: opt.limits.frequency != null ? 'frame.size.limits.frequency' : `twice the task's moves (frame.frequency)` });
162
+ // racking, where the assembly asks it of the frame (frame.rack) or of its sizing (limits.rack): each way across, the
163
+ // side push alone at the top, with no weight, held to the sway allowed at each top node; a way nothing holds the
164
+ // frame (one plane on pinned feet) cannot be sized against, and is said
165
+ const rackCases = [];
166
+ const rk = s.a.frame?.rack != null || opt.limits.rack != null ? rackOf(s, fm) : null;
167
+ if (rk) {
168
+ const lim = opt.limits.rack != null ? { value: opt.limits.rack, from: 'frame.size.limits.rack' } : rk.lim, drawnFrame = solveFrame(fm.model);
169
+ for (const { dir, name } of sideways(fm.down)) {
170
+ const label = `racked ${name}`, loads = rk.top.map((n) => ({ node: n, force: dir.map((v) => (v * rk.F) / rk.top.length) }));
171
+ try { drawnFrame.statics({ loads, gravity: [0, 0, 0] }); } catch (e) {
172
+ if (e.code !== 'fea.frame.mechanism' || !e.driven) throw e;
173
+ limitRows.push({ limit: 'rack', where: name, what: `not sized: nothing holds the frame ${name}, ${freeSaid(fm, (drawnFrame.mechanisms ?? []).filter((m) => e.loose.some((l) => l.node === m.node && l.freedom === m.freedom)))}; a brace or fixed feet, not a profile, holds it`, value: null, from: rk.loadFrom });
174
+ continue;
175
+ }
176
+ rackCases.push({ label, loads, gravity: [0, 0, 0], limits: ['deflection'] });
177
+ for (const n of rk.top) deflection.push({ node: n, limit: lim.value, along: dir, cases: [label] });
178
+ limitRows.push({ limit: 'deflection', where: rk.top.join(', '), what: `the top, ${label} by ${n3(rk.F, 1)} N (${rk.loadFrom})`, value: lim.value, from: lim.from });
179
+ }
180
+ // the sag limits hold in the poses, not under the push
181
+ if (rackCases.length) for (const d of deflection) if (!d.cases) d.cases = fm.cases.map((c) => c.label);
182
+ }
111
183
  const limits = { ...(deflection.length ? { deflection } : {}), stress: { margin: stress }, buckling: { factor, euler: FRAME_CHECK.euler.value }, ...(Hz != null ? { frequency: { Hz } } : {}) };
112
184
  // every beam's alloy carries its strength, so the beams outside the groups are held to it too
113
185
  const withStrength = (model) => ({ ...model, materials: Object.fromEntries(Object.entries(model.materials).map(([k, v]) => [k, fm.beams.get(k)?.strength ? { ...v, strength: fm.beams.get(k).strength } : v])) });
114
- const cases = fm.cases.map((c) => ({ label: c.label, loads: fm.nodeLoads(c.values), inertia: fm.nodeMasses(c.values) }));
115
- const sized = sizing([withStrength(fm.model), withStrength(fm.rigid)], { groups, choices, limits, cases, by: opt.by });
186
+ const cases = [...fm.cases.map((c) => ({ label: c.label, loads: fm.nodeLoads(c.values, null, c.push), inertia: fm.nodeMasses(c.values) })), ...rackCases];
116
187
  const byName = new Map(choices.map((c) => [c.name, c]));
188
+ // every join a group's beam makes must go together with the profiles chosen (joinFit): a design where one does not is
189
+ // never solved, and a lighter choice that breaks one is what set the group. A join as drawn is not asked again
190
+ const groupOf = new Map(Object.entries(groups).flatMap(([g, ids]) => ids.map((id) => [id, g]))), sets = { sets: context?.sets ?? {} }, fitMemo = new Map();
191
+ const asSized = (b, design) => { const g = groupOf.get(b.id), c = g ? byName.get(design[g]) : null; return c ? { name: c.profile, roll: c.roll ?? 0 } : { name: b.m.profile.name, roll: 0, drawn: true }; };
192
+ const pairs = fm.joins.filter((x) => fm.beams.has(x.A.id) && fm.beams.has(x.B.id) && (groupOf.has(x.A.id) || groupOf.has(x.B.id)));
193
+ const fits = (design) => {
194
+ const out = [];
195
+ for (const x of pairs) {
196
+ const pa = asSized(x.A, design), pb = asSized(x.B, design);
197
+ if (pa.drawn && pb.drawn) continue;
198
+ const key = `${x.j.index}|${pa.name}|${pa.roll}|${pb.name}|${pb.roll}`;
199
+ if (!fitMemo.has(key)) fitMemo.set(key, joinFit(x, { model: modelOf(pa.name), roll: pa.roll }, { model: modelOf(pb.name), roll: pb.roll }, sets));
200
+ const why = fitMemo.get(key);
201
+ if (why) out.push({ where: x.j.label, why });
202
+ }
203
+ return out;
204
+ };
205
+ const sized = sizing([withStrength(fm.model), withStrength(fm.rigid)], { groups, choices, limits, cases, by: opt.by, ...(pairs.length ? { fits } : {}) });
117
206
  const rows = sized.groups.map((g) => {
118
207
  const c = byName.get(g.choice), drawn = [...new Set(g.members.map((id) => fm.beams.get(id).m.profile.name.replace(/^profile-/, '')))];
119
208
  const drawnKg = g.members.reduce((t, id) => t + fm.beams.get(id).grams / 1000, 0);
120
209
  return { group: g.name, beams: g.members, profile: c.profile, roll: c.roll, choice: g.choice, drawn, length: r3(g.length), kg: r3(g.mass), drawnKg: r3(drawnKg), lighter: g.lighter,
121
- governs: g.governs ? { limit: g.governs.limit, where: g.governs.where, value: r3(g.governs.value), allowed: r3(g.governs.allowed), case: g.governs.case, lighter: g.governs.lighter, broken: r3(g.governs.broken) } : null, margin: g.margin == null ? null : r3(g.margin) };
210
+ governs: g.governs ? (g.governs.limit === 'fit' ? { limit: 'fit', where: g.governs.where, why: g.governs.why, lighter: g.governs.lighter, broken: null } : { limit: g.governs.limit, where: g.governs.where, value: r3(g.governs.value), allowed: r3(g.governs.allowed), case: g.governs.case, lighter: g.governs.lighter, broken: r3(g.governs.broken) }) : null, margin: g.margin == null ? null : r3(g.margin) };
122
211
  });
123
212
  const drawn = [...fm.beams.values()].filter((b) => sized.groups.some((g) => g.members.includes(b.id))).reduce((t, b) => t + b.grams / 1000, 0);
124
213
  return { ok: sized.ok, rows, limits: limitRows, total: r3(sized.total), drawn: r3(drawn), tried: sized.tried, search: sized.search, worst: sized.worst, sized, fm };
@@ -128,6 +217,8 @@ export function frameSizing(s, helpers, given) {
128
217
  const unitOf = { deflection: 'mm', stress: 'MPa', buckling: 'x', frequency: 'Hz' };
129
218
  const sayLimit = (g) => {
130
219
  if (!g) return 'the lightest in the list';
220
+ if (g.limit === 'fit') return `a join: with ${g.lighter}, ${g.where} does not go together (${g.why})`;
221
+ if (g.limit === 'deflection' && /^racked /.test(g.case ?? '')) return `racking: with ${g.lighter}, the sway at ${g.where} ${g.case.replace(/^racked /, '')} breaks its limit ${n3(g.broken, 2)} times over`;
131
222
  const u = unitOf[g.limit], what = g.limit === 'deflection' ? `the sag at ${g.where}` : g.limit === 'stress' ? `the stress in ${g.where}` : g.limit === 'buckling' ? (g.where === 'frame' ? 'the frame\'s buckling factor' : `${g.where.replace(' (Euler)', '')}'s Euler margin`) : 'the lowest mode';
132
223
  return `${g.limit}: with ${g.lighter}, ${what} breaks its limit ${n3(g.broken, 2)} times over`;
133
224
  };
@@ -139,7 +230,7 @@ export function sizingText(r) {
139
230
  const lines = [`${r.ok ? 'sized' : 'no profile in the list meets every limit; nearest'}: ${n3(r.total, 3)} kg of grouped beams (drawn ${n3(r.drawn, 3)} kg), ${r.tried} designs solved (${r.search === 'every' ? 'every design ranked by mass' : 'by steps'})`];
140
231
  lines.push('group | profile | kg | set by | margin');
141
232
  for (const x of r.rows) lines.push(`${x.group} | ${x.choice}${x.drawn.length === 1 && x.drawn[0] === x.choice ? '' : ` (drawn ${x.drawn.join(', ')})`} | ${n3(x.kg, 3)} | ${sayLimit(x.governs)} | ${x.margin == null ? '-' : `${n3(x.margin, 2)}x`}`);
142
- lines.push(`limits: ${r.limits.map((l) => `${l.limit} ${l.limit === 'deflection' ? `${n3(l.value, 3)} mm at ${l.what ?? l.where}` : l.limit === 'frequency' ? `${n3(l.value, 1)} Hz` : `${n3(l.value, 2)}x`} (${l.from})`).join('; ')}`);
233
+ lines.push(`limits: ${r.limits.map((l) => `${l.limit} ${l.limit === 'rack' ? `${l.where}: ${l.what}` : l.limit === 'deflection' ? `${n3(l.value, 3)} mm at ${l.what ?? l.where}` : l.limit === 'frequency' ? `${n3(l.value, 1)} Hz` : `${n3(l.value, 2)}x`} (${l.from})`).join('; ')}`);
143
234
  return lines;
144
235
  }
145
236
 
@@ -152,8 +243,9 @@ export function sizeChecks(s, f, helpers) {
152
243
  let r;
153
244
  try { r = frameSizing(s, helpers); } catch (e) { f('fail', `frame.size: ${e.message}`, 'frame.size: refused', { code: 'frame.size' }); return; }
154
245
  if (!r) return;
155
- const text = r.rows.map((x) => `${x.group}: ${x.choice}, ${n3(x.kg, 3)} kg, ${x.governs ? `set by ${sayLimit(x.governs)}, ${n3(x.margin, 2)} times inside it as chosen` : 'the lightest in the list'}`).join('; ');
156
- f(r.ok ? 'info' : 'warn', `${r.ok ? 'sized' : `no profile in the list meets every limit: the nearest breaks ${r.worst.limit} at ${r.worst.where} ${n3(r.worst.ratio, 2)} times over`}: ${text}. ${n3(r.total, 3)} kg of grouped beams against ${n3(r.drawn, 3)} kg drawn (cad frame --size --write writes the profiles in)`, r.ok ? null : 'frame.size: not met',
246
+ const text = r.rows.map((x) => `${x.group}: ${x.choice}, ${n3(x.kg, 3)} kg, ${x.governs ? `set by ${sayLimit(x.governs)}, ${n3(x.margin, 2)} times inside ${x.governs.limit === 'fit' ? 'its nearest limit' : 'it'} as chosen` : 'the lightest in the list'}`).join('; ');
247
+ const broke = r.worst && /^racked /.test(r.worst.case ?? '') ? `racking (${r.worst.case}) at ${r.worst.where}` : `${r.worst?.limit} at ${r.worst?.where}`;
248
+ f(r.ok ? 'info' : 'warn', `${r.ok ? 'sized' : `no profile in the list meets every limit: the nearest breaks ${broke} ${n3(r.worst.ratio, 2)} times over`}: ${text}. ${n3(r.total, 3)} kg of grouped beams against ${n3(r.drawn, 3)} kg drawn (cad frame --size --write writes the profiles in)`, r.ok ? null : 'frame.size: not met',
157
249
  { code: 'frame.size', values: { kg: r.total, drawn: r.drawn, tried: r.tried }, refs: { groups: r.rows, limits: r.limits, search: r.search } });
158
250
  }
159
251
 
package/lib/machine.mjs CHANGED
@@ -2,31 +2,106 @@
2
2
  // the task. cad plot plans a drawing on it, checks it against the task, and shows the result before anything moves.
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
- import { svgToStrokes, orderStrokes, planToolpath, stepBlocks, estimate, sheetFrame, fk } from '@rulecad/robots';
5
+ import { svgToStrokes, orderStrokes, planToolpath, stepBlocks, estimate, sheetFrame, fk, gaitBlocks } from '@rulecad/robots';
6
+ import { gaitSequence } from './gait.mjs';
6
7
  import { trainFrom, workingSpeed } from './motors.mjs';
7
8
  import { chainOf, accuracyOf, sample, jacobianError } from './task.mjs';
8
9
  import { paths } from './workspace.mjs';
9
10
 
10
- const r6 = (x) => +Number(x).toFixed(6), n3 = (x, d = 2) => String(Number(x.toFixed(d)));
11
+ const num = Number.isFinite, r6 = (x) => +Number(x).toFixed(6), n3 = (x, d = 2) => String(Number(x.toFixed(d)));
11
12
 
12
- /** The machine as plain data. Every figure's origin is said in _why, by the name of the figure. @param {object} s a built assembly with a task */
13
+ // One driven joint as an axis: its motor, the steps it takes a degree (or mm) through its train, and the fastest it steps
14
+ function axisOf(s, id) {
15
+ const motion = s.motion, t = trainFrom(motion, id), d = motion.drives.find((x) => x.joint === t.root), j = motion.joints.find((x) => x.id === id), spec = new Map((s.a.joints || []).map((x) => [x.id, x])).get(id) ?? {};
16
+ if (!d?.model.stepAngle) throw new Error(`${s.project}/${s.name}: joint ${id} has no stepper driving it, and a step file needs one`);
17
+ const micro = d.spec.microsteps ?? 16, per = (360 / d.model.stepAngle) * micro, stepsPerUnit = j.type === 'prismatic' ? (per * t.ratio) / t.slide / 360 : (per * t.ratio) / 360;
18
+ const rpm = workingSpeed(d.model, d.spec, d.supply), maxRate = (rpm / 60) * per, home = spec.home;
19
+ const homing = home ? { endstop: home.endstop, direction: home.direction ?? -1, rate: Math.round(maxRate / 8), back: Math.round(stepsPerUnit * 3) } : null;
20
+ return { name: id, joint: id, motor: d.id, model: d.model.name, driver: d.spec.driver ?? null, stepAngle: d.model.stepAngle, microsteps: micro, ratio: r6(t.ratio), stepsPerUnit: r6(stepsPerUnit), unit: j.type === 'prismatic' ? 'mm' : 'deg', limits: (j.limits ?? j.dofs[0].slice(0, 2)).map(r6), maxRate: Math.round(maxRate), homing,
21
+ _why: { stepAngle: `${d.model.name}.step_angle`, microsteps: d.spec.microsteps != null ? `the motor item's "microsteps" (resolution only, not accuracy)` : 'the default, 1/16 (resolution only, not accuracy)', ratio: t.stages.length ? `the train from ${t.root} to ${id}` : 'direct', maxRate: `${n3(rpm, 1)} rpm, ${d.spec.speed != null ? 'the motor item\'s speed' : `the working speed of a ${d.model.name}`}` } };
22
+ }
23
+
24
+ /** The slots of a CNC shield each motor is wired to, by motor item: from a wire "<motor>.<anchor>" to "<item>.X" (X, Y, Z or A). */
25
+ export function shieldSlots(a) {
26
+ const out = {};
27
+ for (const w of a.wires || []) { const [from, to] = [String(w.from), String(w.to)], m = /^[^.]+\.([XYZA])$/.exec(to); if (m) out[from.split('.')[0]] = m[1]; }
28
+ return out;
29
+ }
30
+ /** The step and direction slots of the streamer (arm.ino on a CNC Shield V3), in its axis order: axis 0 on X, 1 on Y, 2 on Z. */
31
+ export const STREAMER_SLOTS = ['X', 'Y', 'Z'];
32
+
33
+ /** The machine as plain data. Every figure's origin is said in _why, by the name of the figure. A machine with a gait and no
34
+ * task is its legs: an axis for each joint a motor turns, in the order the shield's slots are wired. @param {object} s a built assembly with a task or a gait */
13
35
  export function machineOf(s) {
14
- if (!s.task) throw new Error(`${s.project}/${s.name} has no "task": a machine says what it is for`);
15
- const c = chainOf(s), motion = s.motion, specs = new Map((s.a.joints || []).map((j) => [j.id, j]));
16
- const axes = c.names.map((id) => {
17
- const t = trainFrom(motion, id), d = motion.drives.find((x) => x.joint === t.root), j = motion.joints.find((x) => x.id === id), spec = specs.get(id) ?? {};
18
- if (!d?.model.stepAngle) throw new Error(`${s.project}/${s.name}: joint ${id} has no stepper driving it, and a step file needs one`);
19
- const micro = d.spec.microsteps ?? 16, per = (360 / d.model.stepAngle) * micro, stepsPerUnit = j.type === 'prismatic' ? (per * t.ratio) / t.slide / 360 : (per * t.ratio) / 360;
20
- const rpm = workingSpeed(d.model, d.spec, d.supply), maxRate = (rpm / 60) * per, home = spec.home;
21
- const homing = home ? { endstop: home.endstop, direction: home.direction ?? -1, rate: Math.round(maxRate / 8), back: Math.round(stepsPerUnit * 3) } : null;
22
- return { name: id, joint: id, motor: d.id, model: d.model.name, driver: d.spec.driver ?? null, stepAngle: d.model.stepAngle, microsteps: micro, ratio: r6(t.ratio), stepsPerUnit: r6(stepsPerUnit), unit: j.type === 'prismatic' ? 'mm' : 'deg', limits: (j.limits ?? j.dofs[0].slice(0, 2)).map(r6), maxRate: Math.round(maxRate), homing,
23
- _why: { stepAngle: `${d.model.name}.step_angle`, microsteps: d.spec.microsteps != null ? `the motor item's "microsteps" (resolution only, not accuracy)` : 'the default, 1/16 (resolution only, not accuracy)', ratio: t.stages.length ? `the train from ${t.root} to ${id}` : 'direct', maxRate: `${n3(rpm, 1)} rpm, ${d.spec.speed != null ? 'the motor item\'s speed' : `the working speed of a ${d.model.name}`}` } };
24
- });
36
+ if (!s.task && s.gait) return gaitMachineOf(s);
37
+ if (!s.task) throw new Error(`${s.project}/${s.name} has no "task" and no "gait": a machine says what it is for`);
38
+ const c = chainOf(s), motion = s.motion;
39
+ const axes = c.names.map((id) => axisOf(s, id));
25
40
  const kinematics = c.names.length === 2 && motion.joints.filter((j) => c.names.includes(j.id)).every((j) => j.type === 'revolute') ? 'scara' : motion.joints.filter((j) => c.names.includes(j.id)).every((j) => j.type === 'prismatic') ? 'cartesian' : 'serial';
26
41
  const pen = s.a.task.pen ?? null;
27
42
  return { format: 'rulecad.machine/1', name: `${s.project}/${s.name}`, kinematics, tool: s.task.tool, elbow: sample(s).elbow, axes, task: { sheet: s.a.task.sheet ?? null, region: s.a.task.region ?? null, volume: s.a.task.volume ?? null, speed: s.task.speed, accuracy: s.task.accuracy, accel: s.task.accel ?? 500, ...(s.task.blockTime ? { blockTime: s.task.blockTime } : {}) }, ...(pen ? { pen } : {}) };
28
43
  }
29
44
 
45
+ function gaitMachineOf(s) {
46
+ const seq = gaitSequence(s), slots = shieldSlots(s.a);
47
+ let axes = seq.names.map((id) => { const a = axisOf(s, id); return { ...a, ...(slots[a.motor] ? { slot: slots[a.motor] } : {}) }; });
48
+ if (axes.every((a) => STREAMER_SLOTS.includes(a.slot))) axes = [...axes].sort((a, b) => STREAMER_SLOTS.indexOf(a.slot) - STREAMER_SLOTS.indexOf(b.slot));
49
+ const g = s.gait, pattern = typeof s.a.gait.pattern === 'string' ? s.a.gait.pattern : `duty ${s.a.gait.pattern?.duty}`;
50
+ return { format: 'rulecad.machine/1', name: `${s.project}/${s.name}`, kinematics: 'legged', tool: null, axes, task: null,
51
+ gait: { legs: g.legs.map((l) => l.name), pattern, period: g.period, stride: g.stride, lift: g.lift, height: g.height, frames: seq.q.length } };
52
+ }
53
+
54
+ /**
55
+ * A gait as a step file: its cycle played for some cycles from a pose of the assembly and back to it, every leg's joints
56
+ * in the same blocks. Findings say how long a cycle takes on the motors against the gait's period, and whether the
57
+ * streamer can take the file: three axes at most, each on the shield's slot of its own number.
58
+ * @param {object} s a built assembly with a gait @param {{ cycles?: number, period?: number, from?: string }} [o] from: a pose's name (default the pose the assembly shows)
59
+ */
60
+ export function plotGait(s, { cycles = 3, period, from } = {}) {
61
+ if (!s.gait) throw new Error(`${s.project}/${s.name} has no "gait" to play`);
62
+ const m = machineOf(s), seq = gaitSequence(s), names = m.axes.map((a) => a.name), cols = names.map((n) => seq.names.indexOf(n));
63
+ const ordered = { period: seq.period, names, q: seq.q.map((r) => cols.map((i) => r[i])) };
64
+ const poses = s.motion.poses || {}, poseName = from ?? s.motion.pose ?? null;
65
+ if (from != null && !poses[from]) throw new Error(`--pose ${from}: no such pose (poses: ${Object.keys(poses).join(', ') || 'none'})`);
66
+ const pose = poseName ? poses[poseName] : null, findings = [];
67
+ const start = pose && names.every((n) => num(pose[n])) ? names.map((n) => pose[n]) : null;
68
+ if (poseName && !start) findings.push({ level: 'info', text: `the pose "${poseName}" does not set ${names.filter((n) => !num(pose?.[n])).join(', ')}, so the file starts and ends at the cycle's first frame`, code: 'gait.from', values: {} });
69
+ const r = gaitBlocks(ordered, { axes: m.axes.map((a) => ({ name: a.name, stepsPerUnit: a.stepsPerUnit, maxRate: a.maxRate, unit: a.unit })), cycles, ...(period != null ? { period } : {}), ...(start ? { from: start } : {}) });
70
+ findings.push(...r.findings);
71
+ // the streamer: three axes, axis k on the shield's slot X, Y or Z in that order
72
+ if (names.length > STREAMER_SLOTS.length) findings.push({ level: 'warn', text: `${names.length} axes, and the streamer steps ${STREAMER_SLOTS.length} (an Uno under a CNC Shield V3): the file is written, and send.mjs refuses it`, code: 'stream.axes', values: { axes: names.length, streamer: STREAMER_SLOTS.length } });
73
+ else for (const [k, a] of m.axes.entries()) {
74
+ if (!a.slot) findings.push({ level: 'info', text: `${a.name}'s motor ${a.motor} has no wire to a shield's slot: the streamer steps it as axis ${k}, on ${STREAMER_SLOTS[k]}`, code: 'stream.wiring', refs: { item: a.motor } });
75
+ else if (a.slot !== STREAMER_SLOTS[k]) findings.push({ level: 'fail', text: `${a.name}'s motor ${a.motor} is wired to the shield's ${a.slot}, and the streamer steps axis ${k} on ${STREAMER_SLOTS[k]}`, code: 'stream.wiring', refs: { item: a.motor } });
76
+ }
77
+ const n = r.blocks.length;
78
+ findings.push({ level: 'info', text: `${cycles} cycle${cycles === 1 ? '' : 's'} of the gait (${m.gait.pattern}) in ${n} blocks, ${n3(r.time, 1)} s${start ? `, from the pose "${poseName}" and back to it` : ''}`, code: 'plot.time', values: { time: r.time, cycles, blocks: n } });
79
+ const steps = { ...r, machine: m.name, drawing: 'gait', ...(start ? { pose: poseName } : {}) };
80
+ return { ok: findings.every((x) => x.level !== 'fail'), findings, steps, machine: m, time: { time: r.time } };
81
+ }
82
+
83
+ // A picture of a gait's step file: each axis's position through the run, from its blocks, with the gait's frames as dots
84
+ export function gaitPicture(result) {
85
+ const f = result.steps, W = 720, H = 160, pad = 40, colours = ['#135', '#c33', '#383', '#a60'];
86
+ const series = f.axes.map(() => []);
87
+ let t = 0, pos = [...f.start];
88
+ series.forEach((p, k) => p.push([0, pos[k] / f.axes[k].stepsPerUnit]));
89
+ for (const b of f.blocks) { t += b.time; pos = pos.map((x, k) => x + b.steps[k]); series.forEach((p, k) => p.push([t, pos[k] / f.axes[k].stepsPerUnit, b.kind])); }
90
+ const panels = series.map((p, k) => {
91
+ const lo = Math.min(...p.map((x) => x[1])), hi = Math.max(...p.map((x) => x[1])), y = (v) => H - 20 - ((v - lo) / (hi - lo || 1)) * (H - 40), x = (s) => pad + (s / (t || 1)) * (W - 2 * pad);
92
+ const line = p.map(([s, v]) => `${n3(x(s))},${n3(y(v))}`).join(' '), dots = p.filter((q) => q[2] === 'gait').map(([s, v]) => `<circle cx="${n3(x(s))}" cy="${n3(y(v))}" r="1.6" fill="${colours[k % 4]}"/>`).join('');
93
+ return `<g transform="translate(0 ${k * H})"><text x="${pad}" y="14" font-size="12" font-family="sans-serif">${f.axes[k].name}: ${n3(lo, 0)} to ${n3(hi, 0)} ${f.axes[k].unit} (the motor's shaft)</text><polyline points="${line}" fill="none" stroke="${colours[k % 4]}" stroke-width="1"/>${dots}</g>`;
94
+ }).join('');
95
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H * series.length + 24}" viewBox="0 0 ${W} ${H * series.length + 24}"><rect width="100%" height="100%" fill="#fff"/>${panels}<text x="${pad}" y="${H * series.length + 16}" font-size="12" font-family="sans-serif">${n3(t, 1)} s: ${f.cycles} cycles, ${n3(f.cycleTime, 2)} s each against the gait's ${f.period} s; dots are the gait's frames</text></svg>\n`;
96
+ }
97
+
98
+ export function writeGait(s, result) {
99
+ const dir = paths.exports(s.project); fs.mkdirSync(dir, { recursive: true }); const file = path.join(dir, `${s.name}-gait.steps.json`);
100
+ fs.writeFileSync(file, JSON.stringify(result.steps));
101
+ const prev = paths.preview(s.project, `${s.name}-gait.svg`); fs.mkdirSync(path.dirname(prev), { recursive: true }); fs.writeFileSync(prev, gaitPicture(result));
102
+ return { file, preview: prev };
103
+ }
104
+
30
105
  // A drawing's size against the sheet: the first stroke that leaves it, named
31
106
  function fitsSheet(strokes, frame) {
32
107
  const off = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/cad",
3
- "version": "0.7.75",
3
+ "version": "0.7.78",
4
4
  "description": "The cad command: JSCAD designs from traceable rules, checked for printing and fit, versioned by what fits, shared as links and exported as Bambu 3MF.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -68,13 +68,13 @@
68
68
  "@rulecad/rules": "^0.3.22",
69
69
  "@jscad/modeling": "^2.12.0",
70
70
  "three": "^0.186.1",
71
- "@rulecad/fea": "^0.2.11",
71
+ "@rulecad/fea": "^0.2.14",
72
72
  "@rulecad/topopt": "^0.3.4",
73
73
  "@rulecad/flexures": "^0.5.4",
74
74
  "@rulecad/gears": "^0.3.4",
75
75
  "@rulecad/motors": "^0.1.6",
76
76
  "@rulecad/fixings": "^0.1.7",
77
- "@rulecad/robots": "^0.1.3",
77
+ "@rulecad/robots": "^0.1.4",
78
78
  "@rulecad/frames": "^0.1.12"
79
79
  },
80
80
  "peerDependencies": {
@@ -29,7 +29,7 @@
29
29
  "power": { "type": "object", "additionalProperties": false, "properties": { "margin": { "type": "number" } } },
30
30
  "wires": { "type": "array", "description": "Wires between anchors, their length measured through every pose", "items": { "type": "object", "required": ["from", "to"], "additionalProperties": false, "properties": { "id": { "type": "string" }, "from": { "type": "string" }, "to": { "type": "string" }, "via": { "type": "array", "items": { "anyOf": [{ "type": "string" }, { "type": "object", "required": ["along", "from", "to"], "additionalProperties": false, "description": "A run along a beam's slot: the wire follows the slot from one distance to another, held by printed cable clips at a pitch", "properties": { "along": { "type": "string", "description": "A beam's slotted face: rail.top" }, "from": { "$ref": "#/$defs/expr", "description": "mm from the beam's end a" }, "to": { "$ref": "#/$defs/expr" }, "pitch": { "$ref": "#/$defs/expr", "description": "The most between clips, mm (default 100)" }, "cable": { "$ref": "#/$defs/expr", "description": "The bundle the clips hold, mm (default 6)" } } }] }, "description": "Anchors, path joints or runs along a slot that the wire is routed by" }, "gauge": { "type": "string", "description": "awg22" }, "colour": { "type": "string" }, "conductors": { "type": "number" }, "connectors": { "type": "array", "items": { "type": "string" } }, "current": { "type": "number", "description": "A: else a motor's rated current at either end, or a signal's" }, "note": { "type": "string" } } } },
31
31
  "gravity": { "$ref": "#/$defs/vec3", "description": "Which way down is, for masses in loads (default [0, 0, -1])" },
32
- "frame": { "type": "object", "additionalProperties": false, "description": "The frame: what it is (a generator, kind with inside or outside, which expands into beams, joins and their ends before anything is built, as cad frame --expand writes out), and how its beams and joins are solved for frame.deflection, frame.stress, frame.buckling, frame.rack and frame.frequency, which beams could be printed (beam.printable), and how it is cut and heated for frame.square and frame.heat. Left out, it stands on its feet: the beam ends that carry a foot, a levelling foot, a castor plate or a stacking foot, or else the lowest beam ends, each held from moving (pinned)", "properties": {"kind": {"enum": ["box", "portal", "table", "gantry", "shelf"], "description": "A frame generated from a size: box (four posts and a ring of beams at the bottom and top), portal (two legs and a beam across: inside and outside are [width, height]; it lies in one plane and tips over on its feet alone, so it is refused until supports says its feet are held down, as z1.a and z2.a fixed), table (four legs and a ring at the top), gantry (a box without its top beams across, and a beam riding along the two top side beams on a sliding joint) or shelf (a box with rings between, shelves of them). Its beams are z1 .. (upright), x1 .. and y1 .. (along x and y, by ring from the bottom), g (a gantry's moving beam); its corner arrangement follows the join"}, "inside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The clear volume the frame encloses, [width (x), depth (y), height (z)] in mm (a portal: [width, height]); the beams go round it. Give inside or outside"}, "outside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The volume the whole frame must fit in, [width, depth, height] in mm (a portal: [width, height]); the beams go within it"}, "profile": {"type": "string", "description": "Every beam's profile, a square one (2020-misumi-hfs5, 3030-generic, 4040-item-8)"}, "join": {"description": "How the beams meet at each corner: a kind (blind, end-tap, bracket, gusset, hidden, anchor: the upright beams run through and the others butt against their faces, each shorter by the profile's width at each end; cube: every beam butts into a corner node, each as long as the inside), or { kind, fitting, screw } as a join takes them", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["kind"], "properties": {"kind": {"type": "string"}, "fitting": {"type": "string"}, "screw": {"type": "string"}}}]}, "feet": {"type": ["string", "null"], "description": "What stands under the upright beams' lower ends: foot, levelling, castor or stacking (printed), or a bought foot's set by name (fitting-motedis-foot-m6-d19); left out, an end cap"}, "caps": {"type": ["string", "boolean"], "description": "The ends no join covers: printed end caps (true, the default), a bought end cap's set by name, or false for none (join.end then names them)"}, "braces": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "The upright sides whose corners are stiffened against racking: each join in that side becomes a bracket join with a printed corner bracket in the corner, on drop-in nuts"}, "panels": {"type": "object", "additionalProperties": false, "required": ["sheet", "thickness"], "description": "Panels closing the upright sides, each cut to its bay with its clips (a box, a shelf, a gantry's two sides)", "properties": {"sheet": {"type": "string", "description": "The sheet's material: acrylic, polycarbonate, aluminium, plywood, mdf"}, "thickness": {"$ref": "#/$defs/expr", "description": "mm"}, "sides": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "Which sides (default every side that has a bay)"}}}, "shelves": {"type": "integer", "minimum": 1, "maximum": 20, "description": "A shelf: how many rings stand between the bottom and the top, spacing its height into equal clear bays (default 1)"}, "supports": {"type": "object", "description": "Where the frame is held, by beam end (\"z1.a\") or a place on a beam (\"x1.bottom@50%\"): pinned holds it from moving and lets it turn, fixed holds it from turning too, resting holds it from moving and from twisting about the beam's own length (a beam lying across a round bar, as the beam coupon does; for a beam along x, y or z). Given, these are the only supports", "additionalProperties": {"enum": ["pinned", "fixed", "resting"]}}, "limit": {"$ref": "#/$defs/expr", "description": "The sag allowed in every frame.deflection finding, in mm: at each load's point, each named point and along each guide whose rail gives no parallelism of its own (default: the task's accuracy, else the span of the beam it is on over 360)"}, "points": {"type": "array", "description": "Places on beams to report the sag at, beside each load's point and every guide (\"x1.top@50%\")", "items": {"type": "string"}}, "cut": {"type": "object", "additionalProperties": false, "description": "How the beams are cut in this workshop, where it differs from the profile's set and the kit's defaults: frame.square, frame.cut and the cut list read it", "properties": {"tolerance": {"$ref": "#/$defs/expr", "description": "How far a cut length may be from the length asked, either way, in mm (default: the profile's cut_tolerance, else 0.5)"}}}, "heat": {"type": "object", "additionalProperties": false, "description": "frame.heat: the temperatures the frame works at. The beams grow with the air in the enclosure; each printed fitting is held to its plastic's softening point", "properties": {"air": {"$ref": "#/$defs/expr", "description": "The air round the frame when it runs, in degrees C (inside its enclosure)"}, "built": {"$ref": "#/$defs/expr", "description": "The air it was built and squared in, in degrees C (default 20)"}, "heaters": {"type": "array", "description": "Hot things near the frame: what is within reach of one is taken at its temperature", "items": {"type": "object", "required": ["at", "temperature", "reach"], "additionalProperties": false, "properties": {"name": {"type": "string"}, "at": {"$ref": "#/$defs/vec3", "description": "Its middle, in the assembly's frame, mm"}, "temperature": {"$ref": "#/$defs/expr", "description": "Degrees C at its surface"}, "reach": {"$ref": "#/$defs/expr", "description": "How far from its middle a part is taken at that temperature, mm"}}}}}}, "printed": {"description": "beam.printable: each beam tried printed in this plastic (the kit's printable profile of its size, lying down or standing up), the frame solved again and held to its own limits: its sags, stress, buckling, creep and lowest mode; the beams that can be printed are listed, and printed together solved once more. A plastic's set by name (\"petg\"), or how it prints", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["material"], "properties": {"material": {"type": "string", "description": "The plastic's set: pla, petg"}, "walls": {"type": "integer", "minimum": 1, "description": "Walls round every outline, in lines (3)"}, "infill": {"type": "number", "minimum": 0, "maximum": 1, "description": "The share of the inside the infill fills (0.4)"}, "pose": {"enum": ["lying", "standing"], "description": "Only this way up (both are tried where left out)"}}}]}, "size": {"type": "object", "additionalProperties": false, "description": "frame.size: each group of beams that must match given the lightest profile from a list that meets the frame's own limits (the sag at each load, point and guide, each beam's stress and buckling with frame.margin to spare, and the lowest mode against the task's moves), solved in every pose; a table of each group's profile, the limit that set it and its margin, and cad frame --size --write writes the profiles in", "properties": {"profiles": {"type": "array", "minItems": 1, "items": {"type": "string"}, "description": "The profiles to choose from, by set (default MISUMI's HFS5, HFS6 and HFS8 series from 2020 to 4080). One that is not square is tried lying as drawn and turned a quarter. Choose one family whose joins fit each other: the join checks of the written frame say where they do not"}, "groups": {"type": "object", "description": "Beams that must take one profile, by group name (\"rails\": [\"x1\", \"x2\"]); the rest are grouped by themselves: one profile, one direction, lengths within 0.5 mm", "additionalProperties": {"type": "array", "minItems": 1, "items": {"type": "string"}}}, "limits": {"type": "object", "additionalProperties": false, "description": "Limits in place of the frame checks' own", "properties": {"deflection": {"$ref": "#/$defs/expr", "description": "The sag allowed at every load, named point and guide, mm"}, "stress": {"$ref": "#/$defs/expr", "description": "How many times under its alloy's strength each beam stays (default frame.margin, 2)"}, "buckling": {"$ref": "#/$defs/expr", "description": "How many times its load the frame, and each grouped beam by Euler's load, must carry before it buckles (default frame.margin, 2)"}, "frequency": {"$ref": "#/$defs/expr", "description": "The lowest mode's floor, Hz (default twice what the task's moves shake it at; none without a task)"}}}, "by": {"enum": ["mass", "cost"], "description": "What is made least (mass: no profile set in the kit gives a price per metre yet)"}}}, "rack": {"type": "object", "additionalProperties": false, "description": "frame.rack: the side push at the frame's top and the sway allowed", "properties": {"load": {"$ref": "#/$defs/expr", "description": "The side push in N, shared among the top corners (default 20, an estimate)"}, "limit": {"$ref": "#/$defs/expr", "description": "The sway allowed at the top, in mm (default: the task's accuracy, else the height over 400)"}}}} },
32
+ "frame": { "type": "object", "additionalProperties": false, "description": "The frame: what it is (a generator, kind with inside or outside, which expands into beams, joins and their ends before anything is built, as cad frame --expand writes out), and how its beams and joins are solved for frame.deflection, frame.stress, frame.buckling, frame.rack and frame.frequency, which beams could be printed (beam.printable), and how it is cut and heated for frame.square and frame.heat. Left out, it stands on its feet: the beam ends that carry a foot, a levelling foot, a castor plate or a stacking foot, or else the lowest beam ends, each held from moving (pinned)", "properties": {"kind": {"enum": ["box", "portal", "table", "gantry", "shelf"], "description": "A frame generated from a size: box (four posts and a ring of beams at the bottom and top), portal (two legs and a beam across: inside and outside are [width, height]; it lies in one plane and tips over on its feet alone, so it is refused until supports says its feet are held down, as z1.a and z2.a fixed), table (four legs and a ring at the top), gantry (a box without its top beams across, and a beam riding along the two top side beams on a sliding joint) or shelf (a box with rings between, shelves of them). Its beams are z1 .. (upright), x1 .. and y1 .. (along x and y, by ring from the bottom), g (a gantry's moving beam); its corner arrangement follows the join"}, "inside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The clear volume the frame encloses, [width (x), depth (y), height (z)] in mm (a portal: [width, height]); the beams go round it. Give inside or outside"}, "outside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The volume the whole frame must fit in, [width, depth, height] in mm (a portal: [width, height]); the beams go within it"}, "profile": {"type": "string", "description": "Every beam's profile, a square one (2020-misumi-hfs5, 3030-generic, 4040-item-8)"}, "join": {"description": "How the beams meet at each corner: a kind (blind, end-tap, bracket, gusset, hidden, anchor: the upright beams run through and the others butt against their faces, each shorter by the profile's width at each end; cube: every beam butts into a corner node, each as long as the inside), or { kind, fitting, screw } as a join takes them", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["kind"], "properties": {"kind": {"type": "string"}, "fitting": {"type": "string"}, "screw": {"type": "string"}}}]}, "feet": {"type": ["string", "null"], "description": "What stands under the upright beams' lower ends: foot, levelling, castor or stacking (printed), or a bought foot's set by name (fitting-motedis-foot-m6-d19); left out, an end cap"}, "caps": {"type": ["string", "boolean"], "description": "The ends no join covers: printed end caps (true, the default), a bought end cap's set by name, or false for none (join.end then names them)"}, "braces": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "The upright sides whose corners are stiffened against racking: each join in that side becomes a bracket join with a printed corner bracket in the corner, on drop-in nuts"}, "panels": {"type": "object", "additionalProperties": false, "required": ["sheet", "thickness"], "description": "Panels closing the upright sides, each cut to its bay with its clips (a box, a shelf, a gantry's two sides)", "properties": {"sheet": {"type": "string", "description": "The sheet's material: acrylic, polycarbonate, aluminium, plywood, mdf"}, "thickness": {"$ref": "#/$defs/expr", "description": "mm"}, "sides": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "Which sides (default every side that has a bay)"}}}, "shelves": {"type": "integer", "minimum": 1, "maximum": 20, "description": "A shelf: how many rings stand between the bottom and the top, spacing its height into equal clear bays (default 1)"}, "supports": {"type": "object", "description": "Where the frame is held, by beam end (\"z1.a\") or a place on a beam (\"x1.bottom@50%\"): pinned holds it from moving and lets it turn, fixed holds it from turning too, resting holds it from moving and from twisting about the beam's own length (a beam lying across a round bar, as the beam coupon does; for a beam along x, y or z). Given, these are the only supports, and at least one is named", "minProperties": 1, "additionalProperties": {"enum": ["pinned", "fixed", "resting"]}}, "limit": {"$ref": "#/$defs/expr", "description": "The sag allowed in every frame.deflection finding, in mm: at each load's point, each named point and along each guide whose rail gives no parallelism of its own (default: the task's accuracy, else the span of the beam it is on over 360)"}, "points": {"type": "array", "description": "Places on beams to report the sag at, beside each load's point and every guide (\"x1.top@50%\")", "items": {"type": "string"}}, "cut": {"type": "object", "additionalProperties": false, "description": "How the beams are cut in this workshop, where it differs from the profile's set and the kit's defaults: frame.square, frame.cut and the cut list read it", "properties": {"tolerance": {"$ref": "#/$defs/expr", "description": "How far a cut length may be from the length asked, either way, in mm (default: the profile's cut_tolerance, else 0.5)"}}}, "heat": {"type": "object", "additionalProperties": false, "description": "frame.heat: the temperatures the frame works at. The beams grow with the air in the enclosure; each printed fitting is held to its plastic's softening point", "properties": {"air": {"$ref": "#/$defs/expr", "description": "The air round the frame when it runs, in degrees C (inside its enclosure)"}, "built": {"$ref": "#/$defs/expr", "description": "The air it was built and squared in, in degrees C (default 20)"}, "heaters": {"type": "array", "description": "Hot things near the frame: what is within reach of one is taken at its temperature", "items": {"type": "object", "required": ["at", "temperature", "reach"], "additionalProperties": false, "properties": {"name": {"type": "string"}, "at": {"$ref": "#/$defs/vec3", "description": "Its middle, in the assembly's frame, mm"}, "temperature": {"$ref": "#/$defs/expr", "description": "Degrees C at its surface"}, "reach": {"$ref": "#/$defs/expr", "description": "How far from its middle a part is taken at that temperature, mm"}}}}}}, "printed": {"description": "beam.printable: each beam tried printed in this plastic (the kit's printable profile of its size, lying down or standing up), the frame solved again and held to its own limits: its sags, stress, buckling, creep and lowest mode; the beams that can be printed are listed, and printed together solved once more. A plastic's set by name (\"petg\"), or how it prints", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["material"], "properties": {"material": {"type": "string", "description": "The plastic's set: pla, petg"}, "walls": {"type": "integer", "minimum": 1, "description": "Walls round every outline, in lines (3)"}, "infill": {"type": "number", "minimum": 0, "maximum": 1, "description": "The share of the inside the infill fills (0.4)"}, "pose": {"enum": ["lying", "standing"], "description": "Only this way up (both are tried where left out)"}}}]}, "size": {"type": "object", "additionalProperties": false, "description": "frame.size: each group of beams that must match given the lightest profile from a list that meets the frame's own limits (the sag at each load, point and guide, each beam's stress and buckling with frame.margin to spare, and the lowest mode against the task's moves), solved in every pose; a table of each group's profile, the limit that set it and its margin, and cad frame --size --write writes the profiles in", "properties": {"profiles": {"type": "array", "minItems": 1, "items": {"type": "string"}, "description": "The profiles to choose from, by set (default MISUMI's HFS5, HFS6 and HFS8 series from 2020 to 4080). One that is not square is tried lying as drawn and turned a quarter. A design is only tried where every join of a grouped beam still goes together (a blind join's screw and button head in the other beam's slot, an end-tap's cap head on its far face, a bought fitting on both profiles); the join checks of the written frame hold the rest"}, "groups": {"type": "object", "description": "Beams that must take one profile, by group name (\"rails\": [\"x1\", \"x2\"]); the rest are grouped by themselves: one profile, one direction, lengths within 0.5 mm", "additionalProperties": {"type": "array", "minItems": 1, "items": {"type": "string"}}}, "limits": {"type": "object", "additionalProperties": false, "description": "Limits in place of the frame checks' own", "properties": {"deflection": {"$ref": "#/$defs/expr", "description": "The sag allowed at every load, named point and guide, mm"}, "stress": {"$ref": "#/$defs/expr", "description": "How many times under its alloy's strength each beam stays (default frame.margin, 2)"}, "buckling": {"$ref": "#/$defs/expr", "description": "How many times its load the frame, and each grouped beam by Euler's load, must carry before it buckles (default frame.margin, 2)"}, "frequency": {"$ref": "#/$defs/expr", "description": "The lowest mode's floor, Hz (default twice what the task's moves shake it at; none without a task)"}, "rack": {"$ref": "#/$defs/expr", "description": "The sway allowed at the frame's top under frame.rack's side push alone, each way across, mm: racking as a limit (default frame.rack's own limit where the assembly gives frame.rack; none otherwise)"}}}, "by": {"enum": ["mass", "cost"], "description": "What is made least (mass: no profile set in the kit gives a price per metre yet)"}}}, "rack": {"type": "object", "additionalProperties": false, "description": "frame.rack: the side push at the frame's top and the sway allowed", "properties": {"load": {"$ref": "#/$defs/expr", "description": "The side push in N, shared among the top corners (default 20, an estimate)"}, "limit": {"$ref": "#/$defs/expr", "description": "The sway allowed at the top, in mm (default: the task's accuracy, else the height over 400)"}}}} },
33
33
  "loads": { "type": "array", "description": "What the assembly has to do: a torque (N m) or force (N) on a joint, or a mass (kg) carried at an anchor", "items": { "type": "object", "additionalProperties": false, "properties": { "joint": { "type": "string" }, "torque": { "$ref": "#/$defs/expr" }, "force": { "$ref": "#/$defs/expr" }, "mass": { "$ref": "#/$defs/expr" }, "at": { "$ref": "#/$defs/anchorRef" }, "note": { "type": "string" } } } },
34
34
  "poses": { "type": "object", "description": "Named sets of joint values ({ \"hinge\": 90 }), and of items' variables (\"action.travel\": 25: a flexure drawn bent in that pose, printed as drawn)", "additionalProperties": { "type": "object", "additionalProperties": { "$ref": "#/$defs/values" } } },
35
35
  "printInPlace": { "type": "array", "minItems": 2, "items": { "type": "string" }, "description": "Items printed together as one object printed in place (\"printInPlace\": true on it): they come off the bed together, so the assembly order never takes them apart from each other" },