{
  "schema": "vextor.vxl.v1",
  "id": "reducer_nominal_hardware",
  "units": {"angle": "deg", "length": "mm"},
  "needs": [
    {"id": "nominal_hardware", "source": "user", "text": "Nominal ISO4762 M3×16 screw (Ø5.5×3 head) and ISO4032 M3 nut (AF5.5×2.4); thread envelopes only, without helical flanks or preload."},
    {"id": "native", "source": "user", "text": "Full reducer motion, actual hardware and physical running.", "unmodeled": "Finite geometry observations do not establish continuous driving-flank engagement under load or the physical 20-turn trial."},
    {"id": "printed", "source": "user", "text": "110×80×6 mm base (128×92×6 for 24/48), two fixed Ø6 journals with nut loading channels, and two independent Ø9.6×2 mm end caps."}
  ],
  "params": [
    {"id": "pinion_teeth", "domain": ["20", "20"], "type": "count", "value": "20"},
    {"id": "backlash", "domain": ["0.15", "0.25"], "type": "length", "value": "0.2"}
  ],
  "lets": [
    {"id": "base_w", "expr": "if(pinion_teeth == 20, 110mm, 128mm)"},
    {"id": "base_h", "expr": "if(pinion_teeth == 20, 80mm, 92mm)"},
    {"id": "shaft_x", "expr": "if(pinion_teeth == 20, 30mm, 33mm)"},
    {"id": "shaft_y", "expr": "base_h / 2"},
    {"id": "centres", "expr": "2.25mm * pinion_teeth"},
    {"id": "small_nominal_width", "expr": "if(pinion_teeth == 20, 2.3258131541246003mm, 2.3233344447003472mm)", "type": "length"},
    {"id": "large_nominal_width", "expr": "if(pinion_teeth == 20, 2.344676662540983mm, 2.3352905288851575mm)", "type": "length"},
    {"id": "small_epsilon", "expr": "(small_nominal_width - (pi * 1.5mm / 2 - backlash / 2)) / (1.5mm * pinion_teeth) * 180deg / pi"},
    {"id": "large_epsilon", "expr": "(large_nominal_width - (pi * 1.5mm / 2 - backlash / 2)) / (3mm * pinion_teeth) * 180deg / pi"}
  ],
  "checks": [
    {"id": "backlash_family", "expr": "backlash / 1mm == 0.15 or backlash / 1mm == 0.20 or backlash / 1mm == 0.25", "message": "Use j=0.15/0.20/0.25 mm."}
  ],
  "defs": [
    {
      "id": "finished_gear",
      "category": "step",
      "params": [
        {"id": "teeth", "type": "count"},
        {"id": "epsilon", "type": "angle"},
        {"id": "marker_d", "type": "length"},
        {"id": "marker_h", "type": "length"},
        {"id": "marker_x", "type": "length"}
      ],
      "steps": [
        {"id": "nominal", "op": "spur_gear", "bind": "nominal", "chord": "0.0175", "face_width": "8", "module": "1.5", "pressure_angle": "20", "profile_shift": "0", "teeth": "teeth", "thinning": "0"},
        {"id": "envelope", "op": "cylinder", "bind": "$bind", "diameter": "1.5mm * (teeth + 2) + 2mm", "length": "10"},
        {"id": "trim_plus", "op": "intersect", "target": "$bind", "tool": "nominal", "alias": "nominal_plus", "tool_place": {"rotate": [{"axis": "z", "deg": "epsilon"}]}},
        {"id": "trim_minus", "op": "intersect", "target": "$bind", "tool": "nominal", "alias": "nominal_minus", "tool_place": {"rotate": [{"axis": "z", "deg": "-epsilon"}]}},
        {"id": "bore", "op": "hole", "target": "$bind", "at": ["0", "0", "8"], "axis": "-z", "depth": "through", "diameter": "6.3"},
        {"id": "indicator", "op": "cylinder", "bind": "indicator", "at": ["marker_x", "0", "7.98"], "diameter": "marker_d", "length": "marker_h"},
        {"id": "self", "op": "union", "target": "$bind", "tool": "indicator"}
      ]
    }
  ],
  "parts": [
    {
      "id": "small",
      "deliver": "body",
      "role": "deliverable",
      "steps": [
        {"id": "gear", "use": "finished_gear", "bind": "body", "args": {"epsilon": "small_epsilon", "marker_d": "8", "marker_h": "15.02", "marker_x": "9", "teeth": "pinion_teeth"}, "covers": []}
      ]
    },
    {
      "id": "large",
      "deliver": "body",
      "role": "deliverable",
      "steps": [
        {"id": "gear", "use": "finished_gear", "bind": "body", "args": {"epsilon": "large_epsilon", "marker_d": "2", "marker_h": "1.52", "marker_x": "15", "teeth": "2 * pinion_teeth"}, "covers": []}
      ]
    },
    {
      "id": "iso4762_m3x16",
      "deliver": "body",
      "role": "deliverable",
      "steps": [
        {"id": "shank", "op": "cylinder", "bind": "body", "diameter": "3", "length": "16.02"},
        {"id": "head", "op": "cylinder", "bind": "head", "at": ["0", "0", "16"], "diameter": "5.5", "length": "3"},
        {"id": "join_head", "op": "union", "target": "body", "tool": "head"}
      ]
    },
    {
      "id": "iso4032_m3",
      "deliver": "body",
      "role": "deliverable",
      "steps": [
        {"id": "hex", "op": "extrude", "bind": "body", "length": "2.4", "plane": "xy", "profile": {"regular_polygon": {"across_flats": "5.5", "center": ["0", "0"], "rotation": "30", "sides": "6"}}, "toward": "+z"},
        {"id": "thread_envelope", "op": "hole", "target": "body", "at": ["0", "0", "2.4"], "axis": "-z", "depth": "through", "diameter": "3"}
      ]
    },
    {
      "id": "base",
      "deliver": "body",
      "role": "deliverable",
      "steps": [
        {"id": "blank", "op": "box", "bind": "body", "size": ["base_w", "base_h", "6"]},
        {"id": "journal", "op": "cylinder", "bind": "journal", "diameter": "6", "length": "8.32"},
        {"id": "nut_trap", "op": "extrude", "bind": "hex", "length": "2.6", "plane": "xy", "profile": {"regular_polygon": {"center": ["0", "0"], "circumradius": "3.2", "rotation": "30", "sides": "6"}}, "toward": "+z"},
        {"id": "loading_channel", "op": "box", "bind": "channel", "size": ["5.7", "shaft_y + 0.02mm", "2.6"]},
        {"id": "journal_pair", "op": "union", "target": "body", "tool": "journal", "alias": "journal_at_${i}", "tool_place": {"translate": ["shaft_x + i * centres", "shaft_y", "5.98"]}, "at_each": [{"range": ["0", "1"], "var": "i"}]},
        {"id": "hex_pair", "op": "cut", "target": "body", "tool": "hex", "alias": "hex_at_${i}", "tool_place": {"translate": ["shaft_x + i * centres", "shaft_y", "-0.02"]}, "at_each": [{"range": ["0", "1"], "var": "i"}]},
        {"id": "channel_pair", "op": "cut", "target": "body", "tool": "channel", "alias": "channel_at_${i}", "tool_place": {"translate": ["shaft_x + i * centres - 2.85mm", "-0.02", "-0.02"]}, "at_each": [{"range": ["0", "1"], "var": "i"}]},
        {"id": "screw_pair", "op": "hole", "target": "body", "at": ["shaft_x + i * centres", "shaft_y", "14.3"], "axis": "-z", "depth": "through", "diameter": "3.4", "at_each": [{"range": ["0", "1"], "var": "i"}]},
        {"id": "mount_0", "op": "hole", "target": "body", "at": ["8", "8", "6"], "axis": "-z", "depth": "through", "diameter": "4.5"},
        {"id": "mount_1", "op": "hole", "target": "body", "at": ["base_w - 8mm", "8", "6"], "axis": "-z", "depth": "through", "diameter": "4.5"},
        {"id": "mount_2", "op": "hole", "target": "body", "at": ["8", "base_h - 8mm", "6"], "axis": "-z", "depth": "through", "diameter": "4.5"},
        {"id": "mount_3", "op": "hole", "target": "body", "at": ["base_w - 8mm", "base_h - 8mm", "6"], "axis": "-z", "depth": "through", "diameter": "4.5"}
      ]
    },
    {
      "id": "cap_in",
      "deliver": "body",
      "role": "deliverable",
      "steps": [
        {"id": "ring", "op": "revolve", "bind": "body", "angle": "360", "axis": {"direction": ["0", "1"], "through": ["0", "0"]}, "plane": "xz", "profile": {"rect": {"max": ["4.8", "2"], "min": ["1.7", "0"]}}}
      ]
    },
    {
      "id": "cap_out",
      "deliver": "body",
      "role": "deliverable",
      "steps": [
        {"id": "ring", "op": "revolve", "bind": "body", "angle": "360", "axis": {"direction": ["0", "1"], "through": ["0", "0"]}, "plane": "xz", "profile": {"rect": {"max": ["4.8", "2"], "min": ["1.7", "0"]}}}
      ]
    }
  ],
  "assemblies": [
    {"id": "reducer", "occurrences": [{"id": "base_placed", "part": "base", "pose": {}}, {"id": "small_placed", "part": "small", "pose": {"translate": ["30", "40", "6"]}}, {"id": "large_placed", "part": "large", "pose": {"rotate": [{"axis": "z", "deg": "4.5"}], "translate": ["75", "40", "6"]}}, {"id": "cap_in_placed", "part": "cap_in", "pose": {"translate": ["30", "40", "14.3"]}}, {"id": "cap_out_placed", "part": "cap_out", "pose": {"translate": ["75", "40", "14.3"]}}, {"id": "screw_0", "part": "iso4762_m3x16", "pose": {"translate": ["30", "40", "0.3"]}}, {"id": "screw_1", "part": "iso4762_m3x16", "pose": {"translate": ["75", "40", "0.3"]}}, {"id": "nut_0", "part": "iso4032_m3", "pose": {"translate": ["30", "40", "0.18"]}}, {"id": "nut_1", "part": "iso4032_m3", "pose": {"translate": ["75", "40", "0.18"]}}]}
  ],
  "requirements": [
    {"id": "screw_solid", "kind": "solid_count", "subject": "iso4762_m3x16", "covers": ["nominal_hardware"], "required": true},
    {"id": "nut_solid", "kind": "solid_count", "subject": "iso4032_m3", "covers": ["nominal_hardware"], "required": true},
    {"id": "small_solid", "kind": "solid_count", "subject": "small", "covers": ["printed"], "required": true},
    {"id": "small_mesh", "kind": "closed_delivered_mesh", "subject": "small", "covers": ["printed"], "required": true},
    {"id": "small_teeth", "kind": "gear_teeth", "subject": "small", "axis": {"at": ["0", "0", "0"], "dir": "+z"}, "face_width": "8", "measurement": "prism_section_v1", "module": "1.5", "pressure_angle": "20", "profile_shift": "0", "teeth": "pinion_teeth", "thinning": "backlash / 2", "tol": {"diameter": "0.06", "form": "0.03", "thickness": "0.002"}, "window": {"axial": ["0", "8"], "radial": ["0.75mm * (pinion_teeth - 2.5) - 0.1mm", "0.75mm * (pinion_teeth + 2) + 0.1mm"]}, "covers": ["printed"], "required": true},
    {"id": "small_bore", "kind": "hole", "subject": "small", "axis": "z", "axis_at": ["0", "0", "0"], "diameter": "6.3", "through": ["0", "8"], "covers": ["printed"], "required": true},
    {"id": "large_solid", "kind": "solid_count", "subject": "large", "covers": ["printed"], "required": true},
    {"id": "large_mesh", "kind": "closed_delivered_mesh", "subject": "large", "covers": ["printed"], "required": true},
    {"id": "large_teeth", "kind": "gear_teeth", "subject": "large", "axis": {"at": ["0", "0", "0"], "dir": "+z"}, "face_width": "8", "measurement": "prism_section_v1", "module": "1.5", "pressure_angle": "20", "profile_shift": "0", "teeth": "2 * pinion_teeth", "thinning": "backlash / 2", "tol": {"diameter": "0.06", "form": "0.03", "thickness": "0.002"}, "window": {"axial": ["0", "8"], "radial": ["0.75mm * (2 * pinion_teeth - 2.5) - 0.1mm", "0.75mm * (2 * pinion_teeth + 2) + 0.1mm"]}, "covers": ["printed"], "required": true},
    {"id": "large_bore", "kind": "hole", "subject": "large", "axis": "z", "axis_at": ["0", "0", "0"], "diameter": "6.3", "through": ["0", "8"], "covers": ["printed"], "required": true},
    {"id": "base_solid", "kind": "solid_count", "subject": "base", "covers": ["printed"], "required": true},
    {"id": "base_mesh", "kind": "closed_delivered_mesh", "subject": "base", "covers": ["printed"], "required": true},
    {"id": "base_bounds", "kind": "envelope", "subject": "base", "bounds": {"max": ["base_w", "base_h", "14.3"], "min": ["0", "0", "0"]}, "tol": "0.02", "covers": ["printed"], "required": true},
    {"id": "journal_0_od", "kind": "outer_diameter", "subject": "base", "axis": "z", "axis_at": ["shaft_x", "shaft_y", "0"], "diameter": "6", "span": {"from": "6", "to": "14.3"}, "covers": ["printed"], "required": true},
    {"id": "journal_1_od", "kind": "outer_diameter", "subject": "base", "axis": "z", "axis_at": ["shaft_x + centres", "shaft_y", "0"], "diameter": "6", "span": {"from": "6", "to": "14.3"}, "covers": ["printed"], "required": true},
    {"id": "screw_0_hole", "kind": "hole", "subject": "base", "axis": "z", "axis_at": ["shaft_x", "shaft_y", "0"], "diameter": "3.4", "through": ["2.58", "14.3"], "covers": ["printed"], "required": true},
    {"id": "screw_1_hole", "kind": "hole", "subject": "base", "axis": "z", "axis_at": ["shaft_x + centres", "shaft_y", "0"], "diameter": "3.4", "through": ["2.58", "14.3"], "covers": ["printed"], "required": true},
    {"id": "mount_0_hole", "kind": "hole", "subject": "base", "axis": "z", "axis_at": ["8", "8", "0"], "diameter": "4.5", "through": ["0", "6"], "covers": ["printed"], "required": true},
    {"id": "mount_1_hole", "kind": "hole", "subject": "base", "axis": "z", "axis_at": ["base_w - 8mm", "8", "0"], "diameter": "4.5", "through": ["0", "6"], "covers": ["printed"], "required": true},
    {"id": "mount_2_hole", "kind": "hole", "subject": "base", "axis": "z", "axis_at": ["8", "base_h - 8mm", "0"], "diameter": "4.5", "through": ["0", "6"], "covers": ["printed"], "required": true},
    {"id": "mount_3_hole", "kind": "hole", "subject": "base", "axis": "z", "axis_at": ["base_w - 8mm", "base_h - 8mm", "0"], "diameter": "4.5", "through": ["0", "6"], "covers": ["printed"], "required": true},
    {"id": "cap_in_solid", "kind": "solid_count", "subject": "cap_in", "covers": ["printed"], "required": true},
    {"id": "cap_in_mesh", "kind": "closed_delivered_mesh", "subject": "cap_in", "covers": ["printed"], "required": true},
    {"id": "cap_in_bore", "kind": "hole", "subject": "cap_in", "axis": "z", "axis_at": ["0", "0", "0"], "diameter": "3.4", "through": ["0", "2"], "covers": ["printed"], "required": true},
    {"id": "cap_in_shape", "kind": "revolved_profile", "subject": "cap_in", "axis": "+z", "origin": ["0", "0", "0"], "profile": {"rect": {"max": ["2", "4.8"], "min": ["0", "1.7"]}}, "radial": "+x", "covers": ["printed"], "required": true},
    {"id": "cap_out_solid", "kind": "solid_count", "subject": "cap_out", "covers": ["printed"], "required": true},
    {"id": "cap_out_mesh", "kind": "closed_delivered_mesh", "subject": "cap_out", "covers": ["printed"], "required": true},
    {"id": "cap_out_bore", "kind": "hole", "subject": "cap_out", "axis": "z", "axis_at": ["0", "0", "0"], "diameter": "3.4", "through": ["0", "2"], "covers": ["printed"], "required": true},
    {"id": "cap_out_shape", "kind": "revolved_profile", "subject": "cap_out", "axis": "+z", "origin": ["0", "0", "0"], "profile": {"rect": {"max": ["2", "4.8"], "min": ["0", "1.7"]}}, "radial": "+x", "covers": ["printed"], "required": true}
  ]
}
