FooCAD Source Codeimport uk.co.nickthecoder.foocad.smartextrusion.v1.*
import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.*
import uk.co.nickthecoder.foocad.screws.v3.*
import uk.co.nickthecoder.foocad.extras.v1.*
import static uk.co.nickthecoder.foocad.extras.v1.Extras.*
class PlainShelfBracket : Model {
@Custom
var depth = 150
@Custom
var width = 20
@Custom
var thickness = 6
@Custom( about="How much protudes beyond the triangular support" )
var overlap = 16
@Custom( about="Rounding inside the triangle" )
var round = 5
@Custom( about="Rounding of the ends" )
var round2 = 5
@Custom
var chamfer = 1
@Custom( about="Angle of the triangular support (Usually 45° or less)" )
var angle = 35
meth height() = depth * tan( angle )
meth plainBracket() : Shape3d {
val height = height()
val triangle = Triangle( depth - overlap, height - overlap )
val inside = triangle.offset( - thickness )
.roundCorner( 2, round )
.roundCorner( 1, round )
.roundCorner( 0, round * 2 )
val main = (triangle - inside)
.smartExtrude(width)
.edges( Chamfer( chamfer ) )
val top = Square( depth, width )
.roundCorner(2,round2)
.roundCorner(1,round2)
.smartExtrude( thickness )
.bottom( Chamfer( chamfer ) )
.rotateX(90)
.frontTo(0)
.rightTo( depth )
val side = Square( height, width )
.roundCorner(2,round2)
.roundCorner(1,round2)
.smartExtrude( thickness )
.bottom( Chamfer( chamfer ) )
.rotateX(90)
.frontTo(0)
.rightTo( height )
.rotateZ(90).mirrorX()
return main + side + top
}
override meth build() = plainBracket()
}
class ShelfBracket : PlainShelfBracket() {
@Custom
var countersink = Countersink()
meth topHoles() : Shape3d {
return countersink
.rotateX(-90)
.centerZTo( width/2 )
.backTo( thickness )
.leftTo( thickness + round*2 + 6 )
.centerXTo( depth - overlap/2 - thickness*0.6 ).also()
}
meth sideHoles() : Shape3d {
val height = height()
return countersink
.rotateY(90)
.centerZTo( width/2 )
.rightTo( thickness )
.frontTo( thickness + round*2 + 6 )
.centerYTo( height - overlap/2 - thickness*0.6 ).also()
}
override meth build() : Shape3d {
val plain = super.build()
val topHoles = topHoles()
val sideHoles = sideHoles()
return plain - topHoles - topHoles - sideHoles
}
}