import uk.co.nickthecoder.foocad.smartextrusion.v1.* import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.* import uk.co.nickthecoder.foocad.screws.v3.* class PipeClip : Model { @Custom var diameter = 69.0 @Custom var width = 10.0 @Custom var thickness = 3.5 @Custom var gap = 60 @Custom var blockSize = Vector3( 4, 40, 10 ) @Piece @Slice( brimWidth=5 ) meth clip() : Shape3d { val r = diameter /2 + thickness/2 val shape = PolygonBuilder().apply { moveTo(0,0) circularArcBy( Vector2(-r*0.2, r*0.1), r*0.2, false, true ) circularArcBy( Vector2(0,gap), r, true, false ) circularArcBy( Vector2(r*0.2, r*0.1), r*0.2, false, true ) }.buildPath() .thickness( thickness ) .centerY() .leftTo(-diameter/2-thickness) val main = shape.smartExtrude( width ) .edges( Chamfer( 0.5 ) ) val block = Square( blockSize.x, blockSize.y ) .roundAllCorners(1) .centerY() .rightTo( shape.left + thickness ) .smartExtrude( width + blockSize.z ) .edges( Chamfer(1) ) val screwHoles = Countersink() .rotateY(90) .rightTo( block.right ) .centerZTo( width + blockSize.z/2 - 1 ) .centerYTo( blockSize.y * 0.3 ) .mirrorY().also() return main + block - screwHoles } @Slice( brimWidth=5 ) override fun build() : Shape3d { val pipe = Cylinder(50, diameter/2).previewOnly() return clip() + pipe } }