Exit Full View
Up

/Garden/PlantLabelHolder.foocad

PlantLabelHolder
FooCAD Source Code
import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.*

class PlantLabelHolder : Model {
    
    @Custom( about="Size of the plant label" )
    var labelSize = Vector3( 60, 18, 1.5 )

    var size = Vector3( 100, 30, 4.5 )

    var slack = Vector2( 1.0, 0.3 )

    var chamfer = 1.0

    override fun build() : Shape3d {
        val outline = PolygonBuilder().apply {
            radius(size.y/3)
            moveTo(0,0)
            lineTo(0,size.y)
            lineTo(size.x,size.y)
            radius(1)
            lineTo(size.x + size.y*1.5,size.y/2)
            radius(5)
            lineTo(size.x,0)         
        }.build().centerY()

        val labelOutline = PolygonBuilder().apply {
            moveTo(0,0)
            lineTo(0,labelSize.y)
            lineTo(labelSize.x,labelSize.y)
            radius(1)
            lineTo(labelSize.x + labelSize.y*1.5,labelSize.y/2)
            radius(5)
            lineTo(labelSize.x,0)         
        }.build().centerY()
            .offset(slack.x)

        val slot = labelOutline.extrude(labelSize.z+slack.y) +
            labelOutline.chamferedExtrude( size.z *0.8, slack.x )

        return outline.chamferedExtrude(size.z, chamfer) - slot.bottomTo( size.z*0.24)
    }
}