FooCAD Source Codeimport uk.co.nickthecoder.foocad.threaded.v2.*
import uk.co.nickthecoder.foocad.screws.v3.*
import uk.co.nickthecoder.foocad.smartextrusion.v1.*
import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.*
import uk.co.nickthecoder.foocad.gears.v1.*
class SpurGearMount : Model {
var thickness = 6.0
var gearConfig = GearConfig.lego().module(3)
var axelDiameter = 13.0
var axelClearance = 0.3
var washerSize = Vector2(20, 0.6)
var extraHeight = washerSize.y + 0.3
var capSize = Vector2( 20, 2 )
var screwHole : Shape3d = Countersink().mirrorZ()
var capThread = Thread(9)
meth spur( teeth : int ) : Shape3d {
val shape = InvoluteGear( gearConfig, teeth ).spurProfile()
val solid = shape.smartExtrude( thickness )
.edges( Chamfer(0.6) )
val hole = Circle( axelDiameter/2 )
.extrude( thickness * 3 ).center()
return solid - hole
}
@Piece
meth washer() : Shape3d {
val shape = Circle( washerSize.x/2 ) - Circle( axelDiameter/2 + axelClearance )
return shape.extrude( washerSize.y )
}
@Piece
meth mount() : Shape3d {
val post = Circle( axelDiameter/2 - axelClearance )
.smartExtrude( capSize.y + thickness + extraHeight )
val cap = Circle( capSize.x/2 )
.smartExtrude(capSize.y)
.bottom( Chamfer( capSize.y*0.6 ) )
return post + cap - screwHole
}
@Piece
meth mountScrewCap() : Shape3d {
val post = Circle( axelDiameter/2 - axelClearance )
.smartExtrude( thickness + extraHeight )
val screwHole = Countersink().recess( post.top - 3 ).topTo(post.top)
val threadedHole = capThread.threadedHole( post.size.z - 3 )
.bottomTo( 3 )
return post - screwHole - threadedHole
}
@Piece
meth cap() : Shape3d {
val cap = Circle( capSize.x/2 )
.smartExtrude(capSize.y)
.bottom( Chamfer( capSize.y*0.6 ) )
val thread = capThread.threadedRod( thickness + extraHeight + cap.top - 3 )
return cap + thread
}
override fun build() : Shape3d {
//val onePieceMount = mount().mirrorZ().bottomTo(0) // One piece mount.
val mount = mountScrewCap()
val cap = cap().mirrorZ().bottomTo(3.5).color("violet")
val washer = washer().color("Orange")
val spur = spur(20).previewOnly().bottomTo( washer.top )
val washers = washer.bottomTo(spur.top).also()
return mount + cap + washers + spur
}
}