import uk.co.nickthecoder.foocad.screws.v3.* import uk.co.nickthecoder.foocad.threaded.v2.* import uk.co.nickthecoder.foocad.smartextrusion.v1.* import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.* class PannierClip : AbstractModel() { @Custom var thickness = 24 @Custom var screwPitch = 1.5 @Custom var shimSize = Vector3( 24, 44, 2 ) @Piece meth clip() : Shape3d { val angle = -90 + 13.5 val doc = SVGParser().parseFile( "pannierClip.svg" ) val fiveP = doc.shapes["fivecm"] // A 5cm rectangle. Used to scale to the correct size. val scale = 50.0 / fiveP.size.x val main = doc.shapes["main"].scale(scale).rotate(angle) .smartExtrude( thickness ).edges(Chamfer(0.6)) .centerXY().translateX(3.5) val top = Square( 44, thickness ).roundAllCorners(2,1).center() .extrude( 3 ) .rotateX(-90) .bottomTo(0) .frontTo( main.back -3 ) val sides = Square(10, thickness).roundAllCorners(2,1) .smartExtrude( 10 ) .bottom( Chamfer(2) ) .rotateX(-90) .bottomTo(0).leftTo( top.left ).backTo( top.front ) .mirrorX().also() val holes = Thread.woodScrew( screwPitch ) .threadedHole( 16 ) .rotateX(90) .centerZTo( sides.size.z/2 ) .backTo( top.back ) .centerXTo( -17 ) .color("Red") .mirrorX().also() return main + top + sides - holes } @Piece meth washer() : Shape3d { val block = Circle(10).smartExtrude(4) .top( Chamfer(2) ) val hole = Countersink().topTo( block.top ) return block - hole } @Piece meth jig() : Shape3d { val real = clip().rotateX(-90).bottomTo(0).centerY() - Cube( 100 ).center().bottomTo( 1 ) val main = Square( 44, thickness ).roundAllCorners(3).center().extrude(1) val holes = Cylinder( 3, 2 ).bottomTo(-1).translateX( -17 ).mirrorX().also() return main - holes + real.previewOnly() } @Piece( about="The box has an uneven surface which needs shims to make flat." ) meth shim() = Square( shimSize.x, shimSize.y ).roundAllCorners(3).extrude( shimSize.z ) override fun build() : Shape3d { return clip() } }