Exit Full View
Up

/Printer/SpoolSled.foocad

SpoolSled
FooCAD Source Code
import static uk.co.nickthecoder.foocad.chamferedextrude.ChamferedExtrude.*

/**
    A simple sled for filament spools to sit on, with standard bearings added for
    smooth rotation on the spool's rims.
    
    Fit the bearings by inserting them from the bottom, and bending the base to
    make the uprights spread apart. Do NOT bend the uprights, as these are
    weak, and may split if the layer adhesion of your print is low.

*/
class SpoolSled : Model {
    
    var bearingD = 22.0

    // My bearings are 7mm wide, but lets add 0.5mm gap.
    var bearingWidth = 7.5

    var holeD = 7.0
    
    var thickness = 2.0

    var round = 7.8
    
    // The base is deliberately thin, so that it can bend when you insert the
    // bearings.
    var baseThickness = 1.2

    var distance = 65

    fun uprights() : Shape3d {
        val outerR = bearingD / 2 + 3
        val profile = Circle( outerR ).translateY( outerR )
            .hull( Square( outerR*2, 1 ).centerX() )

        val fillet = Cube( outerR*2, round, round ).centerX() -
            Circle( round ).sides(12).internalChamferedExtrude( outerR*2, 1 )
                .center().rotateY(90)
                .translate(0, round, round)

        val half = profile.extrude( thickness )
            .rotateX(90).translateY( -bearingWidth/ 2 ) +
            fillet.translate( 0, bearingWidth/2+thickness, baseThickness )

        val axis = (
                Cylinder( bearingWidth/2.2, holeD/2 ) -
                Cube( holeD ).centerX()
                    .rotateX(30)
                    .translateY(-holeD/2)
                    .color("Red")
            )
            .rotateX(90)
            .translateY( bearingWidth/2 )
            .translateZ( outerR )

        return (half + axis).mirrorY().also()
            .translateX( distance / 2 ).mirrorX().also()
    }

    fun base() : Shape3d {
        val outerR =  bearingD / 2 + 3
        val r = outerR + 5
        val a = Circle( r )

        val ellipse = Circle( distance/2 ).scale( 1, 0.5 )
        val join = ellipse - ellipse.offset( -6 )

        val profile = a.translateX( distance / 2 ).mirrorX().also() +
            join

        return profile.extrude( baseThickness )
            

    }

    fun holes() : Shape3d {
        val outerR =  bearingD / 2 + 3

        val hole =  Square( outerR*2, bearingWidth ).center()
        return hole.internalChamferedExtrude( baseThickness, 1, 0 )
            .translateX( distance / 2 ).mirrorX().also()
    }

    override fun build() : Shape3d {
        return uprights() + base() - holes()
    }
}