KCL (KITTYCAD LANGUAGE)SOURCE
✓ executed/*
Generated by Text-to-CAD:
A hex bolt: a regular hexagonal head 13mm across flats and 8mm tall, with a cylindrical shaft 10mm in diameter and 30mm long below the head.
*/
@settings(defaultLengthUnit = mm)
// Parameters
headAcrossFlats = 13
headHeight = 8
shankDiameter = 10
shankRadius = shankDiameter / 2
shankLength = 30
// For an inscribed hexagon, the polygon radius equals the across-flats/2
hexRadiusInscribed = headAcrossFlats / 2
// Hex head (inscribed to ensure across-flats = 13 mm)
hexHead = startSketchOn(XY)
|> polygon(
radius = hexRadiusInscribed,
numSides = 6,
center = [0, 0],
inscribed = true,
)
|> extrude(length = headHeight, tagEnd = $headTop)
// Cylindrical shaft from the top face of the head, extruded downward below the head
// Ensure a solid, visible shaft by creating it as a NEW body (not merged away) with explicit SOLID body type.
shaftSketch = startSketchOn(planeOf(hexHead, face = headTop))
|> circle(center = [0, 0], radius = shankRadius)
shaft = extrude(
shaftSketch,
length = shankLength,
symmetric = true,
method = NEW,
bodyType = SOLID,
)
// Position the shaft so 30 mm length extends downward from headTop
translate(
shaft,
x = 0,
y = 0,
z = -shankLength / 2,
)