FooCAD Source Codeimport static uk.co.nickthecoder.foocad.changefilament.v1.ChangeFilament.*
import static uk.co.nickthecoder.foocad.layout.v1.Debug.*
/**
Creates letter with raised outlines.
WARNING. This may fail for large widths and bevels.
The *inside* of the shape remains constant, and if the width+bevel*2 gets too big, the shape
will self intersect, and will fail.
*/
class Outline2 : Model, PostProcessor {
@Custom
var string = "2"
@Custom
var style = TextStyle( DEFAULT_FONT, 90)
@Custom
var thickness = 2.0
@Custom
var width = 2.5
@Custom
var pause = true
@Custom
var chamfer = 1.0
@Custom( about="1=> The outline is outside of the text. 0=> The outlin is inside the text." )
var ratio = 1.0
var baseThickness = 0.6
override fun build() : Shape3d {
val text = Text( string, style ).toPolygon()
val outlines = listOf<Shape3d>()
for ( part in text.parts() ) {
println( "Path : $part" )
val outline = ExtrusionBuilder().apply {
crossSection( part.offset(width))
forward( thickness-chamfer )
crossSection()
forward( chamfer )
crossSection( -chamfer )
crossSection( -width+chamfer )
forward( -chamfer )
crossSection( -chamfer )
forward( -thickness+chamfer )
crossSection()
}.buildClosed()
outlines.add( outline )
}
val base = text.extrude( baseThickness )
return Union3d(outlines) + base
}
override fun postProcess(gcode: GCode) {
if ( pause && baseThickness > 0 ) {
pauseAtHeight( gcode, baseThickness, "Change Filament" )
}
}
}