// 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. // Set Units @settings(defaultLengthUnit = in, kclVersion = 1.0) // Define parameters (5/16" - 24 thread size) wallToWallLength = 0.5 thickness = 0.266 diameter = 0.3125 // Define a function for the hex nut fn hexNut(start, thk, innerDia) { hexNutSketch = startSketchOn(-XZ) |> startProfile(at = [start[0] + innerDia, start[1]]) |> 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) |> close() |> subtract2d(tool = circle(center = [start[0], start[1]], radius = innerDia / 2)) |> extrude(length = thk) return hexNutSketch } // Create a hex nut hexNut(start = [0, 0], thk = thickness, innerDia = diameter)