Exit Full View
Up

/Garden/SaladPot.foocad

SaladPot
FooCAD Source Code
class SaladPot : Model {

    // The default size is a quarter of a standard seed tray (but taller)
    @Custom( about="External size of the pot" )
    var size = Vector3( 240/2, 390/2, 70 )

    @Custom( about="Taper the edges to allow the pots to stack inside each other" )
    var taper = 10

    @Custom( about="Radius of the corners" )
    var radius = 12

    @Custom( about="Thicknes of the base" )
    var baseThickness = 2.0

    @Custom( about ="Thickness of the walls")
    var thickness = 0.8

    @Custom( about="Extra thickness at the top")
    var rimThickness = 2.0 

    @Custom( about="Width of the thick part of the base. 0 makes the whole base thick." )
    var baseOffset = 5

    var feetHeight = 6

    var feetThickness = 2

    @Piece
    fun pot() : Shape3d {
        val profile = Square( size.x -rimThickness*2, size.y -rimThickness*2 ).roundAllCorners(radius).center()
        val bottom = Square( size.x - taper -rimThickness*2, size.y -taper -rimThickness*2 ).roundAllCorners(radius).center()
        return ExtrusionBuilder().apply {
            crossSection( bottom )
            forward( size.z - rimThickness*4 )
            crossSection( profile )
            forward( rimThickness*3 )
            crossSection(rimThickness)
            forward( rimThickness )
            crossSection()
            crossSection(-thickness-rimThickness)
            forward( -size.z + baseThickness )
            crossSection(bottom.offset(-thickness))

            if (baseOffset > 0) {
                crossSection( -baseOffset )
                forward( -baseThickness + thickness )
                crossSection()
            }

        }.build()
    }

    /*
        Lifts the pot up a little, allowing water to drain away. Glue this part to the bottom of the pot.
        Could "weld" it in place by stabbing through the two parts with a hot tool, such as a soldering iron,
        or heated bradawl.
    */
    @Piece
    fun feet() : Shape3d {
        val bottom = Square( size.x - taper -rimThickness*2, size.y -taper -rimThickness*2 ).roundAllCorners(radius).center()
        return ExtrusionBuilder().apply {
            crossSection( bottom )
            forward( feetHeight )
            crossSection()
            crossSection( -feetThickness )
            forward( -feetHeight + thickness )
            crossSection()
            crossSection( -10 )
            forward(-thickness )
            crossSection()
        }.buildClosed().color("Orange")
    }

    override fun build() : Shape3d {
        return (pot() + feet().mirrorZ()).toOriginZ()
    }
}