import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.* import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.* class SeedModuleGrid : Model { @Custom( about="Width of the holes (slightly bigger than the pot width, excluding the rim" ) var width = 67.0 // Was 65 @Custom( about="Gap bewteen the holes" ) var gap = Vector2(5.0, 9.0) // was 4 @Custom( about= "Radius of the pots" ) var cornerRadius = 8 @Custom( about="Quantity of pots in the X direction" ) var gridAcross = 3 @Custom( about="Quantity of pots in the Y direction" ) var gridDown = 2 @Custom( about="External size of the tray" ) var traySize = Vector2( 221, 164) @Custom( about="Radius of the tray's corners") var trayRadius = 18 @Custom( about="Used for an 'exclusion' area where no ribs can be created. Often not needed!" ) var trayLip = 5.0 @Custom( about="Thickness of the top sheet" ) var sheetThickness = 0.9 @Custom( about="Thickness of the ribbing, which gives the grid strength" ) var gridThickness = 1.2 @Custom( about="Height of the ribbing, which gives the grid strength" ) var gridHeight = 6.0 @Custom( about="Print in two halves, and then glue them together" ) var cutAt = 3 fun build( cutAt : int ) : Shape3d { val holes = Square( width ).roundAllCorners( cornerRadius ) .tileX( gridAcross, gap.x ) .tileY( gridDown, gap.y ) .center() val sheet = Square( traySize + Vector2( gridThickness, gridThickness ) * 2 ) .roundAllCorners( trayRadius + gridThickness ) .center() val top = (sheet - holes).extrude( sheetThickness ) val ribsX = Square( gridThickness, gridDown* (width+gap.Y) - gap.y + gridThickness ) .repeatX( gridAcross - 1, width + gap.x ) .center() val ribsY = Square( gridAcross*(width+gap.x) - gap.x + gridThickness, gridThickness ) .repeatY( gridDown - 1, width + gap.y ) .center() val ribs = ribsX + ribsY val margin = Math.min( sheet.size.x - ribs.size.x, sheet.size.y - ribs.size.y ) /2 val ribOutline = Square( ribs.size.x + gridThickness, ribs.size.y + gridThickness ).center() .roundAllCorners( cornerRadius + gridThickness ) val ribsRing = (ribOutline - ribOutline.offset(-gridThickness) ) val edge = (sheet - sheet.offset(-gridThickness)) val exclusion : Shape2d = ( Square( traySize ).roundAllCorners(trayRadius).center() - Square( traySize - Vector2( trayLip, trayLip ) * 2 ).roundAllCorners(trayRadius-trayLip).center() ) val tray = exclusion.extrude( 2 ).bottomTo( sheetThickness ).previewOnly() val solid = (ribs + ribsRing + edge - exclusion ).extrude( gridHeight ) .bottomTo(0.01) .color("Orange") if (cutAt > 0) { val overlap = Cube( top.size.x, top.size.y + 2, solid.size.z + 2 ) .centerY().bottomTo(-1).rightTo( ribsX.right - (width + gap.x) * (gridAcross - cutAt-1) ) val cut = (top + solid) / overlap val extra = Cube( gridThickness*2, ribsX.size.y + gridThickness, gridHeight*2 ) .centerY().rightTo(overlap.right ) .color("Red") return cut + extra } return top + solid + tray } @Piece fun cutA() = build( cutAt ) @Piece fun cutB() = build( gridAcross - cutAt ) override fun build() = build( 0 ) }