FooCAD Source Codeimport static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
include SimplePlantPot.foocad
class SimplePlantPotGrid : Model {
// "standard" Wilko sizes : Small67x80. Medium=90x100
@Custom( about="Exterior size of the pot. Does not include the feet thickness" )
var potSize = Vector2( 67, 80 )
@Custom( about= "Exterior width of the bottom of the pot" )
var potBottomWidth = 52
@Custom
var potCornerRadius = 10
@Custom( about="The thickness of the pot's rim" )
var rimThickness = 2.0
@Custom
var gridAcross = 3
@Custom
var gridDown = 3
@Custom
var gridThickness = 1.2
@Custom
var gridHeight = 6.0
// NOTE, we need individual margins, because I will be printing the grid in two parts,
// and gluing them together. Each piece will have 3 margins set, and the other at 0.
@Custom( about="The height that this grid meets the pot. 0 for ground level")
var forHeight = 0.0
@Custom( about="Additional margin left/right (to overlap a tray?)" )
var extraMarginX = 0.0
@Custom( about="Additional margin front/back (to overlap a tray?)" )
var extraMarginY = 0.0
@Custom
var extraMarginIgnoreFront = true
@Piece
fun grid() : Shape3d {
val simplePlantPot = SimplePlantPot().apply {
size = potSize
bottomWidth = potBottomWidth
cornerRadius = potCornerRadius
}
val pot = simplePlantPot.pot()
val offset = 1 + (potSize.x - potBottomWidth)/2 * (forHeight / potSize.y)
val inside = simplePlantPot.bottom().offset(offset)
val profile = inside.offset( gridThickness ) - inside
val margin = (pot.size.x - profile.size.x ) / 2
val grid = profile
.repeatX( gridAcross, pot.size.x )
.repeatY( gridDown, pot.size.y )
.extrude( gridHeight )
.centerXY()
.color("Red")
val wings = Square( margin + gridThickness, gridThickness )
.frontTo( profile.front + potCornerRadius + gridThickness + offset )
.rightTo( profile.left + gridThickness )
.mirrorX().also()
.mirrorY().also()
.rotate(90).also()
.extrude( gridHeight )
val gridOfWings = wings
.repeatX( gridAcross, pot.size.x )
.repeatY( gridDown, pot.size.y )
.centerXY()
val borderOut = Square(
grid.size.x + margin*2 + extraMarginX*2,
grid.size.y + margin*2 + extraMarginY + (if extraMarginIgnoreFront 0 else extraMarginY)
)
.roundAllCorners( potCornerRadius + margin + offset )
val border = (borderOut - borderOut.offset(-gridThickness ) )
.extrude( gridHeight )
.centerXY()
.translateY(if (extraMarginIgnoreFront) extraMarginY/2 else 0)
.color("Green")
val wingsLeft = if ( extraMarginX < 0 ) {
Square(0)
} else {
Square( extraMarginX, gridThickness )
.frontTo( profile.front + potCornerRadius + gridThickness + offset )
.mirrorY().also()
.repeatY( gridDown, pot.size.y )
.centerY()
.leftTo( border.left )
}
val wingsRight = if ( extraMarginX < 0 ) {
Square(0)
} else {
Square( extraMarginX, gridThickness )
.frontTo( profile.front + potCornerRadius + gridThickness + offset )
.mirrorY().also()
.repeatY( gridDown, pot.size.y )
.centerY()
.rightTo( border.right )
}
val wingsFront = if ( extraMarginY < 0 || extraMarginIgnoreFront ) {
Square(0)
} else {
Square( gridThickness, extraMarginY )
.leftTo( profile.left + potCornerRadius + gridThickness + offset )
.mirrorX().also()
.repeatX( gridAcross, pot.size.x )
.centerX()
.frontTo( border.front )
}
val wingsBack = if ( extraMarginY < 0 ) {
Square(0)
} else {
Square( gridThickness, extraMarginY )
.leftTo( profile.left + potCornerRadius + gridThickness + offset )
.mirrorX().also()
.repeatX( gridAcross, pot.size.x )
.centerX()
.backTo( border.back )
}
val marginWings = (wingsLeft + wingsRight + wingsFront + wingsBack).extrude(gridHeight)
val pots = pot.tileX(gridAcross).tileY(gridDown).previewOnly().centerXY()
return grid + border + gridOfWings + marginWings//+ xLine + yLine //+ pots
}
override fun build() = grid()
}