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.* class BungeeClip : Model { @Custom var thickness = 14 @Custom var chamfer = 1.5 @Custom var holeSize = Vector2( 3, 3 ) @Custom var holeCount = 3 override fun build() : Shape3d { val doc = SVGParser().parseFile( "bungeeClip.svg" ) val fiveShape = doc.shapes["fivecm"] // A 5cm rectangle. Used to scale to the correct size. val scale = 50.0 / fiveShape.size.x val mainShape = doc.shapes["main"].scale(scale) val holeShape = doc.shapes["hole"].scale(scale) val main = mainShape.chamferedExtrude( thickness, 1 ) val hole = holeShape .scaleY( holeSize.y / holeShape.size.y ) .centerTo( holeShape.middle ) .extrude( holeSize.x ) val holes = hole.repeatZ( holeCount, (thickness-chamfer)/holeCount ).centerZTo(main.middle.z ) return (main - holes).centerXY() } }