The NEMA17's base is quadratic and can be defined by two dimensions (ignoring the chamfers).
One measurement is diagonal from "/" to "/" (or "\" to "\") and the other just the width.
function octagon(diagonal, width)
-- 2
-- /-----------\
-- / \ 1
-- | |
-- | |
-- | |
-- | |
-- | |
-- \ /
-- \-----------/
-- Corner point 1 is x=width/2, y=c
-- Corner point 2 is x=c, y=width/2
-- To be calculated is c
-- The diagonal point is the mean of points 1 and 2:
-- x = y = width/4 + c/2
-- Based on this the diagonal is
-- d = 2 * sqrt(2) * (width/4 + c/2)
-- Given the diagonal c can be determined
-- c = (d / (2 * sqrt(2)) - width/4) * 2
-- = d / sqrt(2) - width/2
b = width / 2
c = diagonal / math.sqrt(2) - width / 2
return Sketch({
{ b, c},
{ c, b},
{-c, b},
{-b, c},
{-b,-c},
{-c,-b},
{ c,-b},
{ b,-c},
})
end
function build_body()
diagonal_base = 53.77
width_base = 42.15
height_base = 9.46
s1 = octagon(diagonal_base, width_base)
s2 = s1:translate{z = height_base}
diagonal_middle = 50.2
width_middle = 42.2
height_middle = 22.10
s3 = octagon(diagonal_middle, width_middle):translate{z = height_base}
s4 = s3:translate{z = height_middle}
diagonal_top = 53.77
width_top = 42.15
height_top = 8.0
s5 = octagon(diagonal_top, width_top):translate{z = height_base+height_middle}
s6 = s5:translate{z = height_top}
return height_base + height_middle + height_top, Mesh.loft{s1,s2,s3,s4,s5,s6}
end
function holes_sketch()
hole = circle{diameter = 4}:translate{x = 31/2, y = 31/2}
holes = hole ^ hole:rotate{ang_z = 90}
holes = holes ^ hole:rotate{ang_z = 180}
holes = holes ^ hole:rotate{ang_z = 270}
return holes
end
function build_ring()
c = circle{diameter = 22}
return 2, c:extrude{height = 2}
end
function build_axle()
c = circle{radius = 5/2}
a = c:extrude{height = 20}
cutout = rectangle{width = 5, length = 5}
:extrude{height = 20}
:translate{x = -2.5, y = 2, z = 7}
return 20, a:subtract(cutout)
end
function build()
body_height,body = build_body()
holes = holes_sketch():translate{z = body_height}
body = body:pocket(holes,{depth = 4.5})
ring_height,ring = build_ring()
axle_height,axle = build_axle()
return Mesh.union{body,ring:translate{z = body_height},axle:translate{z = body_height + ring_height}}
end