Exit Full View
Up

/Bike/BackLightExtension.foocad

BackLightExtension

With a box on the back of my bike, the back light is too far forward. This goes between the existing fittings.

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

class BackLightExtension : Model {

    @Custom( about="The distance between the screw holes" )
    var holeDistance = 60

    @Custom( about="The length of the extension" )
    var extension = 80

    @Custom
    var height = 14

    override fun build() : Shape3d {

        val solid = Square( holeDistance + 20, extension )
            .center()
            .roundAllCorners(4)
            .chamferedExtrude( height, 1 )

        val diameter = 5.5
        val hole = Circle( diameter/2 )
            .chamferedExtrude( extension, -1, -1 )
            .center()
            .rotateX(90)
            .translate( holeDistance/2, 0, height/2 )

        val holes = hole.mirrorX().also()

        val extraLayers = Cube( 0.3, extension, 0.3 )
            .spreadX( 4, diameter )
            .centerY()
            .centerXTo( holeDistance/2 )
            .bottomTo( height/4 - diameter/4 )
            .topTo( height - height/4 + diameter/4 ).also()
            .mirrorX().also()
            .color("Red")

        return solid - extraLayers - holes
    }

}