// CADL v1 - editable geometry source for sd/design (JSON + // comments).
// Edit numbers/params and rebuild: web page 'Rebuild', POST /api/build, or: python build.py part.cadl
// prompt: Control knob 30 mm diameter, 15 mm tall, 12 flutes, 6 mm D-shaft hole
// template: knob
// printable: Design for 3D printing was on
{
  "plan": "Round knob, 30 mm across and 15 mm tall, sitting on z=0. 12 straight flutes run the full height so the grooves stay open. D-shaft bore 6 mm through. Print mode: no downward face shallower than 45 degrees from vertical.",
  "issues": [
    {"type": "assumption", "msg": "D-shaft flat was not stated; 1.5 mm cut from the radius.", "ref": "$flat"},
    {"type": "assumption", "msg": "Print mode cuts the D flat through the center of the bore. A shallower flat meets the bore on a hairline edge that does not print cleanly.", "ref": "$flat"}
  ],
  "params": {
    "od": 30,
    "height": 15,
    "bore_d": 6,
    "bore_depth": 0,
    "flat": 3,
    "flutes": 12,
    "flute_d": 0.8,
    "skirt_d": 0,
    "skirt_h": 2.5,
    "setscrew_d": 0,
    "flute_w": "=max(1.35, min(1.6, 3.1416*$od/$flutes/3))"
  },
  "steps": [
    {"id": "body", "op": "revolve", "profile": [[0, 0], ["=$od/2", 0], ["=$od/2", "=$height"], [0, "=$height"]]},
    {"id": "bored", "op": "hole", "target": "body", "face": "top", "positions": [[0, 0]], "diameter": "=$bore_d"},
    {
      "id": "flat",
      "op": "box",
      "size": ["=$flat+1", "=$bore_d+2", "=$height+2"],
      "at": ["=$bore_d/2-$flat/2+0.5", 0, -1]
    },
    {"id": "dshaft", "op": "cut", "target": "bored", "tools": ["flat"]},
    {"id": "fl0", "op": "box", "size": ["=$flute_d+2", "=$flute_w", "=$height"], "at": ["=$od/2-$flute_d/2", 0, 0]},
    {"id": "fl1", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 30, "about": [0, 0, 0]},
    {"id": "fl2", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 60, "about": [0, 0, 0]},
    {"id": "fl3", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 90, "about": [0, 0, 0]},
    {"id": "fl4", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 120, "about": [0, 0, 0]},
    {"id": "fl5", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 150, "about": [0, 0, 0]},
    {"id": "fl6", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 180, "about": [0, 0, 0]},
    {"id": "fl7", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 210, "about": [0, 0, 0]},
    {"id": "fl8", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 240, "about": [0, 0, 0]},
    {"id": "fl9", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 270, "about": [0, 0, 0]},
    {"id": "fl10", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 300, "about": [0, 0, 0]},
    {"id": "fl11", "op": "rotate", "target": "fl0", "axis": "z", "angle_deg": 330, "about": [0, 0, 0]},
    {
      "id": "fluted",
      "op": "cut",
      "target": "dshaft",
      "tools": ["fl0", "fl1", "fl2", "fl3", "fl4", "fl5", "fl6", "fl7", "fl8", "fl9", "fl10", "fl11"]
    }
  ],
  "result": "fluted"
}
