FooCAD Source Codeimport uk.co.nickthecoder.foocad.smartextrusion.v1.*
import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
import static uk.co.nickthecoder.foocad.arrange.v1.Arrange.*
import uk.co.nickthecoder.foocad.threaded.v2.*
import static uk.co.nickthecoder.foocad.threaded.v2.Thread.*
import static uk.co.nickthecoder.foocad.extras.v1.Extras.*
class CornerClamp : AbstractModel() {
@Custom( about="Max width of wood that can fit in the clamp" )
var gap = 65
@Custom( about="Length,thickness,height" )
var blockSize = Vector3(60, 5, 30)
@Custom
var baseThickness = 6
@Custom
var footThickness = 5
var wallThickness = 16
@Custom
var thread = Thread(10)
.headSize(Vector2(20,10))
.headChamfer(1)
.rodChamfer(0.1)
.clearance(0.3)
@Piece
fun bolt() : Shape3d {
return thread.bolt( gap + wallThickness ).color("Orange")
}
@Piece
fun foot() : Shape3d {
val base = Square( blockSize.x/2, blockSize.z - 2 )
.center()
.roundAllCorners(3)
.extrude( footThickness )
val hole = thread.threadedHole( base.size.z - 0.5 )
.clipped(true)
.topTo( base.top )
return (base - hole).color("Orange").darker()
}
@Piece
fun clamp() : Shape3d {
val triangle = Triangle( blockSize.x, blockSize.x )
.roundAllCorners(2)
.rotate(180)
val block = triangle
.smartExtrude( baseThickness + blockSize.z )
.edges( Chamfer(1) )
val baseShape = Square( blockSize.x + gap + wallThickness )
.roundCorner(0,blockSize.x,1)
.roundAllCorners(10)
.leftTo( -blockSize.x )
.frontTo( -blockSize.x )
val gaps = Square( 100, 4 ).centerY().translateX(-10).rotate(45) +
Square( 4, gap*7/8 ).centerX().translateY( gap/4 ).rotate(-90).also()
val base = ( baseShape - gaps )
.smartExtrude( baseThickness )
.edges( Chamfer(1) )
val wallShape = Square( baseShape.size.x - 9, wallThickness )
.rotate(90).mirrorX().also(2).rotate(180)
.rightTo( baseShape.right )
.backTo( baseShape.back )
val wall = wallShape
.smartExtrude( baseThickness + blockSize.z )
.edges( Chamfer(1) )
val holes = thread.threadedHole( wallThickness )
.rotateY(90)
.centerYTo( triangle.middle.y )
.centerZTo( baseThickness + blockSize.z/2 )
.rightTo( wall.right )
.rotateZ(90).centerXTo( triangle.middle.x ).also(2)
return base + block + wall - holes
}
override fun build() : Shape3d {
val bolts = bolt().tileY(2,1).rightTo(-1).frontTo(1)
val feet = foot().tileY(2,1).rightTo(-1).backTo(-1)
val clamp = clamp().leftTo(1)
return bolts + feet + clamp
}
}