@rulecad/cad 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/AGENTS.md +29 -10
  2. package/CHANGELOG.md +604 -0
  3. package/EXAMPLES.md +122 -105
  4. package/README.md +292 -63
  5. package/bin/cad.mjs +500 -87
  6. package/lib/assembly.mjs +486 -134
  7. package/lib/bays.mjs +124 -0
  8. package/lib/cache-file.mjs +148 -0
  9. package/lib/clone.mjs +93 -11
  10. package/lib/code-text.mjs +28 -0
  11. package/lib/design-imports.mjs +127 -0
  12. package/lib/design.mjs +291 -59
  13. package/lib/designshapes.mjs +142 -0
  14. package/lib/edit.mjs +29 -5
  15. package/lib/estimates.mjs +51 -0
  16. package/lib/fasten.mjs +11 -5
  17. package/lib/fe-key.mjs +29 -0
  18. package/lib/fittings.mjs +20 -15
  19. package/lib/fixings.mjs +17 -4
  20. package/lib/framebuild.mjs +73 -92
  21. package/lib/framecheck.mjs +154 -77
  22. package/lib/framegen.mjs +9 -1
  23. package/lib/frames.mjs +6 -2
  24. package/lib/framesize.mjs +45 -82
  25. package/lib/gait.mjs +17 -7
  26. package/lib/guides.mjs +84 -50
  27. package/lib/host.mjs +7 -3
  28. package/lib/kit.mjs +5 -5
  29. package/lib/list.mjs +29 -21
  30. package/lib/live-guard.mjs +18 -8
  31. package/lib/loads.mjs +35 -23
  32. package/lib/measured.mjs +740 -99
  33. package/lib/mesh.mjs +156 -56
  34. package/lib/motors.mjs +26 -33
  35. package/lib/names.mjs +15 -0
  36. package/lib/node-version.mjs +52 -0
  37. package/lib/optimise.mjs +34 -25
  38. package/lib/order.mjs +5 -12
  39. package/lib/parts.mjs +3 -0
  40. package/lib/picture-servers.mjs +66 -0
  41. package/lib/power.mjs +14 -7
  42. package/lib/preview.mjs +12 -25
  43. package/lib/programs.mjs +113 -0
  44. package/lib/rules.mjs +2 -1
  45. package/lib/sandbox-guard.mjs +43 -0
  46. package/lib/sandbox-hooks.mjs +109 -15
  47. package/lib/sandbox-lock.mjs +225 -0
  48. package/lib/sandbox-preload.mjs +2 -2
  49. package/lib/sandbox-run.mjs +22 -24
  50. package/lib/sandbox.mjs +345 -42
  51. package/lib/sheet.mjs +114 -3
  52. package/lib/targets/gist.mjs +9 -6
  53. package/lib/versions.mjs +294 -35
  54. package/lib/workspace.mjs +6 -3
  55. package/package.json +14 -14
  56. package/schemas/assembly.schema.json +6 -5
  57. package/schemas/object.schema.json +1 -1
  58. package/schemas/project.schema.json +6 -0
  59. package/templates/coupons/MEASURE.md +109 -0
  60. package/templates/coupons/assemblies/fixings-test.json +20 -0
  61. package/templates/coupons/assemblies/slot-test.json +11 -0
  62. package/templates/coupons/objects/fixings-coupon.js +88 -0
  63. package/templates/coupons/objects/fixings-coupon.json +26 -0
  64. package/templates/coupons/objects/holds-coupon.js +130 -0
  65. package/templates/coupons/objects/holds-coupon.json +42 -0
  66. package/templates/coupons/objects/slot-coupon.js +89 -0
  67. package/templates/coupons/objects/slot-coupon.json +29 -0
  68. package/templates/coupons/project.json +10 -0
@@ -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": {"description": "What stands under the upright beams' lower ends: foot, levelling or stacking (printed), a bought foot's set by name (fitting-motedis-foot-m6-d19), or a printed castor plate as { kind: castor, holes: [x, y], thread: M6, top } from the castor's drawing; left out, an end cap", "oneOf": [{"type": ["string", "null"]},{"type": "object", "additionalProperties": false, "required": ["kind", "holes", "thread"], "properties": {"kind": {"enum": ["castor"]}, "holes": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "number"}, "description": "The castor's bolt holes' spacing [x, y] in mm, from its maker's drawing"}, "thread": {"type": "string", "description": "Its bolts' thread, as M6"}, "top": {"type": "number", "description": "Its top plate's thickness in mm, for the bolts' length (3, an estimate, where left out)"}}}]}, "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 corner of that side keeps the join asked for and gains a printed corner bracket beside it, on drop-in nuts (where the join is a printed bracket already, that bracket is drawn braced instead; a bracket join not printed is refused with braces)"}, "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)"}}}} },
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, its feet and end caps with it, [width, depth, height] in mm (a portal: [width, height]); the beams go within it, smaller by what the feet and caps add (refused on castors, whose height is not drawn)"}, "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, estimate } as a join takes them. blind and end-tap are built as they stand; bracket and gusset with their fitting, printed or bought, and hidden and anchor with a bought one; cube not yet", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["kind"], "properties": {"kind": {"type": "string"}, "fitting": {"type": "string"}, "screw": {"type": "string"}, "estimate": {"type": "boolean", "description": "true: make the frame with a join the kit cannot build yet (cube; bracket, gusset, hidden or anchor with no fitting), its joins checked by their estimate. Without it those are refused, naming what is missing"}}}]}, "feet": {"description": "What stands under the upright beams' lower ends: foot, levelling or stacking (printed), a bought foot's set by name (fitting-motedis-foot-m6-d19), or a printed castor plate as { kind: castor, holes: [x, y], thread: M6, top } from the castor's drawing; left out, an end cap", "oneOf": [{"type": ["string", "null"]},{"type": "object", "additionalProperties": false, "required": ["kind", "holes", "thread"], "properties": {"kind": {"enum": ["castor"]}, "holes": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "number"}, "description": "The castor's bolt holes' spacing [x, y] in mm, from its maker's drawing"}, "thread": {"type": "string", "description": "Its bolts' thread, as M6"}, "top": {"type": "number", "description": "Its top plate's thickness in mm, for the bolts' length (3, an estimate, where left out)"}}}]}, "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 corner of that side keeps the join asked for and gains a printed corner bracket beside it, on drop-in nuts (where the join is a printed bracket already, that bracket is drawn braced instead; a bracket join not printed is refused with braces)"}, "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" },
@@ -48,7 +48,7 @@
48
48
  "id": { "type": "string" },
49
49
  "object": { "type": "string" },
50
50
  "assembly": { "type": "string" },
