PerfectionPiece.frink

Download or view PerfectionPiece.frink in plain text format


/** This makes a replacement piece for my "Perfection" game for 3-D printing.
*/


r = 254/in   // Voxel resolution

bottomWidth = 13.6 mm   // Outside measurement
topWidth = 16.0mm       // Outside measurement
topWallThickness    = 1.7 mm
bottomWallThickness = 1.1 mm
wallHeight = 8.0 mm

lidThickness = 1.1 mm

spindleDiamBottom = 5.5 mm
spindleDiamTop    = 3.8 mm
spindleHeight     = 12.1 mm

yHeight = 13.0 mm       // Outside measurement

br = bottomWallThickness / 2   // bottom radius of cone used as tool
tr = topWallThickness / 2
xr0 = bottomWidth / 2 - br
xr1 = topWidth / 2 - br
y1 = yHeight / 2 - br

// Make a Point2DFloatList (polygon) to represent the shape of the piece.
poly = newJava["frink.graphics.Point2DFloatList"]
poly.addPoint[-xr0 r, -y1 r]   // Bottom left
poly.addPoint[xr0 r, -y1 r]    // Bottom right
poly.addPoint[xr1 r, y1 r]     // Top right
poly.addPoint[-xr1 r, y1 r]    // Top left

// old vs. new : make tapered walls

// old:
// Make the tool to draw the walls
//tool = callJava["frink.graphics.VoxelArray", "makeTaperedCylinder", [0,0,0, 0,0,wallHeight r, br r, tr r]]
//v = callJava["frink.graphics.VoxelArray", "strokeZ", [poly, tool, 0,0,wallHeight/2 r, true]]

// new:
v = callJava["frink.graphics.VoxelArray", "strokeZTapered", [poly, 0, wallHeight r, br r, tr r, true]]

// Make lid
lidPoly = poly.scaleAround[0,0,1.4]  // Scale around the bottom dimensions
lid = v.extrudeZ[lidPoly, wallHeight r, (wallHeight+lidThickness) r]
v = v.union[lid]

// Make spindle
spindle = v.makeTaperedCylinder[0,0,(wallHeight + lidThickness) r, 0,0,(wallHeight+lidThickness+spindleHeight) r, spindleDiamBottom/2 r, spindleDiamTop/2 r]
v = v.union[spindle]


v.projectX[undef].show["X"]
v.projectY[undef].show["Y"]
v.projectZ[undef].show["Z"]

filename = "PerfectionPiece.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[v.toObjFormat["Perfection", 1 / (r mm)]]
w.close[]
println["done."]


Download or view PerfectionPiece.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20217 days, 23 hours, 52 minutes ago.