{
 "commands": [
  {
   "command": "parameters.add",
   "params": {
    "name": "bearing_od",
    "expression": "22 mm",
    "comment": "608 bearing outer diameter"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "bearing_w",
    "expression": "7 mm",
    "comment": "608 bearing width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "interference",
    "expression": "0.1 mm",
    "comment": "press-fit interference on diameter"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "bore",
    "expression": "bearing_od - interference",
    "comment": "press-fit seat diameter"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "wall",
    "expression": "6 mm",
    "comment": "radial wall around the bearing"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "housing_d",
    "expression": "bore + 2*wall"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "housing_len",
    "expression": "10 mm",
    "comment": "housing length along axis, > bearing_w (rest is a shoulder)"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "shoulder_d",
    "expression": "16 mm",
    "comment": "through hole behind the seat; between ~13 (inner race) and bore"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "axis_h",
    "expression": "20 mm",
    "comment": "shaft centre height above the bed"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "base_l",
    "expression": "50 mm"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "base_w",
    "expression": "20 mm"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "base_t",
    "expression": "6 mm"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "slot_d",
    "expression": "5.5 mm",
    "comment": "mounting slot width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "slot_len",
    "expression": "12 mm",
    "comment": "overall slot length along Y (adjustment direction)"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "slot_x",
    "expression": "21 mm",
    "comment": "slot centre distance from axis; keep > housing_d/2 + slot_d/2 for head access"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "set_d",
    "expression": "2.5 mm",
    "comment": "set-screw hole (M3 tap drill)"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "base_l",
    "width": "base_w",
    "height": "base_t",
    "center": [
     0,
     0,
     "base_t/2"
    ],
    "name": "Base",
    "body_name": "BearingBlock"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "housing_d",
    "height": "housing_len",
    "base": [
     0,
     "-housing_len/2",
     "axis_h"
    ],
    "axis": "Y",
    "operation": "join",
    "name": "Housing"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "bore",
    "height": "bearing_w + 1",
    "base": [
     0,
     "-housing_len/2 - 1",
     "axis_h"
    ],
    "axis": "Y",
    "operation": "cut",
    "name": "BearingSeat"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "shoulder_d",
    "height": "housing_len + 2",
    "base": [
     0,
     "-housing_len/2 - 1",
     "axis_h"
    ],
    "axis": "Y",
    "operation": "cut",
    "name": "ShaftClearance"
   }
  },
  {
   "command": "sketch.create",
   "params": {
    "plane": "XY",
    "offset": "base_t",
    "name": "SlotSketch"
   }
  },
  {
   "command": "sketch.draw.dimensioned",
   "params": {
    "command": "sketch.slot.overall",
    "params": {
     "p0": [
      21,
      -6
     ],
     "p1": [
      21,
      6
     ],
     "width": 5.5
    },
    "dimensions": {
     "length": "slot_len",
     "width": "slot_d"
    }
   }
  },
  {
   "command": "sketch.dimension",
   "params": {
    "entities": [
     "origin",
     "a1.center"
    ],
    "type": "horizontal",
    "value": "slot_x"
   }
  },
  {
   "command": "sketch.dimension",
   "params": {
    "entities": [
     "origin",
     "a1.center"
    ],
    "type": "vertical",
    "value": "slot_len/2 - slot_d/2"
   }
  },
  {
   "command": "sketch.dimension",
   "params": {
    "entities": [
     "origin",
     "a2.center"
    ],
    "type": "horizontal",
    "value": "slot_x"
   }
  },
  {
   "command": "sketch.finish",
   "params": {}
  },
  {
   "command": "solid.extrude",
   "params": {
    "distance": "base_t + 1",
    "direction": "negative",
    "operation": "cut",
    "name": "Slot"
   }
  },
  {
   "command": "solid.mirror",
   "params": {
    "features": [
     "Slot"
    ],
    "plane": "YZ",
    "combine": true,
    "name": "SlotMirror"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "set_d",
    "height": "wall + 2",
    "base": [
     0,
     "-housing_len/2 + bearing_w/2",
     "axis_h + bore/2 - 1"
    ],
    "axis": "Z",
    "operation": "cut",
    "name": "SetScrew"
   }
  }
 ]
}