import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.* import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.* import uk.co.nickthecoder.foocad.woodworking.v1.* import static uk.co.nickthecoder.foocad.woodworking.v1.Woodworking.* include AdjustableFoot.foocad class LandingCabinet : Model { var size = Vector3( 1000, 220, 700 ) var sheetThickness = 12 var backThickness = 8 val sideOffset = 10 var shelfOffset = 15 var flat = 30 meth adjustableFoot() = AdjustableFoot().apply { diameter = 20 height = 11 holeCount = 1 extraRodHeight = 0 } @Piece meth foot() : Shape3d { val width = 28 val height = 30 val taper = 4 val profile = PolygonBuilder().apply { moveTo(0,0) lineBy(width/2, 0) lineBy(-taper, height) lineBy(-width/2+taper,0) }.build().roundCorner(2, 2, 1) return adjustableFoot().customFoot( profile ) } @Piece meth footBase() : Shape3d { return adjustableFoot().rod().rotateX(180).bottomTo(0) } override fun build() : Shape3d { val bottom = Square( size.x, size.y ) .roundCorner(1, size.y - flat ) .extrude( sheetThickness ) .label( "bottom" ) .centerXY() .color("Green") val top = bottom.topTo( size.z ) //.previewOnly() val side = Cube( sheetThickness, size.y, size.z - sheetThickness*2 ) .label( "side" ) .backTo( bottom.back ).leftTo( bottom.left ).bottomTo( bottom.top ) .color( "LightGreen" ) val post = Cube( shelfOffset, sheetThickness, side.size.z ) .label( "post" ) .bottomTo( bottom.top ) .rightTo( bottom.right ) .backTo( bottom.back ) .color( "LightGreen" ) val back = Cube( size.x - sheetThickness, backThickness, size.z - sheetThickness ) .label( "back" ) .centerX() .backTo( bottom.back ) .bottomTo( sheetThickness/2 ) .color( "GhostWhite" ) val curvedShelf = Square( size.y - shelfOffset - backThickness ) .roundCorner( 1, size.y - flat - shelfOffset ) .extrude( sheetThickness ) .label( "curvedShelf" ) .rightTo( bottom.right - shelfOffset ) .backTo( size.y/2 - backThickness ) .bottomTo( size.z * 0.45 ) val underCurvedShelf = Cube( curvedShelf.size.x, sheetThickness, 20 ) .label( "underCurvedShelf" ) .leftTo( curvedShelf.left ) .backTo( curvedShelf.back ) .topTo( curvedShelf.bottom ) .color( "lightGreen" ) val shelfWidth = (curvedShelf.left - side.right - sheetThickness) val divider = Cube( sheetThickness, size.y - sideOffset - backThickness, size.z - sheetThickness*2 ) .label( "divider" ) .backTo( bottom.back - backThickness ).leftTo( bottom.left ).bottomTo( bottom.top ) .leftTo( side.right + shelfWidth ) //.previewOnly() .color( "LightBlue" ) val shelves = Cube( shelfWidth, size.y - shelfOffset - backThickness, sheetThickness ) .label( "shelf" ) .leftTo( side.right ) .backTo( curvedShelf.back ) .repeatZ( 2, size.z/3 ) .centerZTo( size.z / 2 ) val feet = foot().mirrorZ() .leftTo( bottom.left + 20 ) .frontTo( bottom.front + 20 ) .mirrorY().also() .rightTo( divider.left - 20 ).also() + foot() .mirrorZ() .rightTo( bottom.right - 20 ) .backTo( bottom.back - 20 ) return bottom + top + side + post + back + divider + shelves + curvedShelf + underCurvedShelf + feet } }