51
- "motor": { "type": "object", "required": ["model"], "additionalProperties": false, "description": "A motor from @rulecad/motors: bought, not printed; its shaft turns the joint it drives", "properties": { "model": { "type": "string" }, "drives": { "type": "string" }, "set": { "type": "object", "description": "Figures that differ from the catalogue's, by name" }, "speed": { "$ref": "#/$defs/expr", "description": "The motor's speed, rpm (default: what it does comfortably)" }, "margin": { "$ref": "#/$defs/expr", "description": "How many times over the torque must be (default 2)" }, "duty": { "$ref": "#/$defs/expr", "description": "The share of the time it runs, 0 to 1 (default 1), for its heat" }, "screw": { "type": "string", "description": "The screws that hold the motor, by a fixing's name: a thread through its plain holes, if not the size they take (M3), or a whole screw with its length and head (M3x8 hex), whose head sets the tool the order names" }, "driver": { "type": "string", "description": "The bought driver item this motor plugs into" }, "leadscrew": { "type": "object", "additionalProperties": false, "required": ["lead"], "properties": { "lead": { "$ref": "#/$defs/expr" }, "diameter": { "$ref": "#/$defs/expr" }, "friction": { "$ref": "#/$defs/expr" } } }, "belt": { "type": "object", "additionalProperties": false, "required": ["teeth"], "properties": { "teeth": { "$ref": "#/$defs/expr" }, "pitch": { "$ref": "#/$defs/expr" }, "stiffness": { "$ref": "#/$defs/expr", "description": "N per mm of strain, per mm of belt width" }, "width": { "$ref": "#/$defs/expr" }, "length": { "$ref": "#/$defs/expr" }, "load": { "$ref": "#/$defs/expr" } } }, "current": { "type": "number", "description": "A per coil, as set on the driver (default its rated current)" }, "cooled": { "type": "boolean", "description": "The driver has a heat sink and moving air" }, "microsteps": { "type": "number", "description": "Steps to a full step (default 16): resolution, not accuracy" } } },
51
+ "motor": { "type": "object", "required": ["model"], "additionalProperties": false, "description": "A motor from @rulecad/motors: bought, not printed; its shaft turns the joint it drives", "properties": { "model": { "type": "string" }, "drives": { "type": "string" }, "set": { "type": "object", "description": "Figures that differ from the catalogue's, by name" }, "speed": { "$ref": "#/$defs/expr", "description": "The motor's speed, rpm (default: what it does comfortably)" }, "margin": { "$ref": "#/$defs/expr", "description": "How many times over the torque must be (default 2)" }, "duty": { "$ref": "#/$defs/expr", "description": "The share of the time it runs, 0 to 1 (default 1), for its heat" }, "screw": { "type": "string", "description": "The screws that hold the motor, by a fixing's name: a thread through its plain holes, if not the size they take (M3), or a whole screw with its length and head (M3x8 hex), whose head sets the tool the order names" }, "driver": { "type": "string", "description": "The bought driver item this motor plugs into" }, "leadscrew": { "type": "object", "additionalProperties": false, "required": ["lead"], "properties": { "lead": { "$ref": "#/$defs/expr" }, "diameter": { "$ref": "#/$defs/expr" }, "friction": { "$ref": "#/$defs/expr" } } }, "belt": { "type": "object", "additionalProperties": false, "required": ["teeth"], "properties": { "teeth": { "$ref": "#/$defs/expr" }, "pitch": { "$ref": "#/$defs/expr" }, "stiffness": { "$ref": "#/$defs/expr", "description": "N per mm of strain, per mm of belt width" }, "width": { "$ref": "#/$defs/expr" }, "length": { "$ref": "#/$defs/expr" }, "load": { "$ref": "#/$defs/expr" } } }, "current": { "type": "number", "description": "The peak current per coil, A, as set on the driver (default its rated current per phase); a TMC2209's trimmer is set for its RMS, about 0.71 of the peak" }, "cooled": { "type": "boolean", "description": "The driver has a heat sink and moving air" }, "microsteps": { "type": "number", "description": "Steps to a full step (default 16): resolution, not accuracy" } } },
52
52
  "bought": { "type": "string", "description": "A part from a rule set (\"608\", \"drv8825\", \"fitting-motedis-end-cap-20-b6\"): bought, not printed; drawn faint from its figures, with anchors from what it is. A frame's bought fitting (an end cap, a levelling foot, a hinge) placed at a beam's address is checked against that beam's profile, and its price goes on cad list" },
53
53
  "variant": { "type": "string" },
54
54
  "set": { "type": "object" },
@@ -94,8 +94,9 @@
94
94
  "fastener": { "description": "What does the fastening: in words (two push pins), named on the shopping list and the assembly step as written; or pins, { \"pin\": \"snap pin 4x6\", \"count\": 2 }, found in the parts' holes and checked (fit.pin): each hole against the one @rulecad/fixings draws for the pin and the printer, the pin's length against the parts, and the load; or magnets, { \"magnet\": \"disc magnet 8x3\", \"count\": 2 }, found in the parts' pockets and checked (fit.magnet): each pocket against the one @rulecad/fixings draws for the magnet and the printer, its depth and floor, and their pull against the load. A screw is a fasten's, which chooses its length and counts it", "anyOf": [{ "$ref": "#/$defs/pins" }, { "$ref": "#/$defs/magnets" }, { "type": "string" }] },
95
95
  "count": { "$ref": "#/$defs/expr", "description": "With fastener: how many" },
96
96
  "access": { "type": "string", "description": "<item>.<anchor>: where the screw's tool comes from, its z axis pointing out along the screw. Whatever stands on that line goes on after the screw; if nothing can, assembly.order says so" },
97
- "min": { "$ref": "#/$defs/expr" },
98
- "max": { "$ref": "#/$defs/expr" },
97
+ "min": { "$ref": "#/$defs/expr", "description": "The smallest gap between a and b (mm). Negative for a press fit: they may run into each other no deeper than this, as measured (-0.1 for a tenth of a millimetre). A min below -1 is refused: where they may overlap by any amount, give \"overlap\": \"allowed\" in its place" },
98
+ "max": { "$ref": "#/$defs/expr", "description": "The largest gap between a and b (mm). A gap outside min to max fails. Negative for a press fit that must grip: they run into each other at least this deep" },
99
+ "overlap": { "enum": ["allowed"], "description": "a and b may overlap by any amount (a rod through a part, an end cap's pegs in a beam, a reference part drawn into another): the overlap check leaves the pair alone, and a gap is still held to min and max where they are given" },
99
100
  "note": { "type": "string" },
100
101
  "label": { "type": "string" },
101
102
  "poses": { "type": "array", "items": { "type": "string" } },
@@ -221,7 +222,7 @@
221
222
  "backlash": { "$ref": "#/$defs/expr" },
222
223
  "ring": { "type": "boolean" },
223
224
  "bevel": { "type": "boolean" },
224
- "worm": { "anyOf": [{ "type": "boolean" }, { "type": "object", "additionalProperties": false, "properties": { "diameter": { "$ref": "#/$defs/expr" }, "hand": { "enum": ["right", "left"] } } }] }
225
+ "worm": { "anyOf": [{ "type": "boolean" }, { "type": "object", "additionalProperties": false, "properties": { "diameter": { "$ref": "#/$defs/expr" }, "hand": { "enum": ["right", "left"] }, "flanks": { "enum": ["printed", "standard"] }, "overhang": { "$ref": "#/$defs/expr" } } }] }
225
226
  }
226
227
  }
227
228
  }
@@ -17,7 +17,7 @@
17
17
  "material": { "type": "string" },
18
18
  "orientation": { "type": "string", "description": "How it sits on the bed, and anything the printer or the person assembling it should know" },
19
19
  "role": { "enum": ["part", "reference", "board"], "description": "reference: drawn faint and never printed (a switch, a tablet); board: a circuit board" },
20
- "engine": { "enum": ["jscad", "manifold", "pcb"], "description": "manifold: v.ops booleans by Manifold (npm install manifold-3d); pcb: a circuit board" },
20
+ "engine": { "enum": ["jscad", "manifold", "pcb"], "description": "manifold: v.ops booleans by Manifold (npm install manifold-3d); jscad: by JSCAD, whatever cad.config.json's engine; left out, cad.config.json's engine (JSCAD if it names none); pcb: a circuit board" },
21
21
  "printInPlace": { "type": "boolean", "description": "The parts print together, in the pose they are drawn in, and move apart once freed (a gearbox printed whole). cad check holds each part to a face of its own on the bed, every two parts to the printer's print_gap apart (measured by Manifold), and nothing to a support, since none can come out from between them" },
22
22
  "variables": { "type": "object", "additionalProperties": { "$ref": "#/$defs/variable" } },
23
23
  "display": { "type": "object", "description": "Settings the mirror and model page use instead (lighter meshes, no legends)" },
