{"commands": [
  {"command": "parameters.add", "params": {"name": "tube_d", "expression": "25 mm", "comment": "tube outer diameter = clamp bore"}},
  {"command": "parameters.add", "params": {"name": "wall", "expression": "4 mm", "comment": "ring wall thickness"}},
  {"command": "parameters.add", "params": {"name": "W", "expression": "12 mm", "comment": "clamp width along the tube axis (print height)"}},
  {"command": "parameters.add", "params": {"name": "bolt_d", "expression": "4.5 mm", "comment": "M4 clearance hole / slot width"}},
  {"command": "parameters.add", "params": {"name": "bolt_off", "expression": "8 mm", "comment": "tube surface to flange-hole centre"}},
  {"command": "parameters.add", "params": {"name": "flange_t", "expression": "5 mm", "comment": "flange thickness per half"}},
  {"command": "parameters.add", "params": {"name": "edge", "expression": "5 mm", "comment": "flange-hole centre to flange end"}},
  {"command": "parameters.add", "params": {"name": "foot_t", "expression": "5 mm", "comment": "mounting foot thickness"}},
  {"command": "parameters.add", "params": {"name": "foot_len", "expression": "80 mm", "comment": "mounting foot length"}},
  {"command": "parameters.add", "params": {"name": "slot_len", "expression": "10 mm", "comment": "foot slot overall length"}},
  {"command": "parameters.add", "params": {"name": "slot_x", "expression": "32 mm", "comment": "foot slot centre distance from axis"}},
  {"command": "parameters.add", "params": {"name": "web_w", "expression": "20 mm", "comment": "web between ring and foot"}},
  {"command": "parameters.add", "params": {"name": "gap", "expression": "10 mm", "comment": "layout gap between the two halves"}},
  {"command": "parameters.add", "params": {"name": "Ri", "expression": "tube_d/2"}},
  {"command": "parameters.add", "params": {"name": "Ro", "expression": "Ri + wall"}},
  {"command": "parameters.add", "params": {"name": "hx", "expression": "Ri + bolt_off"}},
  {"command": "parameters.add", "params": {"name": "fl", "expression": "hx + edge"}},
  {"command": "parameters.add", "params": {"name": "foot_top", "expression": "Ro - 1.5 mm"}},

  {"command": "solid.cylinder", "params": {"radius": "Ro", "height": "W", "operation": "new", "name": "B_Ring", "body_name": "HalfB"}},
  {"command": "solid.box", "params": {"length": "2*fl", "width": "flange_t", "height": "W", "center": [0, "-flange_t/2", "W/2"], "operation": "join", "targets": ["HalfB"], "name": "B_Flanges"}},
  {"command": "solid.box", "params": {"length": "web_w", "width": "foot_top + 1 mm - 8 mm", "height": "W", "center": [0, "-(foot_top + 1 mm + 8 mm)/2", "W/2"], "operation": "join", "targets": ["HalfB"], "name": "B_Web"}},
  {"command": "solid.box", "params": {"length": "foot_len", "width": "foot_t", "height": "W", "center": [0, "-foot_top - foot_t/2", "W/2"], "operation": "join", "targets": ["HalfB"], "name": "B_Foot"}},
  {"command": "solid.box", "params": {"length": "2*fl + 20 mm", "width": "Ro + 2 mm", "height": "W + 2 mm", "center": [0, "(Ro + 2 mm)/2", "W/2"], "operation": "cut", "targets": ["HalfB"], "name": "B_Split"}},
  {"command": "solid.cylinder", "params": {"radius": "Ri", "height": "W + 2 mm", "base": [0, 0, "-1 mm"], "operation": "cut", "targets": ["HalfB"], "name": "B_Bore"}},
  {"command": "solid.cylinder", "params": {"diameter": "bolt_d", "height": "flange_t + 2 mm", "base": ["hx", "-flange_t - 1 mm", "W/2"], "axis": "Y", "operation": "cut", "targets": ["HalfB"], "name": "B_Hole"}},
  {"command": "solid.mirror", "params": {"features": ["B_Hole"], "plane": "YZ", "name": "B_Hole_M"}},
  {"command": "sketch.create", "params": {"plane": "XZ", "offset": "-foot_top - foot_t - 1 mm", "name": "SlotSketch"}},
  {"command": "sketch.draw.dimensioned", "params": {"command": "sketch.slot.overall", "params": {"p0": [27, -6], "p1": [37, -6], "width": 4.5}, "dimensions": {"length": "slot_len", "width": "bolt_d"}}},
  {"command": "sketch.dimension", "params": {"entities": ["origin", "a1.center"], "type": "horizontal", "value": "slot_x - slot_len/2 + bolt_d/2"}},
  {"command": "sketch.dimension", "params": {"entities": ["origin", "a1.center"], "type": "vertical", "value": "W/2"}},
  {"command": "sketch.dimension", "params": {"entities": ["origin", "a2.center"], "type": "vertical", "value": "W/2"}},
  {"command": "sketch.finish", "params": {}},
  {"command": "solid.extrude", "params": {"distance": "foot_t + 2 mm", "operation": "cut", "targets": ["HalfB"], "name": "B_Slot"}},
  {"command": "solid.mirror", "params": {"features": ["B_Slot"], "plane": "YZ", "name": "B_Slot_M"}},

  {"command": "solid.cylinder", "params": {"radius": "Ro", "height": "W", "base": [0, "gap", 0], "operation": "new", "name": "A_Ring", "body_name": "HalfA"}},
  {"command": "solid.box", "params": {"length": "2*fl", "width": "flange_t", "height": "W", "center": [0, "gap + flange_t/2", "W/2"], "operation": "join", "targets": ["HalfA"], "name": "A_Flanges"}},
  {"command": "solid.box", "params": {"length": "2*fl + 20 mm", "width": "Ro + 2 mm", "height": "W + 2 mm", "center": [0, "gap - (Ro + 2 mm)/2", "W/2"], "operation": "cut", "targets": ["HalfA"], "name": "A_Split"}},
  {"command": "solid.cylinder", "params": {"radius": "Ri", "height": "W + 2 mm", "base": [0, "gap", "-1 mm"], "operation": "cut", "targets": ["HalfA"], "name": "A_Bore"}},
  {"command": "solid.cylinder", "params": {"diameter": "bolt_d", "height": "flange_t + 2 mm", "base": ["hx", "gap - 1 mm", "W/2"], "axis": "Y", "operation": "cut", "targets": ["HalfA"], "name": "A_Hole"}},
  {"command": "solid.mirror", "params": {"features": ["A_Hole"], "plane": "YZ", "name": "A_Hole_M"}}
]}
