kcl-samples →
hex-nut
KCL
// Hex nut
// A hex nut is a type of fastener with a threaded hole and a hexagonal outer shape, used in a wide variety of applications to secure parts together. The hexagonal shape allows for a greater torque to be applied with wrenches or tools, making it one of the most common nut types in hardware.
const hexNutScale = 0.90
fn hexNut = (originStart, thk, innerDia) => {
const hexNutSketch = startSketchOn('XZ')
|> startProfileAt([originStart[0] + innerDia * hexNutScale, originStart[1]], %)
|> angledLine({
angle: 240,
length: innerDia * hexNutScale
}, %)
|> angledLine({
angle: 180,
length: innerDia * hexNutScale
}, %)
|> angledLine({
angle: 120,
length: innerDia * hexNutScale
}, %)
|> angledLine({
angle: 60,
length: innerDia * hexNutScale
}, %)
|> angledLine({ angle: 0, length: innerDia * .90 }, %)
|> close(%)
|> hole(circle([originStart[0], originStart[1]], innerDia / 2, %), %)
|> extrude(thk, %)
return hexNutSketch
}
hexNut([0, 3], 5, 4)