{
 "commands": [
  {
   "command": "parameters.add",
   "params": {
    "name": "bl",
    "expression": "68.6 mm",
    "comment": "board length"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "bw",
    "expression": "53.3 mm",
    "comment": "board width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "bt",
    "expression": "1.6 mm",
    "comment": "board thickness"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "comp",
    "expression": "12 mm",
    "comment": "tallest component above board"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "wall",
    "expression": "2 mm",
    "comment": "wall thickness"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "flr",
    "expression": "2 mm",
    "comment": "floor thickness"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "clr",
    "expression": "1.5 mm",
    "comment": "clearance board to wall"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "so",
    "expression": "3 mm",
    "comment": "standoff height (board off floor)"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "so_d",
    "expression": "6 mm",
    "comment": "standoff OD"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "pilot_d",
    "expression": "2.5 mm",
    "comment": "standoff pilot hole for M3 self-tap"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "topgap",
    "expression": "0.5 mm",
    "comment": "air above tallest component"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lip",
    "expression": "5 mm",
    "comment": "lid skirt height"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lip_t",
    "expression": "1.6 mm",
    "comment": "lid skirt thickness"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "fit",
    "expression": "0.2 mm",
    "comment": "skirt-to-wall clearance per side"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lidT",
    "expression": "2 mm",
    "comment": "lid plate thickness"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "bead_r",
    "expression": "0.6 mm",
    "comment": "snap bead radius"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "groove_r",
    "expression": "0.8 mm",
    "comment": "snap groove radius"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "bead_len",
    "expression": "20 mm",
    "comment": "snap bead length"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "usb_w",
    "expression": "12 mm",
    "comment": "USB-B opening width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "usb_h",
    "expression": "11 mm",
    "comment": "USB-B opening height"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "usb_y",
    "expression": "38.1 mm",
    "comment": "USB centre from board edge (power-header side)"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "dc_w",
    "expression": "9 mm",
    "comment": "barrel jack opening width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "dc_h",
    "expression": "11 mm",
    "comment": "barrel opening height"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "dc_y",
    "expression": "7.6 mm",
    "comment": "barrel centre from board edge"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "gap",
    "expression": "10 mm",
    "comment": "print gap base to lid"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Li",
    "expression": "bl + 2*clr",
    "comment": "inner length"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Wi",
    "expression": "bw + 2*clr",
    "comment": "inner width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Lo",
    "expression": "Li + 2*wall",
    "comment": "outer length"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Wo",
    "expression": "Wi + 2*wall",
    "comment": "outer width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "zb",
    "expression": "flr + so",
    "comment": "board underside z"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Hb",
    "expression": "flr + so + bt + comp + topgap + lip",
    "comment": "base height"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lidx",
    "expression": "Lo + gap",
    "comment": "lid centre x"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Lo",
    "width": "Wo",
    "height": "Hb",
    "center": [
     0,
     0,
     "Hb/2"
    ],
    "body_name": "Base",
    "name": "BaseBlock"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Li",
    "width": "Wi",
    "height": "Hb",
    "center": [
     0,
     0,
     "flr + Hb/2"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "Cavity"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "so_d",
    "height": "so + 1",
    "base": [
     "14.0 mm - bl/2",
     "2.5 mm - bw/2",
     "flr - 1"
    ],
    "operation": "join",
    "targets": [
     "Base"
    ],
    "name": "SO1"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "so_d",
    "height": "so + 1",
    "base": [
     "15.3 mm - bl/2",
     "50.7 mm - bw/2",
     "flr - 1"
    ],
    "operation": "join",
    "targets": [
     "Base"
    ],
    "name": "SO2"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "so_d",
    "height": "so + 1",
    "base": [
     "66.1 mm - bl/2",
     "7.6 mm - bw/2",
     "flr - 1"
    ],
    "operation": "join",
    "targets": [
     "Base"
    ],
    "name": "SO3"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "so_d",
    "height": "so + 1",
    "base": [
     "66.1 mm - bl/2",
     "35.5 mm - bw/2",
     "flr - 1"
    ],
    "operation": "join",
    "targets": [
     "Base"
    ],
    "name": "SO4"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "pilot_d",
    "height": "so + 1",
    "base": [
     "14.0 mm - bl/2",
     "2.5 mm - bw/2",
     "flr - 0.5"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "SO1_pilot"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "pilot_d",
    "height": "so + 1",
    "base": [
     "15.3 mm - bl/2",
     "50.7 mm - bw/2",
     "flr - 0.5"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "SO2_pilot"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "pilot_d",
    "height": "so + 1",
    "base": [
     "66.1 mm - bl/2",
     "7.6 mm - bw/2",
     "flr - 0.5"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "SO3_pilot"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "pilot_d",
    "height": "so + 1",
    "base": [
     "66.1 mm - bl/2",
     "35.5 mm - bw/2",
     "flr - 0.5"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "SO4_pilot"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "wall + 2",
    "width": "usb_w",
    "height": "usb_h",
    "center": [
     "-Lo/2 + wall/2",
     "usb_y - bw/2",
     "zb + bt + usb_h/2"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "USBOpening"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "wall + 2",
    "width": "dc_w",
    "height": "dc_h",
    "center": [
     "-Lo/2 + wall/2",
     "dc_y - bw/2",
     "zb + bt + dc_h/2"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "DCOpening"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "radius": "groove_r",
    "height": "bead_len + 2",
    "base": [
     "-(bead_len + 2)/2",
     "Wi/2",
     "Hb - lip + 1.5"
    ],
    "axis": "X",
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "GrooveN"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "radius": "groove_r",
    "height": "bead_len + 2",
    "base": [
     "-(bead_len + 2)/2",
     "-Wi/2",
     "Hb - lip + 1.5"
    ],
    "axis": "X",
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "GrooveS"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Lo",
    "width": "Wo",
    "height": "lidT",
    "center": [
     "lidx",
     0,
     "lidT/2"
    ],
    "body_name": "Lid",
    "name": "LidPlate"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Li - 2*fit",
    "width": "Wi - 2*fit",
    "height": "lip + 1",
    "center": [
     "lidx",
     0,
     "lidT + lip/2 - 0.5"
    ],
    "operation": "join",
    "targets": [
     "Lid"
    ],
    "name": "Skirt"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Li - 2*fit - 2*lip_t",
    "width": "Wi - 2*fit - 2*lip_t",
    "height": "lip + 1",
    "center": [
     "lidx",
     0,
     "lidT + lip/2 + 0.5"
    ],
    "operation": "cut",
    "targets": [
     "Lid"
    ],
    "name": "SkirtHollow"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "radius": "bead_r",
    "height": "bead_len",
    "base": [
     "lidx - bead_len/2",
     "Wi/2 - fit",
     "lidT + lip - 1.5"
    ],
    "axis": "X",
    "operation": "join",
    "targets": [
     "Lid"
    ],
    "name": "BeadN"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "radius": "bead_r",
    "height": "bead_len",
    "base": [
     "lidx - bead_len/2",
     "-(Wi/2 - fit)",
     "lidT + lip - 1.5"
    ],
    "axis": "X",
    "operation": "join",
    "targets": [
     "Lid"
    ],
    "name": "BeadS"
   }
  },
  {
   "command": "appearance.assign",
   "params": {
    "bodies": [
     "Base"
    ],
    "color": "#2b6cb0"
   }
  },
  {
   "command": "appearance.assign",
   "params": {
    "bodies": [
     "Lid"
    ],
    "color": "#e2e8f0"
   }
  }
 ]
}