CNC Spoilboard Grid DXF & Spiral Out-In Surfacing G-Code in TypeScript (With Aluminum T-Track Collision Guard)
Every desktop CNC router owner eventually faces the same rite of passage: milling a fresh 3/4" MDF wasteboard with threaded inserts, 20 mm bench dog holes, and a tramming/surfacing fly-cutter pass — without accidentally
Every desktop CNC router owner eventually faces the same rite of passage: milling a fresh 3/4" MDF wasteboard with threaded inserts, 20 mm bench dog holes, and a tramming/surfacing fly-cutter pass — without accidentally sending a 1/4" carbide endmill straight into a structural aluminum T-track rail.
Most makers either download a static DXF that doesn't match their machine's exact travel limits or spend an hour manually hand-deleting hole intersections in Fusion 360 or VCarve.
While building the free browser-native CNC Spoilboard Grid DXF & Surfacing G-Code Generator at CutPath CAD, we implemented the entire parametric geometry kernel, aluminum T-track collision guard, underside counterbore calculator, and multi-controller .nc G-Code generator in pure zero-dependency TypeScript.
Here are the four geometric and CAM subtleties that make the output safe to run on real machines.
1. Automatic Aluminum T-Track Collision Guard
Hybrid tables like the Shapeoko 5 Pro embed aluminum T-track extrusions directly between MDF slats. If an insert grid hole lands within even a few millimeters of a rail, a 13.5 mm underside counterbore will either crash the cutter into aluminum or leave a paper-thin MDF web that blows out when you torque a hold-down clamp.
Instead of asking the user to delete bad holes manually, we compute an exact exclusion half-width for every track center coordinate tx:
export function checkTrackCollision(
x: number,
y: number,
featureOuterRadiusMm: number,
tTracks: { orientation: 'x' | 'y'; widthMm: number; centersMm: number[] },
minMdfWebMm = 4.0
): boolean {
const halfExcl = tTracks.widthMm / 2 + featureOuterRadiusMm + minMdfWebMm;
for (const center of tTracks.centersMm) {
const dist = tTracks.orientation === 'y' ? Math.abs(x - center) : Math.abs(y - center);
if (dist < halfExcl) return true;
}
return false;
}
On a Shapeoko 5 Pro 4×4 Hybrid table (6 Y-axis tracks on 200 mm pitch, 19.05 mm track width), this automatically preserves 101 safe 1/4-20 threaded insert pockets and skips 43 track collisions before generating a single DXF circle or helical G-code arc — while rendering the skipped holes on a dedicated T_TRACK_GUARD reference layer so the operator can verify clearance visually.
2. Why Underside Counterbores Beat Top-Down Threaded Inserts
Top-driven inserts pull straight up out of MDF as soon as you tighten a cam clamp. Flipping the MDF sheet over and counterboring from the bottom lets flanged 1/4-20 or M6 E-Z Lok inserts pull into the wood fibers instead of out.
The critical clearance equation determines how many 0.5 mm resurfacing skims your wasteboard survives before the fly cutter hits steel:
const metalTopFromBottomMm = insertFlangeDepthMm + insertLengthMm;
const safeResurfaceAllowanceMm = mdfThicknessMm - metalTopFromBottomMm;
// Example: 19.05 mm (3/4" MDF) - (2.2 mm flange + 10.5 mm body) = 6.35 mm (~12 skims)
Our CAD generator automatically exports separate CAM layers (INSERT_THRU, INSERT_COUNTERBORE, DOG_HOLES, V_GRID, BOARD_OUTLINE, T_TRACK_GUARD) as strict AutoCAD R12 DXF with zero splines and zero open contours so Carbide Create, VCarve, Fusion 360, and LightBurn assign pocket depths by layer in one click.
3. Zero-Ridge Spiral Out-In Surfacing G-Code
Conventional zig-zag raster surfacing leaves visible step ridges whenever a router spindle is even 0.05° out of tram along the Y axis, and it repeatedly plunges or exits across MDF edges.
An inward-spiraling rectangle (Spiral Out-In) keeps climb-milling direction consistent around the entire bed perimeter and starts with a 30% bit-diameter overrun outside the board boundary so there is zero plunge mark on the wasteboard:
export function generateSpiralPass(
bedW: number,
bedH: number,
bitDia: number,
stepoverPct: number,
zCut: number,
feedMmMin: number
): string[] {
const step = Math.max(1, bitDia * (stepoverPct / 100));
const overrun = bitDia * 0.3;
let xMin = -overrun;
let xMax = bedW + overrun;
let yMin = -overrun;
let yMax = bedH + overrun;
const lines: string[] = [
`G0 X${xMin.toFixed(3)} Y${yMin.toFixed(3)}`,
`G1 Z${zCut.toFixed(3)} F${Math.round(feedMmMin * 0.25)}`
];
while (xMin <= xMax && yMin <= yMax) {
lines.push(
`G1 X${xMax.toFixed(3)} Y${yMin.toFixed(3)} F${feedMmMin}`,
`G1 X${xMax.toFixed(3)} Y${yMax.toFixed(3)}`,
`G1 X${xMin.toFixed(3)} Y${yMax.toFixed(3)}`,
`G1 X${xMin.toFixed(3)} Y${yMin.toFixed(3)}`
);
xMin += step;
xMax -= step;
yMin += step;
yMax -= step;
if (xMin <= xMax && yMin <= yMax) {
lines.push(`G1 X${xMin.toFixed(3)} Y${yMin.toFixed(3)}`);
}
}
return lines;
}
The post-processor outputs clean, tested headers and footers for GRBL / Carbide Motion, Onefinity Buildbotics, Masso G3, and Mach3 / Mach4 in either inches (G20) or millimeters (G21), plus helical G2 interpolation pockets for every insert and 20 mm MFT dog hole so a single 1/4" upcut endmill drills both sizes without a tool change.
4. Zero-Server Handoff to a 3D Isometric G-Code Backplot Viewer
Never run freshly generated G-code blind on a router. Using sessionStorage, one click passes the generated .nc text directly into our client-side 3D G-Code Viewer & Backplot, where operators scrub the toolpath move-by-move, inspect Z plunge depths, and check rapid clearance height (Zsafe) in 3D before saving to their SD card or Carbide Motion sender.
Try It Free (No Sign-Up Required)
- Free CNC Spoilboard Grid DXF & Surfacing G-Code Generator: https://www.cutpathcad.com/cnc-spoilboard-dxf
- Free 3D G-Code Viewer & Backplot: https://www.cutpathcad.com/gcode-viewer
- Shapeoko & Onefinity Spoilboard Engineering Guide: https://www.cutpathcad.com/tools/shapeoko-onefinity-cnc-spoilboard-grid-dxf-guide
- CNC Wasteboard Surfacing Fly-Cutter Feeds & Speeds Guide: https://www.cutpathcad.com/tools/cnc-wasteboard-surfacing-gcode-fly-cutter-guide
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.