Merge pull request #393 from GridSpace/improved-register
Improved register
This commit is contained in:
commit
560ca3d53e
5 changed files with 92 additions and 88 deletions
|
|
@ -126,6 +126,7 @@
|
||||||
"camTraceBottom": false,
|
"camTraceBottom": false,
|
||||||
"cmaPocketOutline": false,
|
"cmaPocketOutline": false,
|
||||||
"camRegisterThru": 5,
|
"camRegisterThru": 5,
|
||||||
|
"camRegisterOffset": 10,
|
||||||
"camFlatness": 0,
|
"camFlatness": 0,
|
||||||
"camContourBridge": 10,
|
"camContourBridge": 10,
|
||||||
"camForceZMax": false,
|
"camForceZMax": false,
|
||||||
|
|
|
||||||
|
|
@ -518,6 +518,7 @@ export const conf = {
|
||||||
camDrillingOn: false,
|
camDrillingOn: false,
|
||||||
camRegisterSpeed: 1000,
|
camRegisterSpeed: 1000,
|
||||||
camRegisterThru: 5,
|
camRegisterThru: 5,
|
||||||
|
camRegisterOffset: 10,
|
||||||
camHelicalTool: 1000,
|
camHelicalTool: 1000,
|
||||||
camHelicalSpindle: 1000,
|
camHelicalSpindle: 1000,
|
||||||
camHelicalDownSpeed: 250,
|
camHelicalDownSpeed: 250,
|
||||||
|
|
|
||||||
|
|
@ -101,12 +101,12 @@ export function createPopOp(type, map) {
|
||||||
const settings = conf.get();
|
const settings = conf.get();
|
||||||
const { tool } = new Tool(settings, op.rec.tool); //get tool by id
|
const { tool } = new Tool(settings, op.rec.tool); //get tool by id
|
||||||
const opType = op.rec.type
|
const opType = op.rec.type
|
||||||
const drillOrRegister = opType == "drill" || opType == "register"
|
const drillingOp = opType == "drill" || ( opType == "register" && op.rec.axis != "-" )
|
||||||
|
|
||||||
if (!drillOrRegister && tool.type == "drill") {
|
if (!drillingOp && tool.type == "drill") {
|
||||||
alerts.show(`Warning: Drills should not be used for ${opType} operations.`)
|
alerts.show(`Warning: Drills should not be used for non-drilling operations.`)
|
||||||
}
|
}
|
||||||
else if (drillOrRegister && tool.type != "drill") {
|
else if (drillingOp && tool.type != "drill") {
|
||||||
alerts.show(`Warning: Only drills should be used for drilling operations.`)
|
alerts.show(`Warning: Only drills should be used for drilling operations.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -508,21 +508,23 @@ export function createPopOps() {
|
||||||
dwell: 'camDrillDwell',
|
dwell: 'camDrillDwell',
|
||||||
lift: 'camDrillLift',
|
lift: 'camDrillLift',
|
||||||
feed: 'camRegisterSpeed',
|
feed: 'camRegisterSpeed',
|
||||||
thru: 'camRegisterThru'
|
offset: 'camRegisterOffset',
|
||||||
|
thru: 'camRegisterThru',
|
||||||
}).inputs = {
|
}).inputs = {
|
||||||
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
|
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
|
||||||
axis: UC.newSelect(LANG.cd_axis, {}, "regaxis"),
|
axis: UC.newSelect(LANG.cd_axis, {}, "regaxis"),
|
||||||
points: UC.newSelect(LANG.cd_points, { show: () => env.poppedRec.axis !== '-' }, "regpoints"),
|
points: UC.newSelect(LANG.cd_points, {show:() => env.poppedRec.axis !== '-'}, "regpoints"),
|
||||||
sep: UC.newBlank({ class: "pop-sep" }),
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
spindle: UC.newInput(LANG.cc_spnd_s, { title: LANG.cc_spnd_l, convert: UC.toInt, show: hasSpindle }),
|
spindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, show:hasSpindle}),
|
||||||
rate: UC.newInput(LANG.cc_plng_s, { title: LANG.cc_plng_l, convert: UC.toInt, units: true }),
|
rate: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, units:true}),
|
||||||
feed: UC.newInput(LANG.cc_feed_s, { title: LANG.cc_feed_l, convert: UC.toInt, units: true, show: () => env.poppedRec.axis === '-' }),
|
feed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true, show:() => env.poppedRec.axis === '-'}),
|
||||||
sep: UC.newBlank({ class: "pop-sep" }),
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
down: UC.newInput(LANG.cc_sdwn_s, { title: LANG.cc_sdwn_l, convert: UC.toFloat, units: true }),
|
down: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, units:true}),
|
||||||
dwell: UC.newInput(LANG.cd_dwll_s, { title: LANG.cd_dwll_l, convert: UC.toFloat, show: () => env.poppedRec.axis !== '-' }),
|
dwell: UC.newInput(LANG.cd_dwll_s, {title:LANG.cd_dwll_l, convert:UC.toFloat, show:() => env.poppedRec.axis !== '-'}),
|
||||||
lift: UC.newInput(LANG.cd_lift_s, { title: LANG.cd_lift_l, convert: UC.toFloat, units: true, show: () => env.poppedRec.axis !== '-' }),
|
lift: UC.newInput(LANG.cd_lift_s, {title:LANG.cd_lift_l, convert:UC.toFloat, units:true, show:() => env.poppedRec.axis !== '-'}),
|
||||||
sep: UC.newBlank({ class: "pop-sep" }),
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
thru: UC.newInput(LANG.cd_thru_s, { title: LANG.cd_thru_l, convert: UC.toFloat, units: true }),
|
offset: UC.newInput(LANG.cd_rego_s, {title:LANG.cd_rego_l, convert:UC.toFloat, units:true, }),
|
||||||
|
thru: UC.newInput(LANG.cd_thru_s, {title:LANG.cd_thru_l, convert:UC.toFloat, units:true}),
|
||||||
};
|
};
|
||||||
|
|
||||||
createPopOp('helical', {
|
createPopOp('helical', {
|
||||||
|
|
|
||||||
|
|
@ -23,99 +23,95 @@ class OpRegister extends CamOp {
|
||||||
updateToolDiams(tool.fluteDiameter());
|
updateToolDiams(tool.fluteDiameter());
|
||||||
|
|
||||||
let { stock } = settings,
|
let { stock } = settings,
|
||||||
tz = widget.track.pos.z,
|
toolZ = widget.track.pos.z,
|
||||||
lx = bounds.min.x,
|
boundMinX = bounds.min.x,
|
||||||
hx = bounds.max.x,
|
boundMaxX = bounds.max.x,
|
||||||
ly = bounds.min.y,
|
boundMinY = bounds.min.y,
|
||||||
hy = bounds.max.y,
|
boundMaxY = bounds.max.y,
|
||||||
o3 = tool.fluteDiameter() * 2,
|
toolOffset = tool.fluteDiameter() * 2,
|
||||||
mx = (lx + hx) / 2,
|
centerX = (boundMinX + boundMaxX) / 2,
|
||||||
my = (ly + hy) / 2,
|
centerY = (boundMinY + boundMaxY) / 2,
|
||||||
mz = op.thru || zThru || 0,
|
cutDepth = op.thru || zThru || 0,
|
||||||
dx = (stock.x - (hx - lx)) / 4,
|
pathPoints = [],
|
||||||
dy = (stock.y - (hy - ly)) / 4,
|
stockToSurfaceOffset = stock.z - bounds.max.z,
|
||||||
dz = stock.z,
|
startZ = bounds.max.z + stockToSurfaceOffset + toolZ,
|
||||||
points = [],
|
endZ = toolZ - cutDepth,
|
||||||
wo = stock.z - bounds.max.z,
|
cutOffset = op.offset;
|
||||||
z1 = bounds.max.z + wo + tz,
|
|
||||||
z2 = tz - mz;
|
|
||||||
|
|
||||||
if (!(stock.x && stock.y && stock.z)) {
|
if (!(stock.x && stock.y && stock.z)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (op.axis) {
|
switch (op.axis.toLowerCase()) {
|
||||||
case "X":
|
|
||||||
case "x":
|
case "x":
|
||||||
if (op.points == 3) {
|
if (op.points == 3) {
|
||||||
points.push(newPoint(lx - dx, my, 0));
|
pathPoints.push(newPoint(boundMinX - cutOffset, centerY, 0));
|
||||||
points.push(newPoint(hx + dx, my - o3, 0));
|
pathPoints.push(newPoint(boundMaxX + cutOffset, centerY - toolOffset, 0));
|
||||||
points.push(newPoint(hx + dx, my + o3, 0));
|
pathPoints.push(newPoint(boundMaxX + cutOffset, centerY + toolOffset, 0));
|
||||||
} else {
|
} else {
|
||||||
points.push(newPoint(lx - dx, my, 0));
|
pathPoints.push(newPoint(boundMinX - cutOffset, centerY, 0));
|
||||||
points.push(newPoint(hx + dx, my, 0));
|
pathPoints.push(newPoint(boundMaxX + cutOffset, centerY, 0));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Y":
|
|
||||||
case "y":
|
case "y":
|
||||||
if (op.points == 3) {
|
if (op.points == 3) {
|
||||||
points.push(newPoint(mx, ly - dy, 0));
|
pathPoints.push(newPoint(centerX, boundMinY - cutOffset, 0));
|
||||||
points.push(newPoint(mx - o3, hy + dy, 0));
|
pathPoints.push(newPoint(centerX - toolOffset, boundMaxY + cutOffset, 0));
|
||||||
points.push(newPoint(mx + o3, hy + dy, 0));
|
pathPoints.push(newPoint(centerX + toolOffset, boundMaxY + cutOffset, 0));
|
||||||
} else {
|
} else {
|
||||||
points.push(newPoint(mx, ly - dy, 0));
|
pathPoints.push(newPoint(centerX, boundMinY - cutOffset, 0));
|
||||||
points.push(newPoint(mx, hy + dy, 0));
|
pathPoints.push(newPoint(centerX, boundMaxY + cutOffset, 0));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "-":
|
case "-":
|
||||||
let o2 = o3 / 2,
|
let halfOffset = toolOffset / 2,
|
||||||
x0 = lx - dx,
|
loopMinX = boundMinX - cutOffset,
|
||||||
x1 = hx + dx,
|
loopMaxX = boundMaxX + cutOffset,
|
||||||
y0 = ly - dy - o2,
|
loopMinY = boundMinY - cutOffset - halfOffset,
|
||||||
y1 = hy + dy + o2,
|
loopMaxY = boundMaxY + cutOffset + halfOffset,
|
||||||
x4 = (x1 - x0 - o2) / 4,
|
deltaX = (loopMaxX - loopMinX - halfOffset) / 4,
|
||||||
y4 = (y1 - y0 - o2 * 3) / 4,
|
deltaY = (loopMaxY - loopMinY - halfOffset * 3) / 4,
|
||||||
poly, cp, cz;
|
poly, currentPoint, currentZ;
|
||||||
function start(z) {
|
function start(z) {
|
||||||
cz = z;
|
currentZ = z;
|
||||||
cp = { x: x0 + o2 * 0.5, y: y0 + o2 * 1.5 };
|
currentPoint = { x: loopMinX + halfOffset * 0.5, y: loopMinY + halfOffset * 1.5 };
|
||||||
poly = newPolygon().add(cp.x, cp.y, z);
|
poly = newPolygon().add(currentPoint.x, currentPoint.y, z);
|
||||||
}
|
}
|
||||||
function move(dx, dy) {
|
function move(dx, dy) {
|
||||||
cp.x += dx;
|
currentPoint.x += dx;
|
||||||
cp.y += dy;
|
currentPoint.y += dy;
|
||||||
poly.add(cp.x, cp.y, cz);
|
poly.add(currentPoint.x, currentPoint.y, currentZ);
|
||||||
}
|
}
|
||||||
function rept(count, tv, fn) {
|
function rept(count, step, fn) {
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
fn(tv, count === 0);
|
fn(step, count === 0);
|
||||||
tv = -tv;
|
step = -step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let z of base_util.lerp(z1, z2, op.down)) {
|
for (let z of base.util.lerp(startZ, endZ, op.down)) {
|
||||||
let slice = newSlice(z);
|
let slice = newSlice(z);
|
||||||
addSlices(slice);
|
addSlices(slice);
|
||||||
sliceOut.push(slice);
|
sliceOut.push(slice);
|
||||||
start(z);
|
start(z);
|
||||||
rept(4, o2, oy => {
|
rept(4, halfOffset, oy => {
|
||||||
move(0, -oy);
|
move(0, -oy);
|
||||||
move(x4, 0);
|
move(deltaX, 0);
|
||||||
});
|
});
|
||||||
rept(4, o2, ox => {
|
rept(4, halfOffset, ox => {
|
||||||
move(ox, 0);
|
move(ox, 0);
|
||||||
move(0, y4);
|
move(0, deltaY);
|
||||||
});
|
});
|
||||||
rept(4, o2, oy => {
|
rept(4, halfOffset, oy => {
|
||||||
move(0, oy);
|
move(0, oy);
|
||||||
move(-x4, 0);
|
move(-deltaX, 0);
|
||||||
});
|
});
|
||||||
rept(4, o2, ox => {
|
rept(4, halfOffset, ox => {
|
||||||
move(-ox, 0);
|
move(-ox, 0);
|
||||||
move(0, -y4);
|
move(0, -deltaY);
|
||||||
});
|
});
|
||||||
poly.points.pop();
|
poly.points.pop();
|
||||||
slice.camTrace = { tool: tool.getID(), rate: op.feed, plunge: op.rate };
|
slice.camTrace = { tool: tool.getID(), rate: op.feed, plunge: op.rate };
|
||||||
slice.camLines = [poly];
|
slice.camLines = [ poly ];
|
||||||
slice.output()
|
slice.output()
|
||||||
.setLayer("register", { line: color }, false)
|
.setLayer("register", { line: color }, false)
|
||||||
.addPolys(slice.camLines)
|
.addPolys(slice.camLines)
|
||||||
|
|
@ -123,16 +119,16 @@ class OpRegister extends CamOp {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (points.length) {
|
if (pathPoints.length) {
|
||||||
let slice = newSlice(0, null), polys = [];
|
let slice = newSlice(0,null), polys = [];
|
||||||
points.forEach(point => {
|
pathPoints.forEach(point => {
|
||||||
polys.push(newPolygon()
|
polys.push(newPolygon()
|
||||||
.append(point.clone().setZ(z1))
|
.append(point.clone().setZ(startZ))
|
||||||
.append(point.clone().setZ(z2)));
|
.append(point.clone().setZ(endZ)));
|
||||||
});
|
});
|
||||||
slice.camLines = polys;
|
slice.camLines = polys;
|
||||||
slice.output()
|
slice.output()
|
||||||
.setLayer("register", { face: color, line: color })
|
.setLayer("register", {face: color, line: color})
|
||||||
.addPolys(polys);
|
.addPolys(polys);
|
||||||
addSlices(slice);
|
addSlices(slice);
|
||||||
sliceOut.push(slice);
|
sliceOut.push(slice);
|
||||||
|
|
|
||||||
|
|
@ -592,8 +592,6 @@ self.lang['en-us'] = {
|
||||||
cd_dwll_l: ["dwell time","between plunges in","in milliseconds"],
|
cd_dwll_l: ["dwell time","between plunges in","in milliseconds"],
|
||||||
cd_lift_s: "drill lift",
|
cd_lift_s: "drill lift",
|
||||||
cd_lift_l: ["lift between plunges","after dwell period","in workspace units","0 to disable"],
|
cd_lift_l: ["lift between plunges","after dwell period","in workspace units","0 to disable"],
|
||||||
cd_regi_s: "register",
|
|
||||||
cd_regi_l: ["drill registration holes","for double-sided parts","independent of enable","drilling but uses same","tool and settings"],
|
|
||||||
cd_thru_s: "z extend",
|
cd_thru_s: "z extend",
|
||||||
cd_thru_l: ["extend downward cut through stock","in workspace units"],
|
cd_thru_l: ["extend downward cut through stock","in workspace units"],
|
||||||
cd_dtru_s: "drill through",
|
cd_dtru_s: "drill through",
|
||||||
|
|
@ -609,6 +607,12 @@ self.lang['en-us'] = {
|
||||||
cd_sela_s: "Select Matching Diameter",
|
cd_sela_s: "Select Matching Diameter",
|
||||||
cd_sela_l: ["select all holes that", "match selected tool diameter"],
|
cd_sela_l: ["select all holes that", "match selected tool diameter"],
|
||||||
|
|
||||||
|
//CNC Registration
|
||||||
|
cd_regi_s: "register",
|
||||||
|
cd_regi_l: ["drill registration holes","for double-sided parts","independent of enable","drilling but uses same","tool and settings"],
|
||||||
|
cd_rego_s: "part offset",
|
||||||
|
cd_rego_l: ["offset of hole center","from part bounding box","in workspace units"],
|
||||||
|
|
||||||
// CNC HELICAL tolpath
|
// CNC HELICAL tolpath
|
||||||
ch_menu: "helical",
|
ch_menu: "helical",
|
||||||
ch_sdwn_s: "step down (pitch)",
|
ch_sdwn_s: "step down (pitch)",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue