{
 "commands": [
  {
   "command": "parameters.add",
   "params": {
    "name": "pcb_l",
    "expression": "100 mm",
    "comment": "PCB length (X)"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "pcb_w",
    "expression": "60 mm",
    "comment": "PCB width (Y)"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "pcb_t",
    "expression": "1.6 mm",
    "comment": "PCB thickness"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "comp_h",
    "expression": "15 mm",
    "comment": "tallest component above board top"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "wall",
    "expression": "2.4 mm",
    "comment": "wall and floor thickness"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "clr",
    "expression": "1.5 mm",
    "comment": "clearance PCB to walls and components to lid"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "corner_r",
    "expression": "3 mm",
    "comment": "outer vertical corner radius, > wall"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "so_h",
    "expression": "6 mm",
    "comment": "standoff height above floor (insert depth)"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "so_d",
    "expression": "7 mm",
    "comment": "standoff outer diameter"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "insert_d",
    "expression": "4 mm",
    "comment": "M3 heat-set insert hole diameter"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "inset",
    "expression": "4 mm",
    "comment": "mount hole inset from PCB edges"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "vent_w",
    "expression": "2 mm",
    "comment": "vent slot width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "vent_l",
    "expression": "20 mm",
    "comment": "vent slot length (vertical)"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "vent_n",
    "expression": "6",
    "unit": "",
    "comment": "vents per long side, whole number 1..8"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "vent_pitch",
    "expression": "10 mm",
    "comment": "vent spacing"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "usb_w",
    "expression": "10 mm",
    "comment": "USB-C cutout width"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "usb_h",
    "expression": "4 mm",
    "comment": "USB-C cutout height"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "usb_up",
    "expression": "3 mm",
    "comment": "USB-C cutout centre above board top"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lid_t",
    "expression": "2.4 mm",
    "comment": "lid plate thickness"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lip_h",
    "expression": "2 mm",
    "comment": "lid locating lip height"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lip_gap",
    "expression": "0.3 mm",
    "comment": "lip clearance to inner wall"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "pil_d",
    "expression": "7 mm",
    "comment": "lid clamp pillar diameter"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "gap",
    "expression": "10 mm",
    "comment": "layout gap base to lid"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Li",
    "expression": "pcb_l + 2*clr"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Wi",
    "expression": "pcb_w + 2*clr"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Lo",
    "expression": "Li + 2*wall"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "Wo",
    "expression": "Wi + 2*wall"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "board_z",
    "expression": "wall + so_h",
    "comment": "board underside height"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "H",
    "expression": "board_z + pcb_t + comp_h + clr",
    "comment": "base height"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "hx",
    "expression": "pcb_l/2 - inset"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "hy",
    "expression": "pcb_w/2 - inset"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lid_y",
    "expression": "Wo + gap",
    "comment": "lid centre Y"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "pil_h",
    "expression": "H - board_z - pcb_t",
    "comment": "pillar length: lid underside to board top"
   }
  },
  {
   "command": "parameters.add",
   "params": {
    "name": "lip_t",
    "expression": "clr - lip_gap"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Lo",
    "width": "Wo",
    "height": "H",
    "center": [
     0,
     0,
     "H/2"
    ],
    "name": "BaseBlock",
    "body_name": "Base"
   }
  },
  {
   "command": "solid.fillet",
   "params": {
    "edges": [
     [
      53.9,
      33.9,
      13
     ],
     [
      -53.9,
      33.9,
      13
     ],
     [
      53.9,
      -33.9,
      13
     ],
     [
      -53.9,
      -33.9,
      13
     ]
    ],
    "radius": "corner_r",
    "name": "BaseCorners"
   }
  },
  {
   "command": "solid.shell",
   "params": {
    "faces": [
     [
      0,
      0,
      26.5
     ]
    ],
    "thickness": "wall",
    "name": "BaseShell"
   }
  },
  {
   "command": "sketch.create",
   "params": {
    "plane": "XY",
    "offset": "1.4",
    "name": "StandoffSk"
   }
  },
  {
   "command": "sketch.circle.center",
   "params": {
    "center": [
     46,
     26
    ],
    "radius": 3.5
   }
  },
  {
   "command": "sketch.dimension",
   "params": {
    "entities": [
     "c1"
    ],
    "type": "diameter",
    "value": "so_d"
   }
  },
  {
   "command": "sketch.circle.center",
   "params": {
    "center": [
     46,
     26
    ],
    "radius": 2
   }
  },
  {
   "command": "sketch.dimension",
   "params": {
    "entities": [
     "c2"
    ],
    "type": "diameter",
    "value": "insert_d"
   }
  },
  {
   "command": "sketch.constraint.coincident",
   "params": {
    "a": "c1.center",
    "b": "c2.center"
   }
  },
  {
   "command": "sketch.dimension",
   "params": {
    "entities": [
     "origin",
     "c1.center"
    ],
    "type": "horizontal",
    "value": "hx"
   }
  },
  {
   "command": "sketch.dimension",
   "params": {
    "entities": [
     "origin",
     "c1.center"
    ],
    "type": "vertical",
    "value": "hy"
   }
  },
  {
   "command": "sketch.finish",
   "params": {}
  },
  {
   "command": "solid.extrude",
   "params": {
    "sketch": "StandoffSk",
    "distance": "so_h + wall - 1.4",
    "profiles": [
     {
      "point": [
       48.75,
       26
      ]
     }
    ],
    "operation": "join",
    "targets": [
     "Base"
    ],
    "name": "Standoff"
   }
  },
  {
   "command": "solid.pattern.rectangular",
   "params": {
    "features": [
     "Standoff"
    ],
    "dir1": [
     -1,
     0,
     0
    ],
    "count1": 2,
    "spacing1": "2*hx",
    "dir2": [
     0,
     -1,
     0
    ],
    "count2": 2,
    "spacing2": "2*hy",
    "name": "Standoffs"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "vent_w",
    "width": "Wo + 10",
    "height": "vent_l",
    "center": [
     "-(vent_n-1)*vent_pitch/2",
     0,
     "(wall + H)/2"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "Vent"
   }
  },
  {
   "command": "solid.pattern.rectangular",
   "params": {
    "features": [
     "Vent"
    ],
    "dir1": [
     1,
     0,
     0
    ],
    "count1": "vent_n",
    "spacing1": "vent_pitch",
    "name": "Vents"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "wall*3",
    "width": "usb_w",
    "height": "usb_h",
    "center": [
     "-Lo/2",
     0,
     "board_z + pcb_t + usb_up"
    ],
    "operation": "cut",
    "targets": [
     "Base"
    ],
    "name": "USBC"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Lo",
    "width": "Wo",
    "height": "lid_t",
    "center": [
     0,
     "lid_y",
     "lid_t/2"
    ],
    "name": "LidPlate",
    "body_name": "Lid"
   }
  },
  {
   "command": "solid.fillet",
   "params": {
    "edges": [
     [
      53.9,
      111.69999999999999,
      1.2
     ],
     [
      -53.9,
      111.69999999999999,
      1.2
     ],
     [
      53.9,
      43.9,
      1.2
     ],
     [
      -53.9,
      43.9,
      1.2
     ]
    ],
    "radius": "corner_r",
    "name": "LidCorners"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Li - 2*lip_gap",
    "width": "Wi - 2*lip_gap",
    "height": "lip_h + 0.5",
    "center": [
     0,
     "lid_y",
     "lid_t - 0.5 + (lip_h + 0.5)/2"
    ],
    "operation": "join",
    "targets": [
     "Lid"
    ],
    "name": "LipOuter"
   }
  },
  {
   "command": "solid.box",
   "params": {
    "length": "Li - 2*lip_gap - 2*lip_t",
    "width": "Wi - 2*lip_gap - 2*lip_t",
    "height": "lip_h + 1",
    "center": [
     0,
     "lid_y",
     "lid_t + (lip_h + 1)/2"
    ],
    "operation": "cut",
    "targets": [
     "Lid"
    ],
    "name": "LipInner"
   }
  },
  {
   "command": "solid.cylinder",
   "params": {
    "diameter": "pil_d",
    "height": "pil_h + 0.4",
    "base": [
     "hx",
     "lid_y + hy",
     "lid_t - 0.4"
    ],
    "operation": "join",
    "targets": [
     "Lid"
    ],
    "name": "Pillar"
   }
  },
  {
   "command": "solid.pattern.rectangular",
   "params": {
    "features": [
     "Pillar"
    ],
    "dir1": [
     -1,
     0,
     0
    ],
    "count1": 2,
    "spacing1": "2*hx",
    "dir2": [
     0,
     -1,
     0
    ],
    "count2": 2,
    "spacing2": "2*hy",
    "name": "Pillars"
   }
  },
  {
   "command": "solid.hole",
   "params": {
    "position": [
     "hx",
     "lid_y + hy",
     0
    ],
    "clearance": "M3",
    "type": "countersink",
    "cs_diameter": "6.5",
    "cs_angle": "90 deg",
    "name": "LidScrew1"
   }
  },
  {
   "command": "solid.hole",
   "params": {
    "position": [
     "-hx",
     "lid_y + hy",
     0
    ],
    "clearance": "M3",
    "type": "countersink",
    "cs_diameter": "6.5",
    "cs_angle": "90 deg",
    "name": "LidScrew2"
   }
  },
  {
   "command": "solid.hole",
   "params": {
    "position": [
     "hx",
     "lid_y - hy",
     0
    ],
    "clearance": "M3",
    "type": "countersink",
    "cs_diameter": "6.5",
    "cs_angle": "90 deg",
    "name": "LidScrew3"
   }
  },
  {
   "command": "solid.hole",
   "params": {
    "position": [
     "-hx",
     "lid_y - hy",
     0
    ],
    "clearance": "M3",
    "type": "countersink",
    "cs_diameter": "6.5",
    "cs_angle": "90 deg",
    "name": "LidScrew4"
   }
  }
 ]
}