import uk.co.nickthecoder.foocad.smartextrusion.v1.* import static uk.co.nickthecoder.foocad.smartextrusion.v1.SmartExtrusion.* import uk.co.nickthecoder.foocad.threaded.v2.* class ScrewCapThroughWall : Model { @Custom var diameter = 60 @Custom var lockHeight = 4 @Custom var capThreadHeight = 8 @Custom var baseThickness = 1.8 @Custom var wallThickness = 1.8 @Custom var flangeWidth = 8 meth assembly() : Shape3d { val thread = Thread( diameter, 2 ) .rodChamfer(1) .headChamfer(1) .nutHeight( 6 ) val capSolid = Circle( thread.diameter/2 + wallThickness ) .smartExtrude( capThreadHeight + baseThickness ) .top( ProfileEdge.roundedChamfer(3) ) val capThread = thread.threadedHole( capSolid.top - baseThickness ) .chamferEnd(false) val cap = (capSolid - capThread) .label("cap") .color("Green") val neck = thread.threadedRod( capThreadHeight + lockHeight + 1 ) .chamferBottom(false) .topTo(0) val base = Circle( thread.diameter/2 + flangeWidth ) .extrude(baseThickness) .topTo( neck.bottom ) val hole = Circle( thread.coreRadius() - wallThickness ) .extrude(20) .topTo( neck.top + 0.01 ) val lockSolid = Circle( base.right ) .extrude( 4 ) val lockThread = thread.threadedHole( lockSolid.height ) val lock = (lockSolid - lockThread) .label( "lock" ) .bottomTo( base.top + 1 ) .color("Orange") val main = (neck + base - hole) .label("main") val jig = (Circle( base.right ) - Circle( thread.diameter/2 + 2 ) ) .extrude(0.6) .label( "jig" ) .previewOnly().bottomTo( lock.top + 1 ) return cap + main + lock + jig } @Piece meth cap() = assembly().find("cap").rotateX(180).bottomTo(0) @Piece meth main() = assembly().find("main").bottomTo(0) @Piece meth lock() = assembly().find("lock").bottomTo(0) @Piece meth jig() = assembly().find("jig").bottomTo(0) override fun build() : Shape3d { return assembly() } }