import static uk.co.nickthecoder.foocad.arrange.v1.Arrange.* import uk.co.nickthecoder.foocad.threaded.v2.* import static uk.co.nickthecoder.foocad.threaded.v2.Thread.* import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.* import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.* import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.* import static uk.co.nickthecoder.foocad.screws.v2.Screws.* class AdjustableFoot : Model { @Custom var diameter = 25 @Custom var pitch = 2.0 @Custom var height = 20 @Custom var wallThickness = 6 @Custom var baseThickness = 1.2 @Custom var extraNutHeight = 0 @Custom var extraRodHeight = 2 @Custom var chamfer = 3 @Custom var holeCount = 3 var mock = false fun threaded() : Thread { val thread = Thread( diameter, 2 ) .rodChamfer( 1 ) thread.mock = mock return thread } @Piece fun nut() : Shape3d { val thread = threaded() val main = Circle( diameter/2 + wallThickness ) .sides(6).roundAllCorners(5) .chamferedExtrude( height + extraNutHeight, chamfer, 1 ) val hole = thread.threadedHole( main.top - baseThickness ) .chamferStart( false ) .clipped( true ) .topTo( main.top ) .color("Green") return main - hole } @Piece fun rod() : Shape3d { val thread = threaded() val rod = thread.threadedRod( height ) val hole = Countersink() .recess(height + extraRodHeight - 8) .mirrorZ().bottomTo(0) val holes = if (holeCount < 2) { hole } else { hole.translateX( diameter*0.25 ) .repeatAroundZ(3) } val extra = Circle(thread.coreRadius()).sides(thread.sides()) .extrude( extraRodHeight + thread.rodChamfer ) .bottomTo( height - thread.rodChamfer ) return if (mock) { rod + extra } else { rod + extra - holes } } @Custom var cornerSize = Vector2(40, 3 ) @Piece fun rodWithCorner() : Shape3d { val thread = threaded() val rod = thread.threadedRod( height ) val hole = Countersink() .recess(height + extraRodHeight - 8) .mirrorZ().bottomTo(0) val extra = Circle(thread.coreRadius()).sides(thread.sides()) .extrude( extraRodHeight + thread.rodChamfer ) .bottomTo( height - thread.rodChamfer ) val corner = Square( cornerSize.x ).center() .roundAllCorners( 3 ) .extrude( cornerSize.y ) .bottomTo( extra.top ) val offset = Math.max( diameter/2, cornerSize.x/2 - 10) val holes = hole + Countersink() .translate( offset, offset, 0 ) .mirrorZ().bottomTo(corner.bottom) .mirrorX().also() .mirrorY().also() return if (mock) { rod + corner + extra } else { rod + corner + extra - holes }.rotateX(180).bottomTo(0) } // A template to help mark pilot holes for the screws. @Piece fun template() = rod() intersection Cube( 100, 100, 0.4 ).centerXY() override fun build() : Shape3d { return arrangeX( 5, nut(), rod(), rodWithCorner() ) } }