import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.* import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.* import static uk.co.nickthecoder.foocad.changefilament.v1.ChangeFilament.* /** A thin disk to stick onto the bottom of a round plant pot to customise it. I use it to add birthday greetings. */ class PotBase : Model, PostProcessor { @Custom( required=false ) var topString = "Happy\nBirthday" @Custom( required=false ) var middleString = "" @Custom( required=false ) var bottomString = "Amanda\n2021" @Custom var style = TextStyle( BOLD, 8 ).hAlign( CENTER ) @Custom var gap = 0 @Custom var diameter = 94 @Custom var thickness = 1.0 @Custom var thin = 0.4 @Custom var rimWidth = 5 @Custom var rimThickness = 2 @Custom var holeCount = 5 @Custom var holeDiameter = 13 // 11 @Custom var holeOffset = 63 / 2 @Custom( about="Include a pause to change filament, so that the writing is a different colour?" ) var pause = true override fun build() : Shape3d { val circle = Circle( diameter/2 ).sides( 60 ) val middleText : Shape2d = if (middleString == "") { Square(0) } else { Text( middleString, style ).centerY() } val topText = Text( topString, style ).frontTo( middleText.back + gap ).centerX() val bottomText = Text( bottomString, style ).backTo( middleText.front - gap ).centerX() val rim = (circle - circle.offset( - rimWidth ) ).extrude( rimThickness ) val hole = Circle( holeDiameter / 2 ) val holes = if ( holeCount == 1 ) { hole } else { hole.translateX( holeOffset ).repeatAround( holeCount ) } val holedCircle = circle - holes return rim + holedCircle.extrude(thin).color("Black") + (holedCircle - topText - middleText - bottomText).extrude( thickness ) } override fun postProcess(gcode: GCode) { if (pause) { pauseAtHeight( gcode, thin, "Change Filament" ) } } }