Exit Full View
Up

/Garden/SaladBed.foocad

SaladBed
FooCAD Source Code
import static uk.co.nickthecoder.foocad.along.v2.Along.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*

class SaladBed : Model {
    
    @Custom
    // https://www.homebase.co.uk/stewart-premium-extra-deep-gravel-tray-38cm/12814777.html
    //var traySize = Vector3( 380, 240, 80 )
    // https://www.homebase.co.uk/stewart-premium-gravel-tray-52cm/12840691.html
    var traySize = Vector3( 420, 520, 90 )

    @Custom
    var gap = Vector2( 10, 10 )

    @Custom
    var thickness = 18
 
    @Custom
    var across = 3

    @Custom
    var back = 1

    val supportLumber = Lumber("support", 40, 20 )
    val lumber = Lumber( "lumber", 150, thickness )
    val trimLumber = Lumber( "trim", 20, 20 )
    val extraLumber = Lumber( "extra", 30, 20 )
 
    override fun build() : Shape3d {

        val front = lumber.cut( traySize.x * across + gap.x*across + thickness * 2)
            .alongX()
            .translateY( -back * traySize.y / 2 -thickness -gap.y*back/2)
            .centerX()

        val frontBack = front.mirrorY().also()

        val side = lumber.cut( traySize.y * back + gap.y*back )
            .alongY()
            .centerY()
            .leftTo(front.left)
            .darker()
        val sides = side.mirrorX().also()

        val supportOffset = 40
        val support = supportLumber.cut( side.size.y )
            .alongY()
            .centerY()
            .translateX(traySize.x - supportOffset*2s - supportLumber.width()).also()
            .darker()

        val supports = support.repeatX( across, traySize.x ).centerX()

        val trimX = trimLumber.cut( front.size.x - lumber.thickness() * 2 )
            .alongX()
            .frontTo( front.back )
            .topTo( front.top )
            .centerX()
            .color( "Orange" )
        val trimFrontBack = trimX.mirrorY().also()

        val trimY = trimLumber.cut( side.size.y - trimLumber.thickness() * 2 )
            .alongY()
            .leftTo( side.right )
            .topTo( front.top )
            .centerY()
            .color( "Orange" ).darker()
        val trimSides = trimY.mirrorX().also()

        // NOTE, add a mitre at each end, and cut a slot in the trim using the table saw.
        val trimExtras = extraLumber.cut( side.size.y - 6 )
            .alongY2()
            .leftTo( side.right )
            .topTo( front.top + 6 )
            .color( "Orange" ).darker()
            .repeatX( across -1, traySize.x + gap.x / 2 )
            .centerXY()

        val trimExtras2 = extraLumber.cut( traySize.x )
            .alongX2()
            .topTo( front.top )
            .repeatX( across, traySize.x + gap.x / 2 )
            .repeatY( 0, traySize.y + gap.y / 2 )
            .centerXY()
            .color( "Orange" )

        val trays = Cube(traySize)
            .bottomTo(supports.top)
            .tileX( across, gap.x )
            .tileY( back, gap.y )
            .centerXY().previewOnly()

        return frontBack + trimFrontBack + trimSides + trimExtras + trimExtras2 + sides + supports + trays
    }
}