FooCAD Source Codeimport static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
import static uk.co.nickthecoder.foocad.extras.v1.Extras.*
import static uk.co.nickthecoder.foocad.arrange.v1.Arrange.*
class StrapWratchet : Model {
@Custom
var webbingThickness = 20
var slotThickness = 3
var diameter = 30
var axelDiameter = 3
fun axelHole() = Circle(axelDiameter + 0.5)
.extrude(2.2).bottomTo(-0.1)
fun drumSide() : Shape3d {
val circle = Circle(diameter/2)
val tooth = PolygonBuilder().apply {
moveTo( circle.right, 0 )
lineBy( -2, 0 )
bezierBy( Vector2( 1,1 ), Vector2( 0, 1 ), Vector2( 2, 8 ) )
}.build()
val teeth = tooth.repeatAround(15)
return (circle - teeth).extrude( 1 ) - axelHole()
}
@Piece
fun otherSide() : Shape3d {
val indents = Square( 4 ).center().translateX(7)
.repeatAround(4)
.extrude(10)
.center()
return drumSide() - indents
}
@Piece
fun drum() : Shape3d {
val side = drumSide()
val core = Circle(diameter/2 - 5)
.extrude( webbingThickness + 3 )
.bottomTo( side.top )
val outdents = Square(4-0.2).center().translateX(7)
.roundAllCorners(0.5)
.repeatAround(4)
.extrude(1)
.bottomTo( core.top )
val gap = Square( slotThickness, webbingThickness + 1 )
.extrude( core.size.x )
.rotateX(90)
.center()
.centerZTo( core.middle.z )
val axelHoles = axelHole().topTo( core.top + side.size.z ).also()
return side + core + outdents - gap - axelHoles
}
override fun build() : Shape3d {
return arrangeX(5,
drum(), otherSide()
).centerX()
}
}