Creating a Curvelicious Cookie Cutter

So, for reasons I need not go into, I needed an OpenSCAD solid model of a custom cookie cutter produced on an Afinia 3D printer from a Trimble Sketchup model:

Afinia Robot Cutter - on raft
Afinia Robot Cutter – on raft

The cutter is still attached to the raft that, it seems, is required for passable results on the Afinia’s platform.

Having already figured out how to wrap a cutter around a shape, the most straightforward procedure starts by extracting the cutter’s shape. So, lay the cutter face down on the scanner and pull an image into GIMP:

Afinia Robot - scan
Afinia Robot – scan

Blow out the contrast to eliminate the background clutter, then posterize to eliminate shadings:

Afinia Robot - scan enhanced
Afinia Robot – scan enhanced

Select the black interior region, grow the selection by a pixel or two, then shrink it back to eliminate (most of) the edge granularity, plunk it into a new image, and fill with black:

Afinia Robot - scan filled
Afinia Robot – scan filled

Now the magic happens…

Import the bitmap image into Inkscape. In principle, you can auto-trace the bitmap outline and clean it up manually, but a few iterations of that convinced me that it wasn’t worth the effort. Instead, I used Inkscape’s Bézier Curve tool to drop nodes (a.k.a. control points) at all the inflection points around the image, then warped the curves to match the outline:

Afinia Robot - Bezier spline fitting
Afinia Robot – Bezier spline fitting

If you’re doing that by hand, you could start with the original scanned image, but the auto-trace function works best with a high-contrast image and, after you give up on auto-tracing, you’ll find it’s easier to hand-trace a high-contrast image.

Anyhow, the end result of all that is a smooth path around the outline of the shape, without all the gritty details of the pixelated version. Save it as an Inkscape SVG file for later reference.

OpenSCAD can import a painfully limited subset of DXF files that, it seems, the most recent versions of Inkscape cannot produce (that formerly helpful tutorial being long out of date). Instead, I exported (using “Save as”) the path from Inkscape to an Encapsulated Postscript file (this is a PNG, as WordPress doesn’t show EPS files):

Afinia Robot - Bezier Curves.eps
Afinia Robot – Bezier Curves.eps

It’s not clear what the EPS file contains; I think it’s just a list of points around the path that doesn’t include the smooth Bézier goodness. That may account for the grittiness of the next step, wherein the pstoedit utility converts the EPS file into a usable DXF file:

pstoedit dxf:-polyaslines Afinia\ Robot\ -\ Bezier\ Curves.eps Afinia\ Robot\ -\ outline.dxf

Unfortunately, either the EPS file doesn’t have enough points on each curve or pstoedit automatically sets the number of points and doesn’t provide an override: contrary to what you (well, I) might think, the -splineprecision option doesn’t apply to whatever is in the EPS file. In any event, the resulting DXF file has rather low-res curves, but they were good enough for my purposes and OpenSCAD inhaled the DXF and emitted a suitable STL file:

Afinia Robot - shape slab
Afinia Robot – shape slab

To do that, you set the Layout variable to “Slab”, compile the model, and export the STL.

Being interested only in the process and its results, not actually cutting and baking cookies, I tweaked the OpenSCAD parameters to produce stumpy “cutters”:

Afinia Robot - solid model
Afinia Robot – solid model

You do that by setting the Layout variable to “Build”, compile the model, and export yet another STL. In the past, this seemed to be a less fragile route than directly importing and converting the DXF at each stage, but that may not be relevant these days. In any event, having an STL model of the cookie may be useful in other contexts, so it’s not entirely wasted effort.

Run the STL through Slic3r to get the G-Code as usual.

The resulting model printed in about 20 minutes apiece on the M2:

Robot Cutter - stumpy version
Robot Cutter – stumpy version

As it turns out, the fact that the M2 can produce ready-to-use cutters, minus the raft, is a strong selling point.

Given a workable model, the next step was to figure out the smallest possible two-thread-wide cutter blade, then run variations of the Extrusion Factor to see how that affected surface finish. More on that in a while.

The OpenSCAD source isn’t much changed from the original Tux Cutter; the DXF import required different scale factors:

// Robot cookie cutter using Minkowski sum
// Ed Nisley KE4ZNU - Sept 2011
// August 2013 adapted from the Tux Cutter

Layout = "Build";				// Build Slab

//- Extrusion parameters - must match reality!

ThreadThick = 0.25;
ThreadWidth = 0.40;

function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);

MaxSize = 150;				// larger than any possible dimension ...

Protrusion = 0.1;

//- Cookie cutter parameters

Size = 95;

TipHeight = IntegerMultiple(3.0,ThreadThick);
TipThick = 1.5*ThreadWidth;			// 1.5* = thinnest 2-thread wall, 1.0* thread has gaps

WallHeight = IntegerMultiple(1.0,ThreadThick);
WallThick = 4.5*ThreadWidth;

LipHeight = IntegerMultiple(1.0,ThreadWidth);
LipThick = IntegerMultiple(5,ThreadWidth);

//- Wrapper for the shape of your choice

module Shape(Size) {

//- A solid slab of Tux goodness in simple STL format
// Choose magic values to:
//		center it in XY
//		reversed across Y axis (prints with handle on bottom)
//		bottom on Z=0
//		make it MaxSize from head to feet

module Tux(Scale) {
  STLscale = 250;
		  file = "/mnt/bulkdata/Project Files/Thing-O-Matic/Tux Cookie Cutter/Tux Plate.stl",

module Robot(Scale) {
    STLscale = 100.0;
    scale(Scale / STLscale)
				import("/mnt/bulkdata/Project Files/Thing-O-Matic/Pinkie/M2 Challenge/Afinia Robot.stl",

//- Given a Shape(), return enlarged slab of given thickness

module EnlargeSlab(Scale, WallThick, SlabThick) {

	intersection() {
	  minkowski(convexity=5) {


//- Put peg grid on build surface

module ShowPegGrid(Space = 10.0,Size = 1.0) {

  RangeX = floor(100 / Space);
  RangeY = floor(125 / Space);

	for (x=[-RangeX:RangeX])
	  for (y=[-RangeY:RangeY])


//- Build it


if (Layout == "Slab")

if (Layout == "Build")
	difference() {
	union() {
		translate([0,0,(WallHeight + LipHeight - Protrusion)])
		EnlargeSlab(Size,TipThick,TipHeight + Protrusion);
		translate([0,0,(LipHeight - Protrusion)])
		EnlargeSlab(Size,WallThick,(WallHeight + Protrusion));
	Shape(Size);					// punch out cookie hole