import static uk.co.nickthecoder.foocad.screws.v1.Screws.* import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.* class BallHolderRails : Model { @Custom var railD = 9 @Custom var thickness = 14 @Custom var chamfer = 2 // The distance of the two rails. // Due to a bug in FooCAD, some values fail - just adjust slightly and try again. Soz. @Custom var spacing = 60 fun bracket( center : bool ) : Shape3d { val doc = SVGParser().parseFile( "ballHolderRails.svg" ) val scale = spacing / (doc.shapes["rod2"].left - doc.shapes["rod1"].left) val profile = doc.shapes["profile"].scale(scale) val outside = Polygon(profile.paths[0]) val inside = Polygon(profile.paths[1]).offset(-chamfer) val holeDepth = if(center) thickness else thickness - 2 val c2 = 1 // if (piece == "center") 1 else 0 val holes = Circle.hole( railD/2 ).translate( doc.shapes["rod1"].scale(scale).middle ) .internalChamferedExtrude( holeDepth, 1, c2 ) + Circle.hole( railD/2 ).translate( doc.shapes["rod2"].scale(scale).middle ) .internalChamferedExtrude( holeDepth, 1, c2 ) val solid = ( outside.chamferedExtrude( thickness, chamfer ) - inside.internalChamferedExtrude( thickness, chamfer ) - holes ).center().mirrorZ() val keyHole = keyholeHanger( 4, 8 ) .rotateY(90).mirrorX() .translate( -solid.size.x/2+0.6-0.9, solid.size.y/3, 0 ) //return keyHole return solid - keyHole // + Sphere( 70/2 ).translate(6,45,0).previewOnly() } override fun build() : Shape3d { return bracket(false) } }