FooCAD Source Codeclass FoldingBox2 : Model {
var size = Vector3( 300, 500, 250 )
var thickness = 9
meth hinge( length : double ) : Shape3d {
return Circle( thickness/2 ).extrude( length ).rotateY(90)
.center()
}
override fun build() : Shape3d {
val base = Square( size.x, size.y ).center()
.extrude( thickness )
.color("Green")
val end = Square( size.x, size.z ).centerX()
.extrude( thickness )
.rotateX(90)
.frontTo( base.front ).bottomTo( base.top + thickness ) +
hinge( size.x ).bottomTo( base.top ).frontTo( base.front )
val ends = end.backTo( base.back ).also()
return base + ends
}
}