import uk.co.nickthecoder.foocad.smartextrusion.v1.* import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.* import uk.co.nickthecoder.foocad.extras.v1.* import static uk.co.nickthecoder.foocad.extras.v1.Extras.* class HoleSizes : Model { @Custom var height = 3 meth chart(upright : bool) : Shape3d { var holes : Shape2d = Union2d() var text : Shape2d = Union2d() val spacing = 9.5 for ( size in 3 .. 8 ) { text += Text( "$size", 8 ) .centerXTo( size * spacing ) .frontTo( 3 ) .toPolygon() for ( adjustment in 0 .. 3 ) { val diameter = size + adjustment/4 val hole = if (upright) { Circle.hole( diameter /2 ).safeOverhang() } else { Circle.hole( diameter /2 ) } .centerXTo( size * spacing ) .centerYTo( -adjustment * spacing ) holes += hole } } for ( adjustment in 0 .. 2 step 2) { text += Text( "${adjustment/4}", 8 ) .centerYTo( -adjustment * spacing ) .rightTo( holes.left -2 ) } val rectangle = (holes+text).boundingSquare().offset( 3 ) .roundAllCorners(3) return (rectangle - holes).smartExtrude( height ).outside(Chamfer(0.4)) + text.extrude( 0.3 ).bottomTo( height ).color("White") } @Piece @Slice( brimWidth = 10 ) meth upright() : Shape3d { return chart( true ).rotateX(90).bottomTo(0) } override fun build() : Shape3d { return chart( false ) } }