FooCAD Source Codeimport static uk.co.nickthecoder.foocad.changefilament.v1.ChangeFilament.*
/**
Creates raised text, with a background.
The background follows the shape of the text, but also has a guarenteed solid
part running through it (the height of a lower case "e").
The result is that the outline looks pleasing, and yet a strip of double sided
tape is 100% obscured, regardless of the text.
Print Notes
Print using two colours. I've added a beep and message when it is time to change
the filament (assuming "filamentOffset" matches your printer)
*/
class DrawerLabel : Model, PostProcessor {
@Custom( lines=10 )
var words = "5mm LEDs\n3mm LEDs\nOther LEDs\nModules\nResistors\nCapacitors\n" +
"Transistors\nChips\nHeat Shrink\nConnectors"
@Custom
var thickness = 0.6
@Custom
var raised = 0.6
@Custom
var offset = 0.8
@Custom
var style = TextStyle(BOLD, 10.0)
override fun build() : Shape3d {
val shapes = listOf<Shape3d>()
val lowerCaseHeight = Text("e", style ).toPolygon().size.y
val lines = words.split("\n")
var y = 0
for (line in lines ) {
val text = Text( line, style )
.toPolygon()
.centerX()
.color("Black")
val outline = (
text.nonHoles().offset( offset ) +
Square( text.size.x-5, lowerCaseHeight )
.centerX()
).color("White")
val both = (
outline.extrude(thickness) +
text.extrude(raised).translateZ(thickness)
).toOriginY().translateY(y)
shapes.add( both )
y += outline.size.y + 2
}
return Union3d( shapes )
}
// This is the main focus of this example! Also not that the class must implement PostProcessor.
override fun postProcess(gcode: GCode) {
gcode.pauseAtHeight( thickness, "Change filament" )
}
}