Exit Full View
Up

/Words/DogLabel2.foocad

DogLabel2
FooCAD Source Code
import static uk.co.nickthecoder.foocad.changefilament.v1.ChangeFilament.*

/*
Poppy tested the old DogLabel and they only lasted a year or so. The outline came off,
and then one of the telephone number digits came off.
So this version uses indentations on BOTH sides, which should make it more durable (but less pretty).

I recommend printing in 3 colours.
I chose Dark Red, Pink, Black, but the pink and red were a bit too see through
and the darkness from the phone number was apparent from the back.

*/

class DogLabel2 : Model, PostProcessor {
    

    // Your phone number
    @Custom(lines=2)
    var front = "PHONE\nNUMBER"

    // Your pet's name
    @Custom
    var back = "NAME"

    var thickness = 2.0
    var bottomIndent = 0.8
    var topIndent = 0.4

    override fun build() : Shape3d {

        val frontText = Text( front, 7 ).hAlign(CENTER).center()
            .extrude( thickness )
            .bottomTo(thickness - topIndent)
            .color( "Green" )
        
        val backText = Text( back, BOLD, 9 ).hAlign(CENTER)
            .offset(0.2) // Make it bolder
            .mirrorX().center()
            .extrude( thickness ).topTo(bottomIndent)

        val width = Math.max( frontText.size.x, backText.size.x )
        val height = Math.max( frontText.size.y, backText.size.y )

        val hoop = (Circle( 10 ).translateY(-2) - Circle( 5 ))
            .translateY( height - 10 )
        
        val main = Square(width + 5, height + 2).center().roundAllCorners(5)
        
        val both = hoop + main
    
        val outline = (both.offset(0.1) - both.offset(-0.8)).extrude(thickness)
            .bottomTo(thickness - topIndent)
            .color("Green")

        return both.extrude(thickness) - backText - frontText - outline
    }

    // This is the main focus of this example! Also not that the class must implement PostProcessor.
    override fun postProcess(gcode: GCode) {
        gcode.pauseAtHeight( bottomIndent, "Change Filament" )
        gcode.pauseAtHeight( thickness - topIndent, "Change Filament" )
    }
}