Exit Full View
Up

/Christmas/NamedBauble.foocad

NamedBauble

NOTE. This SLOW to render in OpenSCAD. MY first attempt used a single cylinder with LOTS of hole punched in it but this was rediculously slow (I gave up waiting for it to render!) This implementation is still slow, but not unbearable!

NOTE. using resolutionX(3) caused the whole model to render to nothing! Not sure why, but I suspect it relates to total complexity of the model exceeding a maximum value in OpenSCAD.

FooCAD Source Code
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*

class NamedBauble : Model {
    
    var name = "STEVE  ♥  KATY  ♥  "

    var size = 60.0

    var thickness = 1.0

    var hole = 1.6

    var repeat = 6

    var around = 50

    fun ring(size : double ) : Shape3d {
        val text = ExtrusionBuilder.extrude(Text(name,BOLD).resolutionX(5),thickness*1.5)
            
        val scaledText = text.scale( size / 2 /text.size.x*6, size * 0.25 / text.size.y, 1 ).center()
        val height = scaledText.size.y * 1.2

        val l = height * Math.sqrt(2) / repeat
        
        val grid = Cube( l/4, l, l/4 )
            .tileY(repeat)
            .rotateZ(45).center()
            .repeatX(around,Math.PI * size / around)
            .aroundCylinder( size/2, true )
            .rotateX(90)
            .mirrorX().also()

        val topAndBottom = (Circle(size/2 + thickness/2) - Circle( size/2 - thickness/2))
            .extrude(2).translateZ(height/2)
            .mirrorZ().also()

        val around = scaledText.aroundCylinder( size/2, true )
        val oriented = around.rotateX(90)

        val hooks = (Circle( 4 ).sides(3) - Circle( 2 ).sides(3))
            .extrude( thickness )
            .center()
            .rotateY(-90)
            .translate( size/2, 0, height + 6 )
            .repeatAroundZ( 3 )

        return (oriented + topAndBottom + grid).toOriginZ() + hooks
        
    }
    
    override fun build() : Shape3d {
        return ring( size ) // + ring( size * 0.8 )
    }

}