@@ -14,6 +14,12 @@
14
14
  "material": { "type": "string", "description": "The plastic its parts print in unless a part says otherwise: PLA or PETG, or a rule set in rules/ that gives strength, modulus and density. Printed fittings are sized from it" },
15
15
  "printer": { "type": "string", "pattern": "^([A-Za-z0-9][A-Za-z0-9_-]*)?$", "description": "The printer rule set its prints are checked against (bed, overhang, layer), as x1c; left out, cad.config.json's printer. A plain name: letters, digits, - and _" },
16
16
  "objects": { "type": "array", "items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" }, "description": "Its objects, by name, as cad new <project>/<object> lists them" },
17
+ "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$", "description": "The project's latest release, as cad release <project> writes it (a git tag <project>@<version> holds it). Left to cad release" },
18
+ "release": {
19
+ "type": "object",
20
+ "description": "The version of each object in the project's latest release, by name, as cad release <project> writes it. Left to cad release",
21
+ "additionalProperties": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" }
22
+ },
17
23
  "filaments": {
18
24
  "type": "object",
19
25
  "description": "Its filaments, by name, for parts that print in more than one (a part's \"filament\": \"legend\"): each in its AMS slot",
@@ -0,0 +1,109 @@
1
+ # Coupons: measure your printer
2
+
3
+ Every hole, pocket and slot the kit draws starts from a figure someone else measured, or an estimate. These coupons
4
+ settle them on your own printer and plastic: each prints a feature at the kit's figure and a step or two either side,
5
+ with its figure beside it. Find the one that works best, write its figure back with `cad measured`, and every design in
6
+ this workspace follows it the next time it is checked or exported.
7
+
8
+ `npx cad coupons` put this project in your workspace. The rows below keep the numbers they have in the kit's full bench
9
+ sheet (`examples/bench/projects/benchmarks/MEASURE.md` in the rulecad repository), so cad's messages and the kit's notes
10
+ name the same row.
11
+
12
+ **Print in your usual plastic, at 0.2 mm layers, four walls, 25% infill.** Keep the same spool for the whole set.
13
+
14
+ ## What to print
15
+
16
+ | Print | Parts | Solid mass | Measures |
17
+ |---|---|---|---|
18
+ | 1. Fixings coupons (once in PLA, once in PETG if you print both) | `fixings-coupon`, and `holds-coupon` behind it on the same plate: a plate and 13 loose pieces (`cad plates coupons/fixings-test` lays out both) | 55 g and 38 g, 93 g on one plate about 195 by 194 mm, about 100 minutes | 22 to 28, 40 to 47 |
19
+ | 2. Slot coupon (when you build with aluminium beams) | `slot-coupon` (26 loose pieces; `cad plates coupons/slot-test`) | 40 g, about 45 minutes | 29 to 33 |
20
+
21
+ `cad export coupons/fixings-coupon` (and `holds-coupon`, `slot-coupon`) writes each as a 3MF for Bambu Studio.
22
+
23
+ ## What you need
24
+
25
+ | | |
26
+ |---|---|
27
+ | **For the fixings coupon** | Socket cap screws: M2 × 6, M2.5 × 6, M3 × 6, M3 × 8, M4 × 8, M5 × 16; M3 and M4 hex nuts; CNC Kitchen heat-set inserts, M2 × 3 and M3 × 5.7, and a soldering iron with an insert tip; steel bolts or set screws M6 × 16, M8 × 20 and M10 × 25 or longer; a spanner |
28
+ | **For the holds coupon** | Steel dowel pins 3 × 12 mm (ISO 8734 or ISO 2338 m6): two; a few 12 mm lengths of 1.75 mm filament, cut square; disc magnets 6 × 3 mm and 8 × 3 mm, N35 or stronger: three 6 × 3 and four 8 × 3 (sold in tens); a steel M8 hex nut and an M8 washer, for the pull bolt; two blocks of wood no more than 20 mm thick (18 mm plywood offcuts) and a G-clamp; a loop of strong cord; a luggage scale (it reads to 50 kg); a vice, or two scraps of wood to press magnets between |
29
+ | **For the slot coupon** | An offcut of your own beam, 50 to 100 mm long, cut square at one end; M2.5 hex nuts and M2.5 × 8 screws for slot 6, M5 hex nuts and M5 × 10 screws for slot 8; one of the bought slot nuts made for your beam (slide-in or drop-in) |
30
+
31
+ ## The measurements
32
+
33
+ Each row's command writes the figure back, in this workspace's copy of the rule set (`rules/x1c.json`, `rules/pla.json`,
34
+ `rules/slot-8.json`), marked as measured with the date. Give it on its own, as the rows show, or after one of your own
35
+ assemblies (`cad measured home/lidded-box x1c.pilot_m3=2.9`) to see what it moves there. `cad measured --export` then
36
+ prints every figure you measured as a change to the kit's rule sets, to send to the kit (see the end of this sheet).
37
+
38
+ | # | What | How | The kit assumes | Measured |
39
+ |---|---|---|---|---|
40
+ | 22 | Pilots, rows M2, M2.5, M3, M4, M5 | Each figure is the hole as drawn. Drive a screw of that size into each by hand with a driver. The best is the smallest the screw goes into straight, without splitting the boss, that turns with an even drag and cannot be pulled out by hand. `cad measured x1c.pilot_m4=<figure>` (and `pilot_m2`, `pilot_m2_5`, `pilot_m3`, `pilot_m5`; from the PETG print, `x1c.pilot_m4_petg`) | M2 2.1, M2.5 2.5, M3 2.9, M4 3.75, M5 4.7 mm | |
41
+ | 23 | Insert holes, rows IM2, IM3 | Each figure is the hole as drawn. Set an insert in each with the iron. The best goes in straight and flush, pushes no ring of plastic up round it, and does not turn when a screw is tightened in it. `x1c.insert_m2=<figure>`, `x1c.insert_m3=<figure>` (`_petg` from the PETG print) | 3.2 and 4.0 mm, the insert maker's | |
42
+ | 24 | Nut pockets, rows NM3, NM4 | Each figure is the clearance across the flats. Press a nut in with a thumb, then drive a screw into it from the top. The best is the tightest the nut goes into by hand and does not turn in as the screw is driven. `x1c.nut_fit=<figure>` | 0 mm (a snug fit) | |
43
+ | 25 | Nut slots, rows TM3 and TM4 (the back edge) | Each figure is the clearance across the flats. Drop a nut into the slot from the top, then run a screw in from the coupon's back edge through it and tighten. The best is the tightest the nut drops into by hand, that keeps it when the coupon is turned over, and where it does not turn as the screw tightens. `x1c.nut_slip=<figure>` | 0.1 mm (`x1c.slip`) | |
44
+ | 26 | Counterbore, CM3 | Drive an M3 × 8 cap screw in: its head sits wholly under the top face, a hex key reaches it, and it tightens in the pilot under it. If the head rubs, raise `x1c.fit` | `x1c.fit` 0.2 mm each side | |
45
+ | 27 | Printed threads, rows M6P, M8P, M10P | Each figure is the gap on the radius between the printed thread and a bought bolt. Turn a bolt into each by hand. The best is the tightest it turns all the way into smoothly, with no binding and no wobble, and that does not strip when tightened firmly with a spanner. Where the sizes differ, take the figure two of the three agree on. `x1c.thread_gap=<figure>` | 0.2 mm, an estimate | |
46
+ | 28 | Thread flanks, M8P against M8S | Rows M8P and M8S are the same holes in the two forms a printed thread can take: P has its down-facing flanks laid back to 45° (the kit's default, easy to print, about 51% of the standard's flank overlap at 0.2 mm), S keeps the standard's 60° form (more overlap, 63%, but its down-facing flanks overhang 60°). Compare them at each gap, in this order: it holds (tighten a bolt firmly with a spanner: no stripping, the least wobble), it turns smoothly (no catching all the way in), it prints clean (look into the hole with a light: whole teeth, no drooping or strings on the flanks' undersides). The form that wins the first test wins, and the next test settles a tie. Write 45 for P or 60 for S: `x1c.thread_flank=45`. It records the result; changing the kit's default form is a decision of its own | 45, the printed form | |
47
+ | 29 | Tongues, slot 6 and slot 8 | Each tongue's figure is its clearance a side in the beam's opening. Lay the head on the beam's face with the tongue in the slot and push it the beam's length from the square end. The best is the tightest that slides all the way by hand, and does not rattle when the beam is shaken across. `cad measured x1c.slot_fit=<figure>` | 0.2 mm a side (`x1c.fit`, community) | |
48
+ | 30 | Carriers, slot 6 (M2.5) and slot 8 (M5) | Each carrier's figure is its clearance a side all round the slot. Drop its nut into its side (or its end), slide it into the beam from the square end, and run a screw into it through a scrap of plate. The best is the tightest that slides the beam's length by hand, nut in, and that pulls up square when the screw is tightened. Where it is looser than the tongue in 29, write the carrier's figure to `x1c.slot_fit` instead: a part that fills the slot needs the larger | 0.2 mm a side | |
49
+ | 31 | Printed slots, slot 6 and slot 8 | Each block's figure is how far its printed slot is opened a side. Slide a bought slot nut for your beam down each from the top. The best is the tightest it runs the length of by hand without catching, and that holds it upright when the block is tipped on its side. `x1c.printed_slot_fit=<figure>` | 0.2 mm a side | |
50
+ | 32 | The slot itself, by caliper | On the beam's square end: the opening across the face, the lips' thickness, the cavity's width under the lips and its depth from the face (the depth rod of the calipers). Write each to the slot set your beam's profile names, or to `slot-6` or `slot-8` for an unbranded beam: `cad measured slot-8.opening=<mm> slot-8.lip_thickness=<mm> slot-8.cavity_width=<mm> slot-8.cavity_depth=<mm>`. They go in your workspace's copy of the set as measured, and cad refuses figures that make no slot | slot 6: opening 6, lips 1.5, cavity 12 wide, 5.5 deep. Slot 8: 8, 2.2, 16.5, 9 (community figures) | |
51
+ | 33 | The fit, confirmed | With 29 to 32 written back, print again the carrier whose figure you wrote to `x1c.slot_fit`: `cad export coupons/slot-coupon --part slot-8-carrier-<figure>` (or `slot-6-`). It is now drawn from your measured slot. It should slide as that carrier did in 30; a design's own carriers take the same fit with `printer: v.x1c` | | |
52
+ | 40 | Snap pins' barb, the six loose snap pins | Each pin has one, two or three notches down its foot: barb 0.3, 0.4 and 0.5 mm past its peg. Hold the plate over the table's edge so a barb can come out underneath, push each 4 mm pin from the top through the middle socket of row S4, and pull it back by its foot; then the 3 mm pins in S3. The best is the deepest barb that still clicks through by hand and holds when pulled firmly. `cad measured x1c.snap_barb=<figure>`. It records the result: pins are still drawn with a 0.4 mm barb unless their name says another (`snap pin 4x6 barb 0.5`) | 0.4 mm | |
53
+ | 41 | Snap pin sockets, rows S3 and S4 | Each figure is the gap round the peg, each side, as drawn. Push the pin that won 40 through each socket of its row. The best is the tightest it clicks through by hand, and that does not rock once through. `x1c.snap_clearance=<figure>` | 0.05 mm, measured on the launcher's fit test plate with 4 mm pins (this row's tightest socket is 0.1) | |
54
+ | 42 | Pins pressed, rows D3P and FP | Each figure is how much smaller the hole is drawn than the pin, past the hole compensation. Press a 3 × 12 mm dowel into each hole of D3P by hand or in a vice, and a 12 mm length of filament into each of FP. The best goes in straight without splitting its boss and cannot be pulled out by hand. Where the two rows differ, write the dowel's. `x1c.pin_press=<figure>` | 0.05 mm, an estimate | |
55
+ | 43 | Pins slipping, rows D3S and FS | Each figure is how much larger the hole is drawn than the pin, past the hole compensation. Slide a dowel into each hole of D3S by hand and turn it, then a length of filament in FS. The best is the tightest it slides into and turns freely in, without rattling. `x1c.pin_slip=<figure>` | 0.2 mm, an estimate | |
56
+ | 44 | Magnet pockets, rows 6x3 and 8x3 | Each figure is how much smaller the pocket is drawn than the magnet, past the hole compensation. Press a magnet into each with a thumb, or in a vice between two scraps of wood. The best goes in flush without splitting the wall, and stays in when the plate is turned over and tapped on the table. Push each out again with a length of filament through the hole under it. `x1c.magnet_press=<figure>`. The glued fit is not printed here: keep `x1c.magnet_glue` unless a glued magnet will not go in, and then raise it by 0.1 | 0.1 mm, an estimate. The kit warns that it stretches a pocket's wall close to PLA's strength (24.6 MPa for 8 × 3, 32.8 MPa for 6 × 3, against 39) | |
57
+ | 45 | Crush ribs, row 8x3R | Each figure is how far inside the magnet the ribs' tips stand, past the hole compensation. Press an 8 × 3 magnet into each by hand. The best goes in flush by hand and holds when the plate is turned over and tapped. `x1c.magnet_crush=<figure>` | 0.2 mm, an estimate | |
58
+ | 46 | Printed bolts in printed nuts, rows M8N and M10N, and the six loose bolts | Each figure is the thread gap on the radius, half of it drawn in the nut and half in the bolt; each loose bolt has one, two or three notches down its head for the first, second and third figure of its row. Turn each bolt through its own nut by hand. The best is the tightest that turns all the way through smoothly, without binding or wobble, and does not strip when tightened firmly by hand on its head (a printed thread takes no spanner). This is a second reading of the gap in 27: the kit draws a printed pair from the same `x1c.thread_gap`. Where the two differ, write the larger, so both turn | 0.2 mm, an estimate | |
59
+ | 47 | A printed bolt's strength across its layers, the pull bolt | Last. Clamp two blocks of wood to the table, 10 mm apart and standing past its edge. The blocks are no more than 20 mm thick, an 18 mm plywood offcut for instance, so the nut reaches the thread with the waist hanging below them. Push the pull bolt up through the gap from below, put an M8 washer and a steel M8 nut on its thread, and run the nut down finger tight: the whole waist and both its cones hang below the blocks. Tie a loop of cord round the waist above the head, hook the luggage scale in it and pull straight down, slowly, until the waist breaks. The scale's peak in kilograms, times 9.81, over the waist's 9.62 mm² (3.5 mm across), is the strength in MPa: kilograms × 1.02. `cad measured pla.strength_z=<MPa>` (from the PETG print, `petg.strength_z`). Wear glasses | 38.2 kg (PLA's 39 MPa along its layers: its data sheet gives no figure across them); 22.6 kg for PETG (23 MPa) | |
60
+
61
+ The fixings coupon (22 to 28) is one plate with a figure beside every feature, and each row named on its left: a
62
+ pilot row by its thread (M4), then I for insert holes, N for nut pockets, T for nut slots, C for the counterbore,
63
+ and a printed thread by its size and form (M8P, M8S). The figure beside a feature is the one to write back. Print it
64
+ once in PLA and once in PETG, both upright as it is drawn. A pilot or an insert hole is written per plastic: the PLA
65
+ figure without a suffix, the PETG one with `_petg`. The nut fits, the thread gap and the flank form are one figure per
66
+ printer: write the PLA figure, and note the PETG one in the last column where it differs. `cad history`
67
+ then shows each against what the kit drew before.
68
+
69
+ The holds coupon (40 to 47) measures what holds two parts together without a steel screw. It prints beside the fixings
70
+ coupon, on the same plate: a plate with a row for each fit, named on its left, and 13 loose pieces. S3 and S4 are
71
+ sockets for 3 and 4 mm snap pins, their figure the gap round the peg; D3P and FP are holes a 3 mm dowel or 1.75 mm
72
+ filament is pressed into, D3S and FS holes it turns in; 6x3 and 8x3 are pockets disc magnets are pressed into, 8x3R a
73
+ pocket with three crush ribs; M8N and M10N are printed nuts, a hex nut's height, for printed bolts. The loose pieces are
74
+ the six printed bolts for those nuts, the pull bolt with its waist, and six snap pins, three of each size. The pull
75
+ bolt prints standing on its 13 mm head, as drawn, so its waist breaks across its layers: lying down it would break
76
+ along them and measure the strength the data sheet already gives. Its waist is 3.5 mm across and 3.5 mm long, under
77
+ 38 mm of shank and thread: a sideways push of 1 N at its tip as the nozzle passes stresses the waist about 9.9 MPa
78
+ and sways the tip about 0.46 mm (beam bending, an estimate), where a 3 mm waist 6 mm long took 16 MPa and 1 mm. The
79
+ X1C's bed moves only up and down, so nothing shakes it sideways. If it wobbles or snaps all the same, print it alone,
80
+ after the plate, slowed for cooling as the slicer does for a small layer. A loose piece
81
+ says its figure by notches: one, two or three, for the first, second and third figure of its row. The snap sockets go
82
+ through the plate, and each magnet pocket has a hole under it to push the magnet out, so its first layer has a few
83
+ round holes; everything else stands on a plain first layer. Every feature is drawn from the printer's rules through
84
+ @rulecad/fixings, at the kit's figure and a step either side, so the coupon printed again after cad measured is centred
85
+ on yours. The fits are one figure per printer: write the PLA figure, and note the PETG one where it differs. The pull
86
+ bolt measures the plastic, so it is written per plastic. `cad measured` refuses a figure no fit of its kind can be, and
87
+ a strength across the layers above the plastic's strength along them. `cad history` then shows
88
+ each against what the kit drew before.
89
+
90
+ The slot coupon (29 to 33) is 26 loose pieces, each with its figure, the clearance a side, on top: in the front row
91
+ five tongues for slot 6 and five for slot 8 (a T-shaped key, its head on the face and its tongue in the opening), in
92
+ the middle row five carriers for each (a block that slides in the slot holding a hex nut), and at the back three short
93
+ printed slots for each, standing on end. The slot 8 pieces are the larger. Slot 6 is the slot of 20 mm beams, slot 8
94
+ of 30 and 40 mm beams. Every piece is drawn from the slot's rule set, so once 32 is written back the coupon prints from
95
+ your own slot. `cad history` then shows each figure against what the kit drew before.
96
+
97
+ ## Sending your figures to the kit
98
+
99
+ `cad measured --export` prints every figure measured in this workspace that the kit does not hold yet, as a change to
100
+ the kit's own rule sets (a diff, the form a pull request takes). Save it (`npx cad measured --export > measured.diff`)
101
+ and send it to the kit, with the printer, the plastic and the spool you printed with: open an issue at
102
+ https://github.com/JoniBach/rulecad/issues and attach the file, or apply it to a copy of the repository and open a pull
103
+ request. Measurements from many printers are how the kit's estimates become figures people can trust.
104
+
105
+ ## Words used
106
+
107
+ **Pilot:** a hole sized for a screw to cut its own thread. **Heat-set insert:** a threaded brass sleeve melted into a
108
+ hole. **Hole compensation:** how much smaller a printed hole comes out than it was drawn. **Slot nut:** a nut made to
109
+ slide or drop into an aluminium beam's slot.
@@ -0,0 +1,20 @@
1
+ {
2
+ "title": "Fixings coupons",
3
+ "kind": "fit",
4
+ "description": "The fixings coupon and, behind it on the same plate, the holds coupon: write each result back with cad measured <rule>=<value> (MEASURE.md, rows 22 to 28 and 40 to 47), and cad history keeps it against what the kit drew before. Both fit the X1C's 256 mm bed together, about 195 by 194 mm: the holds coupon 195.3 by 76.8 mm, placed 117 mm behind the fixings coupon's front edge, and the fixings coupon 98.6 by 111.8 mm.",
5
+ "items": [
6
+ {
7
+ "id": "coupon",
8
+ "object": "fixings-coupon"
9
+ },
10
+ {
11
+ "id": "holds",
12
+ "object": "holds-coupon",
13
+ "at": [
14
+ 0,
15
+ 117,
16
+ 0
17
+ ]
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "title": "Slot coupon",
3
+ "kind": "fit",
4
+ "description": "The slot coupon on its own: write each result back with cad measured <rule>=<value> (MEASURE.md, rows 29 to 33), and cad history keeps it against what the kit drew before.",
5
+ "items": [
6
+ {
7
+ "id": "coupon",
8
+ "object": "slot-coupon"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,88 @@
1
+ // The fixings coupon: every hole a screw, a nut or an insert needs, at sizes either side of the one the kit draws, so
2
+ // one print settles them for this printer and plastic. Each feature stands in its own boss on a thin base, and every
3
+ // hole ends above the base (the nut slots' screws come in from an edge, lying down, with a teardrop's roof), so the
4
+ // first layer is one plain rectangle and nothing needs a support. Each row is named on the left, and each feature
5
+ // carries the figure to write back (MEASURE.md, rows 22 to 28).
6
+ // Every size comes from v.fixings; each row steps by the printer's hole compensation either side of it.
7
+ import jscad from '@jscad/modeling'
8
+ const { cylinder, cylinderElliptic, roundedRectangle, circle } = jscad.primitives
9
+ const { extrudeLinear } = jscad.extrusions
10
+ const { translate } = jscad.transforms
11
+ const { hull } = jscad.hulls
12
+ const { offset } = jscad.expansions
13
+ const { measureBoundingBox } = jscad.measurements
14
+
15
+ export function main (v) {
16
+ const f = v.fixings, base = v.base, wall = v.wall, step = v.step, seg = v.segments
17
+ const fig = (x) => String(Number(x.toFixed(2))) // a figure as it is labelled and written back
18
+ const around = (centre, n) => Array.from({ length: n }, (_, i) => centre + (i - (n - 1) / 2) * step)
19
+ const width = (text) => { const [lo, hi] = measureBoundingBox(v.shapes.text({ text, height: v.label, stroke: v.stroke })); return hi[0] - lo[0] }
20
+ const say = (text, x, y, z) => translate([x, y, z], extrudeLinear({ height: v.emboss }, v.shapes.text({ text, height: v.label, stroke: v.stroke })))
21
+ // A plain round hole going down from the top, with the lead-in the kit gives a blind hole, its cutter past the top
22
+ const bore = (d, depth, lead, x, y, top) => v.ops.union(
23
+ translate([x, y, top - depth / 2 + 1 / 2], cylinder({ radius: d / 2, height: depth + 1, segments: seg })),
24
+ translate([x, y, top - lead / 2], cylinderElliptic({ height: lead, startRadius: [d / 2, d / 2], endRadius: [d / 2 + lead, d / 2 + lead], segments: seg })))
25
+ // What a feature stands in, its outline rising from the bed to its top, flared at 45° where it meets the base
26
+ const stand = (outline, top) => v.ops.union(extrudeLinear({ height: top }, outline),
27
+ hull(extrudeLinear({ height: base }, offset({ delta: v.root, corners: 'round', segments: seg }, outline)), extrudeLinear({ height: base + v.root }, outline)))
28
+
29
+ // ---------- the features, each { label, across (its footprint, along the row), deep (across it), top, make(x, y) } ----------
30
+ const round = (across, top, cut) => ({ across, deep: across, top, make: (x, y) => ({ solid: stand(circle({ radius: across / 2, center: [x, y], segments: seg }), top), cut: cut(x, y) }) })
31
+ const pilots = (t) => {
32
+ const h = f.holeModel(t, { kind: 'pilot' }), sizes = around(h.diameter, v.pilots)
33
+ return { name: t, items: sizes.map((d) => ({ label: fig(d), ...round(Math.max(...sizes) + 2 * wall, base + h.depth, (x, y) => bore(d, h.depth, h.lead, x, y, base + h.depth)) })) }
34
+ }
35
+ const inserts = (t) => {
36
+ const h = f.holeModel(t, { kind: 'insert' }), sizes = around(h.diameter, v.fits), least = f.fixingModel(t).figures.insert_wall.value
37
+ return { name: `I${t}`, items: sizes.map((d) => ({ label: fig(d), ...round(Math.max(...sizes) + 2 * Math.max(wall, least), base + h.depth, (x, y) => bore(d, h.depth, h.lead, x, y, base + h.depth)) })) }
38
+ }
39
+ // A nut pocket from the top over the screw's clearance hole, as deep again below it so the screw's end passes the nut
40
+ const pockets = (t) => {
41
+ const p = f.nutPocketModel(t), fits = around(p.clearance, v.fits), corner = f.nutPocketModel(t, { fit: Math.max(...fits) }).corner, top = base + 2 * p.depth
42
+ return { name: `N${t}`, items: fits.map((fit) => ({ label: fig(fit), ...round(corner + 2 * wall, top, (x, y) => v.ops.union(f.nutPocket(t, { fit, at: [x, y, top], into: '-z' }), f.hole(t, { depth: top - base, through: false, at: [x, y, top] }))) })) }
43
+ }
44
+ // A cap head's counterbore over its clearance hole, then a pilot: a screw as long as the two seats its head
45
+ const counterbore = (t) => {
46
+ const c = f.counterboreModel(t), p = f.holeModel(t, { kind: 'pilot' }), length = 2 * c.depth, top = base + p.depth + length
47
+ return { name: `C${t}`, items: [{ label: fig(c.diameter), ...round(c.diameter + 2 * wall, top, (x, y) => v.ops.union(f.counterbore(t, { length, at: [x, y, top], into: '-z' }), f.hole(t, { kind: 'pilot', at: [x, y, top - length] }))) }] }
48
+ }
49
+ // A nut slot the nut drops into from the top, across a screw lying along y: the screw comes in through the coupon's
50
+ // back edge, through the nut, and on into the block for its end
51
+ const traps = (t) => {
52
+ const m = f.nutTrapModel(t, { depth: 1, axis: 'y', into: '-z' }), fits = around(m.clearance, v.fits), widest = f.nutTrapModel(t, { depth: 1, axis: 'y', into: '-z', fit: Math.max(...fits) })
53
+ const half = widest.reach - 1, depth = half + wall, axisZ = base + wall + half, top = axisZ + depth, deep = 2 * (wall + m.gap), across = widest.width + 2 * wall
54
+ return { name: `T${t}`, edge: true, items: fits.map((fit) => ({ label: fig(fit), across, deep, top, make: (x, y) => {
55
+ const face = y + deep / 2, slot = face - wall - m.gap / 2 // y is the block's middle; its open face is on the back edge
56
+ return { solid: stand(roundedRectangle({ size: [across, deep], center: [x, y], roundRadius: wall / 2, segments: seg }), top),
57
+ cut: v.ops.union(f.nutTrap(t, { fit, depth, axis: 'y', into: '-z', at: [x, slot, top] }), f.hole(t, { depth: deep - wall, through: false, at: [x, face, axisZ], into: '-y' })) }
58
+ } })) }
59
+ }
60
+ // A printed thread for a bought screw, at three gaps, in the form its flanks are drawn
61
+ const threads = (t, flanks) => {
62
+ const gaps = around(f.holeModel(t, { kind: 'thread', mate: 'bought', flanks }).threaded.clearance, v.fits)
63
+ const made = gaps.map((gap) => f.holeModel(t, { kind: 'thread', mate: 'bought', gap, flanks })), across = Math.max(...made.map((h) => h.diameter)) + 2 * wall
64
+ return { name: `${t}${flanks === 'standard' ? 'S' : 'P'}`, items: gaps.map((gap, i) => ({ label: fig(gap), ...round(across, base + made[i].depth, (x, y) => f.hole(t, { kind: 'thread', mate: 'bought', gap, flanks, at: [x, y, base + made[i].depth] })) })) }
65
+ }
66
+
67
+ // ---------- the rows, front to back ----------
68
+ const rows = [[pockets('M3'), pockets('M4')], [pilots('M2'), pilots('M2.5')], [pilots('M3'), inserts('M2')], [pilots('M4'), inserts('M3')], [pilots('M5'), counterbore('M3')],
69
+ [threads('M6', 'printed'), threads('M10', 'printed')], [threads('M8', 'printed'), threads('M8', 'standard')], [traps('M3'), traps('M4')]]
70
+ const solids = [], cuts = [], labels = []
71
+ let y = v.gap, length = 0
72
+ for (const row of rows) {
73
+ const deep = Math.max(...row.flatMap((g) => g.items.map((it) => it.deep))), line = y + v.label / 2, mid = y + v.label + v.gap + deep / 2
74
+ let x = v.gap
75
+ for (const g of row) {
76
+ const nameWidth = width(g.name)
77
+ labels.push(say(g.name, x + nameWidth / 2, mid, base)); x += nameWidth + v.gap
78
+ for (const it of g.items) {
79
+ const pitch = Math.max(it.across, width(it.label) + v.gap), cx = x + pitch / 2, cy = g.edge ? mid + deep / 2 - it.deep / 2 : mid, m = it.make(cx, cy)
80
+ solids.push(m.solid); cuts.push(m.cut); labels.push(say(it.label, cx, line, base)); x += pitch + v.gap
81
+ }
82
+ x += v.gap
83
+ }
84
+ length = Math.max(length, x); y += deep + v.label + v.gap * 2
85
+ }
86
+ const plate = extrudeLinear({ height: base }, roundedRectangle({ size: [length, y], center: [length / 2, y / 2], roundRadius: v.corner, segments: seg }))
87
+ return v.ops.union(v.ops.subtract(v.ops.union(plate, ...solids), ...cuts), ...labels)
88
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
3
+ "name": "fixings-coupon",
4
+ "title": "Fixings coupon",
5
+ "version": "0.1.0",
6
+ "uses": [
7
+ "x1c"
8
+ ],
9
+ "engine": "manifold",
10
+ "orientation": "Flat on the bed, every hole opening upward: the base is the first layer",
11
+ "description": "Pilots for M2 to M5 at five sizes, heat-set insert holes for M2 and M3, hex nut pockets and side slots for M3 and M4 at three fits, an M3 counterbore, and printed M6, M8 and M10 threads at three gaps, M8 in both flank forms. Each figure is the one to write back with cad measured (MEASURE.md, rows 22 to 28). Print once per printer and plastic.",
12
+ "variables": {
13
+ "base": { "value": "x1c.layer * 6", "unit": "mm", "rule": "The base every feature stands on: six layers, the floor under every blind hole, and a first layer that is one plain rectangle" },
14
+ "wall": { "value": "x1c.wall_min * 2", "unit": "mm", "rule": "Plastic round every hole, pocket and slot: four print lines, as a design gives a boss" },
15
+ "gap": { "value": "x1c.wall_min", "unit": "mm", "rule": "Between features, between a feature and its figure, and round the edge" },
16
+ "root": { "value": "x1c.chamfer", "unit": "mm", "rule": "The 45° flare where each boss meets the base, so no inside corner is square" },
17
+ "step": { "value": "x1c.hole_comp", "unit": "mm", "rule": "Each row steps by the printer's hole compensation either side of what the kit draws: the amount a printed hole comes out wrong by" },
18
+ "pilots": { "value": 5, "rule": "Five pilots for each thread: the kit's figure and two steps either side" },
19
+ "fits": { "value": 3, "rule": "Three of every other feature: the kit's figure and a step either side" },
20
+ "label": { "value": 2.5, "unit": "mm", "rule": "Figure height: six print lines tall, readable close up, and small enough that a figure is no wider than its feature" },
21
+ "stroke": { "value": "x1c.line", "unit": "mm", "rule": "One print line, for the figures" },
22
+ "emboss": { "value": "x1c.layer * 2", "unit": "mm", "rule": "Two layers proud" },
23
+ "corner": { "value": 3, "unit": "mm", "rule": "The base's corners, rounded so they stay down" },
24
+ "segments": { "value": 48, "rule": "Facets on round holes and bosses" }
25
+ }
26
+ }
@@ -0,0 +1,130 @@
1
+ // The holds coupon, the fixings coupon's second plate: what holds two parts together without a screw of steel. A plate
2
+ // with a row for each fit, at sizes either side of the one the kit draws: snap pin sockets (S3, S4), holes for a 3 mm
3
+ // steel dowel and for 1.75 mm filament, pressed (D3P, FP) and slipping (D3S, FS), pockets for 6x3 and 8x3 disc magnets
4
+ // pressed in (6x3, 8x3) and held by crush ribs (8x3R), and printed nuts for printed M8 and M10 bolts (M8N, M10N). Beside
5
+ // it, loose: the printed bolts for those nuts, one for each thread gap, a pull bolt to break, and snap pins at three barb
6
+ // depths for each socket row. Every size comes from v.fixings and the printer's rules, so the coupon prints round the
7
+ // figures the kit draws today, and again round yours once they are measured (MEASURE.md, rows 40 to 47).
8
+ // The plate's first layer is one rectangle with a few round holes (the sockets go through it, and each magnet pocket has
9
+ // a hole under it to push the magnet out); every loose piece stands on a plain round or hexagonal foot. Nothing needs a support.
10
+ import jscad from '@jscad/modeling'
11
+ const { cylinder, cylinderElliptic, roundedRectangle, circle, polygon } = jscad.primitives
12
+ const { extrudeLinear, extrudeRotate } = jscad.extrusions
13
+ const { translate } = jscad.transforms
14
+ const { hull } = jscad.hulls
15
+ const { offset } = jscad.expansions
16
+ const { measureBoundingBox } = jscad.measurements
17
+
18
+ export function main (v) {
19
+ const f = v.fixings, base = v.base, wall = v.wall, seg = v.segments
20
+ const fig = (x) => String(Number(x.toFixed(2))) // a figure as it is labelled and written back
21
+ const around = (centre, n, step) => Array.from({ length: n }, (_, i) => Number((centre + (i - (n - 1) / 2) * step).toFixed(v.places)))
22
+ const width = (text) => { const [lo, hi] = measureBoundingBox(v.shapes.text({ text, height: v.label, stroke: v.stroke })); return hi[0] - lo[0] }
23
+ const say = (text, x, y, z) => translate([x, y, z], extrudeLinear({ height: v.emboss }, v.shapes.text({ text, height: v.label, stroke: v.stroke })))
24
+ // the printer as plain values with one figure changed: each feature in a row is drawn as if the printer's rule were its figure
25
+ const printer = (k, x) => ({ ...v.x1c, [k]: x })
26
+ // A feature's stand, its outline rising from the bed to its top, flared at 45° where it meets the base
27
+ const stand = (outline, top) => v.ops.union(extrudeLinear({ height: top }, outline),
28
+ hull(extrudeLinear({ height: base }, offset({ delta: v.root, corners: 'round', segments: seg }, outline)), extrudeLinear({ height: base + v.root }, outline)))
29
+ const round = (across, top, cut) => ({ across, deep: across, top, make: (x, y) => ({ solid: stand(circle({ radius: across / 2, center: [x, y], segments: seg }), top), cut: cut(x, y) }) })
30
+ // A hole down through everything at (x, y): under a magnet's pocket, to push the magnet out with a pin
31
+ const through = (d, x, y, top) => translate([x, y, top / 2], cylinder({ radius: d / 2, height: top + 2, segments: seg }))
32
+
33
+ // ---------- the plate's rows ----------
34
+ // Snap pin sockets: a hole through a boss as thick as the pin's shaft is long, at three clearances round the kit's.
35
+ // The lowest stays a step above 0: a socket's gap has no hole compensation, so at 0 it prints smaller than its peg
36
+ const sockets = (d) => {
37
+ const name = `snap pin ${d}x${v.shaft}`, c0 = f.pinModel(name).hole.clearance / 2, cs = around(Math.max(c0, (v.step * (v.fits + 1)) / 2), v.fits, v.step)
38
+ return { name: `S${d}`, items: cs.map((c) => ({ label: fig(c), ...round(d + 2 * Math.max(...cs) + 2 * wall, v.shaft, (x, y) => f.pinHole(name, { printer: printer('snap_clearance', c), at: [x, y, v.shaft], depth: v.shaft, through: true })) })) }
39
+ }
40
+ // Plain pins: blind holes from the top, pressed (the figure is how much smaller than the pin, before hole_comp) or slipping
41
+ const pins = (pin, label, fit) => {
42
+ const key = fit === 'press' ? 'pin_press' : 'pin_slip', c0 = f.pinModel(pin, { fit }).hole.clearance, x0 = fit === 'press' ? -c0 : c0
43
+ const xs = around(x0, v.fits, fit === 'press' ? v.press_step : v.step), d = f.pinModel(pin, { fit: 'slip', printer: printer('pin_slip', Math.max(...xs)) }).hole.diameter, top = base + v.pin_depth
44
+ return { name: label, items: xs.map((x) => ({ label: fig(x), ...round(d + 2 * wall, top, (cx, cy) => f.pinHole(pin, { fit, printer: printer(key, x), at: [cx, cy, top], depth: v.pin_depth })) })) }
45
+ }
46
+ // Magnet pockets: as deep as the magnet, with the kit's lead-in at the mouth, the plate's base under it and a push-out
47
+ // hole through that. A press pocket is the magnet less the figure, past hole_comp; a ribbed pocket is the kit's glue
48
+ // pocket with three crush ribs whose tips stand the figure inside the magnet. The kit's seat is read once for the
49
+ // figures it draws from (a press either side of the kit's is a test piece, not a design: fixings would rightly fail it),
50
+ // and the pockets are cut with the design's own booleans
51
+ const bore = (d, depth, lead, x, y, top) => v.ops.union(
52
+ translate([x, y, top - depth / 2 + 1 / 2], cylinder({ radius: d / 2, height: depth + 1, segments: seg })),
53
+ translate([x, y, top - lead / 2], cylinderElliptic({ height: lead, startRadius: [d / 2, d / 2], endRadius: [d / 2 + lead, d / 2 + lead], segments: seg })))
54
+ const ribbed = (q, x, y, top) => v.ops.subtract(bore(q.diameter, q.depth, q.lead, x, y, top), ...Array.from({ length: q.ribs.count }, (_, i) => {
55
+ const t = (2 * Math.PI * i) / q.ribs.count + Math.PI / 2, out = q.diameter / 2 + q.ribs.radius - q.ribs.protrude, low = top - q.depth - 1, high = top - q.lead
56
+ return translate([x + out * Math.cos(t), y + out * Math.sin(t), (low + high) / 2], cylinder({ radius: q.ribs.radius, height: high - low, segments: seg / 2 }))
57
+ }))
58
+ const magnets = (size, label, fit) => {
59
+ const name = `disc magnet ${size}`, key = fit === 'press' ? 'magnet_press' : 'magnet_crush', s0 = f.magnetSeatModel(name, { fit }), q0 = s0.pocket
60
+ const x0 = fit === 'press' ? -q0.clearance : s0.rests.find((r) => r.name.endsWith(key)).value, xs = around(x0, v.fits, v.step)
61
+ const top = base + q0.depth, across = q0.nominal[0] + q0.comp + 2 * q0.lead + 2 * wall
62
+ return { name: label, items: xs.map((x) => ({ label: fig(x), ...round(across, top, (cx, cy) => v.ops.union(fit === 'press' ? bore(q0.nominal[0] + q0.comp - x, q0.depth, q0.lead, cx, cy, top)
63
+ : ribbed(f.magnetSeatModel(name, { fit, printer: printer(key, x) }).pocket, cx, cy, top), through(v.push, cx, cy, top))) })) }
64
+ }
65
+ // Printed nuts for printed bolts: a boss a hex nut's height tall (rounded up to whole layers), a thread through it and
66
+ // the plate drawn half the gap off its basic profile (the bolt takes the other half), as deep as printedBoltModel
67
+ // takes a nut's thread to be when it works out the bolt's strength
68
+ const nuts = (t) => {
69
+ const g0 = f.holeModel(t, { kind: 'thread', mate: 'printed' }).threaded.clearance, gaps = around(g0, v.fits, v.step), high = Math.ceil(f.nutModel(t).height / v.x1c.layer - v.tiny) * v.x1c.layer
70
+ const made = gaps.map((gap) => f.holeModel(t, { kind: 'thread', mate: 'printed', gap, depth: high, through: true })), across = Math.max(...made.map((h) => h.diameter)) + 2 * wall
71
+ return { name: `${t}N`, items: gaps.map((gap) => ({ label: fig(gap), ...round(across, high, (x, y) => f.hole(t, { kind: 'thread', mate: 'printed', gap, depth: high, through: true, at: [x, y, high] })) })), gaps, high }
72
+ }
73
+
74
+
75
+ const n8 = nuts('M8'), n10 = nuts('M10')
76
+ const rows = [[sockets(v.small_pin), sockets(v.large_pin), pins('dowel 3x12', 'D3P', 'press')],
77
+ [pins('filament pin 1.75x12', 'FP', 'press'), pins('filament pin 1.75x12', 'FS', 'slip'), pins('dowel 3x12', 'D3S', 'slip')],
78
+ [magnets('6x3', '6x3', 'press'), magnets('8x3', '8x3', 'press'), magnets('8x3', '8x3R', 'ribs')], [n8, n10]]
79
+ const solids = [], cuts = [], labels = []
80
+ let y = v.gap, length = 0
81
+ for (const row of rows) {
82
+ const deep = Math.max(...row.flatMap((g) => g.items.map((it) => it.deep))), line = y + v.label / 2, mid = y + v.label + v.gap + deep / 2
83
+ let x = v.gap
84
+ for (const g of row) {
85
+ const nameWidth = width(g.name)
86
+ labels.push(say(g.name, x + nameWidth / 2, mid, base)); x += nameWidth + v.gap
87
+ for (const it of g.items) {
88
+ const pitch = Math.max(it.across, width(it.label) + v.gap), cx = x + pitch / 2, m = it.make(cx, mid)
89
+ solids.push(m.solid); cuts.push(m.cut); labels.push(say(it.label, cx, line, base)); x += pitch + v.gap
90
+ }
91
+ x += v.gap
92
+ }
93
+ length = Math.max(length, x); y += deep + v.label + v.gap * 2
94
+ }
95
+ const plate = extrudeLinear({ height: base }, roundedRectangle({ size: [length, y], center: [length / 2, y / 2], roundRadius: v.corner, segments: seg }))
96
+ const out = { plate: v.ops.union(v.ops.subtract(v.ops.union(plate, ...solids), ...cuts), ...labels) }
97
+
98
+ // ---------- the loose pieces, in a row behind the plate ----------
99
+ // Marks: one, two or three notches down the side of a bolt's head or a pin's foot, for the first, second and third figure
100
+ const turn = (v.notch_turn * Math.PI) / v.half_turn
101
+ const notches = (count, radius, height) => Array.from({ length: count }, (_, i) => cylinder({ radius: v.notch, height: 2 * height, center: [radius * Math.cos(i * turn), radius * Math.sin(i * turn), 0], segments: seg / 2 }))
102
+ let x = v.gap, deep = 0
103
+ const place = (name, solid, across) => { out[name] = translate([x + across / 2, y + v.gap + across / 2, 0], solid); x += across + v.gap * 2; deep = Math.max(deep, across) }
104
+ // Printed bolts standing on their heads, one for each of the nuts' gaps, long enough to go through the nut and on
105
+ for (const [t, n] of [['M8', n8], ['M10', n10]]) {
106
+ n.gaps.forEach((gap, i) => {
107
+ const length = Math.round(n.high * v.engaged), b = f.printedBolt(`${t}x${length} hex printed`, { gap }), across = b.screw.headDiameter
108
+ place(`bolt-${t.toLowerCase()}-${fig(gap)}`, v.ops.subtract(b, ...notches(i + 1, (across / 2) * Math.cos(turn / 2), b.screw.headHeight)), across + v.gap)
109
+ })
110
+ }
111
+ // The pull bolt: an M8 printed bolt for a bought steel nut, its shank turned down to a waist that breaks within the
112
+ // luggage scale's reach. The waist is reached by 45° cones from the shank, so nothing overhangs past the printer's limit
113
+ {
114
+ const b = f.printedBolt(`M8x${v.pull_length} hex printed`, { nut: 'steel' }), k = b.screw.headHeight, R = b.screw.major / 2, r = v.waist / 2, z1 = k + 1, z2 = z1 + (R - r) + v.waist_length + (R - r)
115
+ const keep = extrudeRotate({ segments: seg }, polygon({ points: [[0, z1], [R, z1], [r, z1 + R - r], [r, z2 - (R - r)], [R, z2], [0, z2]] }))
116
+ const ring = v.ops.subtract(translate([0, 0, (z1 + z2) / 2], cylinder({ radius: R + 2, height: z2 - z1, segments: seg })), keep)
117
+ place('pull-bolt', v.ops.subtract(b, ring), b.screw.headDiameter + v.gap)
118
+ }
119
+ // Snap pins standing on their feet, three barb depths for each socket row, the split ending a millimetre above the foot.
120
+ // They are drawn from their plain figures (snapPin, the same solid f.pin draws), not checked as a design's pins are:
121
+ // on a split this short most bend past the strain the kit holds a pin to (pin.strain), and finding which click and
122
+ // which break is what they are printed for
123
+ for (const d of [v.small_pin, v.large_pin]) {
124
+ around(v.barb, v.fits, v.barb_step).forEach((lip, i) => {
125
+ const r = d / 2, rise = r + lip, slot = v.shaft - 1 + lip + rise, p = f.snapPin({ diameter: d, length: v.shaft, lip, slot, head: r }), foot = d * 2
126
+ place(`snap-pin-${d}-${fig(lip)}`, v.ops.subtract(p, ...notches(i + 1, foot / 2, 2)), foot + 2)
127
+ })
128
+ }
129
+ return out
130
+ }