Exit Full View
Up

/Misc/ThreadOrganiser.foocad

ThreadOrganiser
FooCAD Source Code
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*


/*
    I have a lot of coloured cotton threads that were in a jumble at the bottom of my sewing box.
    I want to organise them - putting similar colours together.

    To save plastic and print times, I've made the "posts" very stubby, and then taped thin card
    to each for the bobbins to fit over. This has an added bonus that the plastic is much less
    likely to be damaged when a post is knocked.
*/
class ThreadOrganiser : Model {
    
    var diameter = 45.0
    var spacing = 2.0

    var across = 4
    var down = 4

    var baseT = 0.8
    var postHeight = 20
    var postT = 1.2
    var postD = 14.0

    fun spool() = ExtrusionBuilder().apply {
        crossSection( Circle( diameter/2 ) )
        forward ( 10 )
        crossSection( -10 )
        crossSection( 5 )
        forward( 47 )
        crossSection()
        forward( 7 )
        crossSection( Circle(18.5/2) )
        forward( 3 )
        crossSection()
        crossSection( -1 )
        forward( -10-47-7-3 )
        crossSection()
    }.buildClosed()

    fun post() = (
            Circle(postD/2) - Circle(postD/2-postT) +
            Square(postD,postT).center() +
            Square(postT,postD).center()
    ).extrude( postHeight )

    override fun build() : Shape3d {
        val spool = spool().previewOnly()
        var delta = diameter + spacing

        val spools = spool.repeatX( across, delta ).repeatY( down, delta ).centerXY()

        var posts = post().repeatX( across, delta ).repeatY( down, delta ).centerXY()

        val base = Square( spools.size.x + 10, spools.size.y + 10 )
            .roundAllCorners( 15 )
            .center()
            .extrude(  baseT )
            .color("Orange")

        return spools.bottomTo(base.top) + base + posts
    }
}