/Boxes/UnderPrinter.foocad

The X stepper motor overhangs the sides of the printer, and one day I left a drinks can under it. When the gratry lowered the gantry jammed against the can, making a dreadful sound.
This item prevents that from happening again. The dovetail is glued to the side of the printer, and the box fits in the dovetail. Now I can't accidentaly leave something there.
import uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion
import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.*
import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.*
import static uk.co.nickthecoder.foocad.extras.v1.Extras.*
class Clearance : AbstractModel() {
@Custom
var size = Vector3( 50, 40, 40 )
@Custom
var thickness = 1.1
fun dovetail() = (Triangle(7) hull Triangle(7).translateX(20))
.roundCorner(1,1)
.roundCorner(0,1)
.centerX().backTo(0)
@Piece
fun attachment() : Shape3d {
return dovetail().extrude( 20 ).rotateX(-90)
}
@Piece
fun box() : Shape3d {
val square = Square( size.x, size.y )
.roundAllCorners(3)
.centerX().backTo(0)
val dovetail = dovetail().offset(0.5)
val outside = square - dovetail
val inside = Square( size.x, size.y + dovetail.front )
.roundAllCorners(3)
.offset( -thickness )
.centerX().frontTo( outside.front + thickness )
val box = outside
.chamferedExtrude(size.z, 2, 0) -
inside.chamferedExtrude(size.z, 2, 0).translateZ(thickness)
return box // shape.extrude( size.z )
}
@Piece
fun lid() : Shape3d {
val height = 10
val outside = Square( size.x, size.y - dovetail().size.y -thickness/2).centerX()
.roundAllCorners(3,6)
val inside = outside.offset( -thickness - 0.4 )
val top = Square( size.x-12, 12 ).translateY(6).centerX().offset(-2)
.roundAllCorners(2,6)
return ExtrusionBuilder().apply {
crossSection( top )
forward( height )
crossSection( outside )
forward(1)
crossSection()
crossSection( inside )
forward(2)
crossSection()
crossSection( - thickness )
forward( -2 -1 )
crossSection()
forward( -height + thickness )
crossSection( top.offset(-thickness) )
}.build().color( "Orange")
}
@Piece( printable = false )
override fun build() : Shape3d {
val box = box()
val attachment = attachment().rotateX(90).color("Green")
val lid = lid().rotateX(180).bottomTo( box.top + 0 ).frontTo( box.front )
return box + attachment + lid
}
}
