kcl-samples → lug-nut

lug-nut

lug-nut

KCL

// Lug Nut
// lug Nuts are essential components used to create secure connections, whether for electrical purposes, like terminating wires or grounding, or for mechanical purposes, such as providing mounting points or reinforcing structural joints. 

// Define the plane the lug lives on


// Define constants
const lugDiameter = 24 // mm
const lugHeadLength = lugDiameter * .5 // mm
const lugThreadDiameter = lugDiameter/2 * .85 //mm
const lugLength = 30 //mm
const lugThreadDepth = lugLength - 12.7 //mm

const customPlane = {
      plane: {
        origin: { x: 0, y: 0, z: 0 },
        xAxis: { x: 1, y: 0, z: 0 },
        yAxis: { x: 0, y: 1, z: 0 },
        zAxis: { x: 0, y: 0, z: 1 }
      }
    }

fn lug = (plane, length, diameter) => {

    const lugSketch = startSketchOn(customPlane)
      |> startProfileAt([0 + diameter/2, 0], %)
      |> angledLineOfYLength({
        angle: 70,
        length: lugHeadLength,
      }, %)
      |> xLineTo(lugDiameter/2, %)
      |> yLineTo(lugLength, %)
      |> tangentialArc({
        offset: 90,
        radius: 3,
      }, %)
      |> xLineTo(0+.001, %, $c1)
      |> yLineTo(lugThreadDepth, %)
      |> xLineTo(lugThreadDiameter, %)
      |> yLineTo(0, %)
      |> close(%)
      |> revolve({
        axis: "Y",
      }, %)
    return lugSketch
}

lug(customPlane, lugLength, lugDiameter)