Public
Edited
May 4, 2023
Insert cell
Insert cell
Insert cell
Insert cell
envelopeWidth = 245
Insert cell
envelopeHeight = 170
Insert cell
clankBedThickness = 19.05
Insert cell
Insert cell
path = ["M3,0,0,0", "M3,100,100,0"]
Insert cell
populateVizSpace(tpVizSpace, [path])
Insert cell
stepover = 0.5
Insert cell
facingDepth = -0.25
Insert cell
travelHeight = 5
Insert cell
function range(n) {
return [...Array(n).keys()];
}
Insert cell
function toFixed(num, fixed) {
let re = new RegExp("^-?\\d+(?:.\\d{0," + (fixed || -1) + "})?");
let truncStr = num.toString().match(re)[0];
return parseFloat(truncStr);
}
Insert cell
endMillDiameter = 3.17
Insert cell
numTraversals = Math.floor(envelopeHeight / (endMillDiameter * stepover))
Insert cell
yVals = range(numTraversals).map((ti) =>
toFixed(ti * (endMillDiameter * stepover), 2)
)
Insert cell
points = yVals
.map((y, idx) => {
if (idx % 2 === 0) {
return [
[0, y],
[envelopeWidth, y]
];
} else {
return [
[envelopeWidth, y],
[0, y]
];
}
})
.flat()
Insert cell
mainToolpath = points.map((pt) => `G1 X${pt[0]} Y${pt[1]}`)
Insert cell
Insert cell
feed = 3886.2
Insert cell
setMainFeed = [`G0 F${feed}`]
Insert cell
setSpeedAndSpindleOn = [`M3 S5000`, `G4 S1`, `M3 S10000`, `G4 S1`, `M3 S15000`]
Insert cell
spindleOff = [`M5`]
Insert cell
initialPlunge = [`G1 Z${facingDepth} F${feed / 4}`, ...setMainFeed]
Insert cell
moveToTravelHeight = [`G0 Z${travelHeight} F${feed * 2}`, ...setMainFeed]
Insert cell
moveToOrigin = ["G0 X0 Y0"]
Insert cell
preamble = [
// "G17",
"G21", // set units to mm
// "G40",
// "G49",
// "G54",
// ";G80",
"G90", // absolute positioning
"G94", // feed rate set to units/min
"T0" // activate current tool
]
Insert cell
entireToolpath = [
preamble,
setMainFeed,
moveToTravelHeight,
moveToOrigin,
setSpeedAndSpindleOn,
initialPlunge,
mainToolpath,
moveToTravelHeight,
spindleOff
].flat()
Insert cell
entireToolpathString = entireToolpath.join("\n")
Insert cell
downloadButton(entireToolpathString, "facing.nc")
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more