import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.* import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.* import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.* class StubbyScrewDriver : Model { // A standard bit has 15mm for the hex, and 25mm high in total. // Therefore baseSize.y should be < 15mm // And holeDepth + lidHeight - 2 > 25mm @Custom var baseSize = Vector2( 60, 12 ) var lidHeight = 18 @Custom( about="How deep the bits fit into the base" ) var holeDepth = 10 @Custom( about="How deep the bits fit into the main holes" ) var fullHoleDepth = 16 @Custom var socketD = 7.7 fun hexHole(holdDepth : double, socketD : double) : Shape3d = Circle( socketD/2 ).sides(6) .chamferedExtrude( holeDepth, 0, -1 ) .topTo(baseSize.y+0.01) @Piece fun holeSizeTest() : Shape3d { val piece = Cylinder(baseSize.y,10) - hexHole( holeDepth, socketD ) // Measure 1/4 of an inch, which is the stadard size sockets. val preview = Cube( 2, 25.4 / 4, 20 ).centerXY().previewOnly() return piece + preview } var connectionSize = Vector2(18,10) @Custom( about="Diameter and thickness of magnets (plus extra for tolerance)" ) var magnetSize = Vector2( 11, 1 ) fun magnetHole() = Cylinder( magnetSize.y, magnetSize.x / 2 ) @Piece fun base() : Shape3d { val hex = Circle(baseSize.x/2).sides(6).roundAllCorners(5) .chamferedExtrude( baseSize.y, 2 ) val toolHole = hexHole( holeDepth, socketD+0.1 ) val ring1 = toolHole.repeatCircularZ(18, 11,360*11/12) val extraHole = hexHole( fullHoleDepth, socketD ).rotateX(90) .frontTo(-baseSize.x*0.438) .translateZ(baseSize.y/2) .rotateZ(120) return hex - ring1 - extraHole - magnetHole().topTo(hex.top) } @Piece fun top() : Shape3d { val hex = Circle(baseSize.x/2).sides(6).roundAllCorners(5) .chamferedExtrude( lidHeight, 2 ) val toolHole = hexHole( lidHeight -1.2, socketD + 0.5 ) val ring1 = toolHole.repeatCircularZ(18, 11,360*11/12).topTo(hex.top + 0.01) val extraHole = hexHole( fullHoleDepth, socketD ).rotateX(90) .frontTo(-baseSize.x*0.438) .translateZ(lidHeight/2) .rotateZ(120) val mainHole = hexHole( fullHoleDepth, socketD ).mirrorZ().bottomTo(0) return hex - ring1 - mainHole -extraHole - magnetHole().topTo(hex.top) } override fun build() : Shape3d { return base() + top().translateX(baseSize.x) } }