Exit Full View
Up

/Tools/DriveWheel.foocad

DriveWheel
FooCAD Source Code
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
/**
A simple way to drive someng using a electric drill/screwdriver.
Attach a bolt, and add rubber grip (I used an old bike tyre).

My first use for this wa to turn a filament spool, as I wanted to transfer
filament from an nice environmentally friendly cardboard spool to an
(evil if used only once) plastic spool.
*/
class DriverWheel : Model {
    
    // One of my spools has a 31mm opening, but most are larger
    // Note this is the "small" diameter, the crown will make it larger.
    @Custom
    var diameter = 35 
   
    @Custom
    var depth = 20

    @Custom
    var baseThickness = 1.0

    @Custom
    var thickness = 1.5

    @Custom
    var bolt = 5.5 // For an M5 bolt?

    // A lower value makes the crown more pronounced.
    @Custom
    var crown = 2.0

    override fun build() : Shape3d {

        val profile = PolygonBuilder().apply {
            moveTo(0,0)
            lineTo(diameter/2,0)
            circularArcTo(diameter/2, depth, diameter*crown, false,true)
            lineTo(diameter/2,depth)
            lineTo(diameter/2-thickness, depth)
            circularArcTo(diameter/2-thickness, baseThickness, diameter*crown, false,false)
            lineTo(0,baseThickness)
        }.build()

        val finP = PolygonBuilder().apply {
            moveTo( 0,0 )
            lineTo(diameter/2,0)
            circularArcTo(diameter/2, depth/2, diameter*crown, false,true)
            lineTo(5,4)
        }.build()

        val fins = finP.extrude( 1 ).centerZ().rotateX(90).repeatAroundZ(7) +
            Cylinder(5,6) 

        // I added fins to the design, but my 1st print din't include them,
        // and it worked just fine!
        val result = profile.revolve() /*+ fins*/ -
            Cylinder.hole( depth, bolt/2 ).center()


        return result // Cube( diameter*2,1,diameter*2).center()
    }
}