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 { @Custom( about="Overall size of the cabinet (not including the feet)" ) var size = Vector3( 1000, 220, 700 ) @Custom( about="Thicknessness of the plywood" ) var sheetThickness = 12 @Custom( about="The shelves are inset from the front" ) var shelfOffset = 8 @Custom( about="The rounded corner has a flat part, i.e. the rounding does go all the way to the back." ) var flat = 50 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 shelfWidth = size.x - size.y - sheetThickness val cornerBack = Cube( size.y - sheetThickness, sheetThickness, size.z - sheetThickness*2 ) .label( "cornerBack" ) .backTo( bottom.back ) .rightTo( bottom.right ) .bottomTo( bottom.top ) .color( "LightBlue" ).darker() val divider = Cube( sheetThickness, size.y, size.z - sheetThickness*2 ) .label( "divider" ) .backTo( bottom.back ).leftTo( bottom.left ).bottomTo( bottom.top ) .rightTo( cornerBack.left ) .color( "LightBlue" ) val curvedShelf = Square( size.y - sheetThickness - shelfOffset ) .roundCorner( 1, size.y - flat - shelfOffset ) .extrude( sheetThickness ) .label( "curvedShelf" ) .leftTo( divider.right ) .backTo( cornerBack.front ) .centerZTo( size.z * 0.5 ) val shelves = Cube( shelfWidth, size.y - shelfOffset, sheetThickness ) .label( "shelf" ) .leftTo( side.right ) .backTo( bottom.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 + divider + cornerBack + shelves + curvedShelf + feet } }