import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.* import static uk.co.nickthecoder.foocad.diagram.v1.Diagram.* import static uk.co.nickthecoder.foocad.arrange.v1.Arrange.* import static uk.co.nickthecoder.foocad.screws.v3.Screws.* import uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.* import static uk.co.nickthecoder.foocad.extras.v1.Extras.* class FlatBedAttachments : Model { @Custom(about="Cap is smaller than the knobs") var capSlack = 0.1 val headD = 12 val holeD = 6.6 @Piece fun boltKnob() = boltKnob( 18, Vector2(24,3), 10 ) @Piece fun boltKnob2() = boltKnob( 38, Vector2(24,2), 10 ) @Piece fun boltKnobAndCap() = arrangeX(1, boltKnob(), cap() ) @Piece fun boltKnob2AndCap() = arrangeX(1, boltKnob2(), cap() ) fun boltKnob( knobDiameter : double, size : Vector2, knobSpacer : double ) : Shape3d { val recessDepth = 8 val height = knobSpacer + recessDepth val hex = Circle( knobDiameter/2 ).sides(6).roundAllCorners( 3 ) val flat = Circle( size.x/2 ) .smartExtrude( size.y ).filletTop(size.y / 2) val knob = hex.smartExtrude( height ) .filletTop( 2 ) .chamferBottom( 1 ) val throughHole = Cylinder( 100, holeD / 2 ).center() val recess = Circle( headD/2 ).sides( 6 ).extrude( recessDepth + 0.1 ) .topTo( knob.top + 0.1 ) return flat + knob - recess - throughHole } @Piece fun cap() : Shape3d { val capHeight = 4 return Circle( headD / 2 - capSlack ).sides(6).roundAllCorners(1, 1).extrude( capHeight ) } // Print using TPU. @Piece fun washer() : Shape3d { return (Circle( boltKnob().size.x/2 ) - Circle( 4 ) ) .extrude( 2 ) } // Print using TPU. @Piece fun washer2() : Shape3d { return (Circle( 45 / 2 ) - Circle( 4 ) ) .extrude( 1.2 ) // Was 2.0 } override fun build() : Shape3d { return arrangeY( 10, arrangeX(10, boltKnob().labelFront( "boltKnob" ), washer().labelFront( "washer" ), cap().labelFront( "cap" ) ).centerX(), arrangeX(10, boltKnob2().labelFront( "boltKnob2" ), washer2().labelFront( "washer2" ) ).centerX() ) } }