2025-04-04 11:03:13 -07:00
// Hex Nut
2025-03-06 18:01:24 -05:00
// 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.
// Set Units
2025-05-06 08:44:03 +12:00
@settings(defaultLengthUnit = in, kclVersion = 1.0)
2025-03-06 18:01:24 -05:00
2025-04-04 11:03:13 -07:00
// Define parameters (5/16" - 24 thread size)
2025-03-06 18:01:24 -05:00
wallToWallLength = 0.5
thickness = 0.266
diameter = 0.3125
// Define a function for the hex nut
fn hexNut(start, thk, innerDia) {
2025-03-26 08:53:34 -07:00
hexNutSketch = startSketchOn(-XZ)
2025-04-25 16:01:35 -05:00
|> startProfile(at = [start[0] + innerDia, start[1]])
KCL: Angled line should use keyword args (#5803)
We continue migrating KCL stdlib functions to use keyword arguments. Next up is the `angledLine` family of functions (except `angledLineThatIntersects, which will be a quick follow-up).
Before vs. after:
`angledLine({angle = 90, length = 3}, %, $edge)`
=> `angledLine(angle = 90, length = 3, tag = $edge)`
`angledLineOfXLength({angle = 90, length = 3}, %, $edge)`
=> `angledLine(angle = 90, lengthX = 3, tag = $edge)`
`angledLineOfYLength({angle = 90, length = 3}, %, $edge)`
=> `angledLine(angle = 90, lengthY = 3, tag = $edge)`
`angledLineToX({angle = 90, length = 3}, %, $edge)`
=> `angledLine(angle = 90, endAbsoluteX = 3, tag = $edge)`
`angledLineToY({angle = 90, length = 3}, %, $edge)`
=> `angledLine(angle = 90, endAbsoluteY = 3, tag = $edge)`
2025-04-09 14:55:15 -05:00
|> angledLine(angle = 240, length = innerDia)
|> angledLine(angle = 180, length = innerDia)
|> angledLine(angle = 120, length = innerDia)
|> angledLine(angle = 60, length = innerDia)
|> angledLine(angle = 0, length = innerDia * .90)
2025-03-06 18:01:24 -05:00
|> close()
2025-04-26 15:31:51 -05:00
|> subtract2d(tool = circle(center = [start[0], start[1]], radius = innerDia / 2))
2025-03-06 18:01:24 -05:00
|> extrude(length = thk)
return hexNutSketch
}
// Create a hex nut
2025-05-01 11:36:51 -05:00
hexNut(start = [0, 0], thk = thickness, innerDia = diameter)