import uk.co.nickthecoder.foocad.extras.v1.* import static uk.co.nickthecoder.foocad.extras.v1.Extras.* import uk.co.nickthecoder.foocad.cup.v1.* import static uk.co.nickthecoder.foocad.cup.v1.Cup.* import uk.co.nickthecoder.foocad.smartextrusion.v1.* import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.* class GroundSpikeCover : Model { @Custom( about="Diameter of the main tube" ) var diameter = 41 @Custom( about="Depth of the tube") var depth = 20 @Custom( about="Thickness of the walls" ) var thickness = 1.2 @Custom( about="Width and thickness of the overlap, making it easier to see, and shielding from rain." ) var overlap = Vector2(8, 5) @Custom( about="Depth of the hole which aids lifting" ) var handleDepth = 8 @Piece @Slice( fillDensity=5 ) meth plain() : Shape3d { val capShape = Circle( diameter/2 + overlap.x ) val cap = capShape .smartExtrude( overlap.y ) .bottom( ProfileEdge.fillet(3) ) .top( ProfileEdge.step( 3, -2 ) and ProfileEdge.step( 2, 2 ) ) val outside = Circle( diameter/2 ) val tube = outside .cup( depth, thickness ) .baseThickness( 0.1 ) .insideBottom( ProfileEdge.fillet( 3 ) ) //.outsideBottom( ProfileEdge.fillet( 3 ).reverse() ) .insideTop( ProfileEdge.chamfer( -2 ) and ProfileEdge.flat(2)) .outsideTop( ProfileEdge.chamfer( 1 ) ) .bottomTo( cap.top ) return cap + tube } @Piece( about="Only suitable for larger covers" ) meth withHandle() : Shape3d { val plain = plain() val handleCircle = Circle( diameter/2 ) val recess = Cup( handleCircle, handleDepth, thickness*1.5 ) .cavity( true ) .insideBottom( Fillet( handleDepth/4 ) ) .insideTop( Chamfer( 1 ) ) .mirrorZ() .bottomTo(0) val insideFillet = Cup( handleCircle, handleDepth, thickness ) .insideBottom( Fillet(5) ) .bottomTo( recess.top - thickness+0.1 ) val handleShape = ProfileEdge.mouldingExtra( thickness, handleDepth - thickness*1.5, ProfileEdge.chamfer(-1), ProfileEdge.chamferedStep( -1, 2 ) ).mirrorX().also() val handle = handleShape .extrude( recess.size.x - thickness ) .rotateX(90).centerY() return plain and insideFillet and recess insert handle } @Piece( about="Adds a lip, to help lift up the cover" ) meth withPullup() : Shape3d { val plain = plain() val handleCircle = Circle( diameter/ 2 ) val recess = Cup( handleCircle, handleDepth, thickness*1.5 ) .cavity( true ) .insideBottom( Chamfer( handleDepth/4 ) ) .insideTop( Chamfer( 1 ) ) .mirrorZ() .bottomTo(0) val insideFillet = Cup( handleCircle, handleDepth, thickness ) .insideBottom( Fillet(5) ) .bottomTo( recess.top - thickness+0.1 ) val pullup = Segment( diameter/2, -60, 60 ) .extrude( thickness*1.5 ) return plain and recess and insideFillet insert pullup } @Piece( print="withHandle" ) override fun build() : Shape3d { return withHandle().mirrorZ().bottomTo( 0 ) } }