Exit Full View
Up

/Garden/USection.foocad

USection
FooCAD Source Code
/*
Extruded U section.
*/

class USection : Model {
    
    @Custom
    var internal = Vector2( 6, 6 )

    // If non-zero, then an extra piece is addded on one side
    // I am going to use it for attaching it with screws
    @Custom
    var tab = 6

    @Custom
    var thickness = 1.2

    @Custom
    var length = 200

    // For a right angled piece.
    @Custom
    var lengthZ = 50


    override fun build() : Shape3d {
        val profile = Square( internal.x + thickness*2, internal.y + thickness).centerX() -
            Square( internal.x, internal.y ).translateY( thickness ).centerX() +
            Square( tab, thickness ).translateX( internal.x /2 + thickness )

        return if (length == 0) {
            profile.extrude( length ).rotateX(-90).mirrorZ()
        } else {
            profile.extrude( lengthZ ) +
            profile.extrude( length ).rotateX(-90).mirrorZ()
        }
    }
}