add z top/bottom limit overrides in pocket and trace

This commit is contained in:
Stewart Allen 2025-02-08 18:59:33 -05:00
commit 38ae2a0f3a
5 changed files with 47 additions and 13 deletions

View file

@ -162,7 +162,9 @@ function inRange(value, min, max) {
function round(v, zeros) {
if (typeof v === 'object') {
for (let [key,val] of Object.entries(v)) {
v[key] = round(val);
if (typeof val === 'number') {
v[key] = round(val, zeros);
}
}
return v;
}

View file

@ -1476,12 +1476,13 @@ CAM.init = function(kiri, api) {
thru: 'camTraceThru',
rate: 'camTraceSpeed',
plunge: 'camTracePlunge',
bottom: 'camTraceBottom',
offover: 'camTraceOffOver',
dogbone: 'camTraceDogbone',
revbone: 'camTraceDogbone',
merge: 'camTraceMerge',
select: 'camTraceMode'
select: 'camTraceMode',
ov_topz: 'camTraceZTop',
ov_botz: 'camTraceZBottom',
}).inputs = {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
select: UC.newSelect(LANG.cc_sele_s, {title:LANG.cc_sele_l}, "select"),
@ -1500,10 +1501,11 @@ CAM.init = function(kiri, api) {
merge: UC.newBoolean(LANG.co_merg_s, undefined, {title:LANG.co_merg_l}),
dogbone: UC.newBoolean(LANG.co_dogb_s, undefined, {title:LANG.co_dogb_l, show:canDogBones}),
revbone: UC.newBoolean(LANG.co_dogr_s, undefined, {title:LANG.co_dogr_l, show:canDogBonesRev}),
expand: UC.newExpand("overrides"),
exp: UC.newExpand("overrides"),
sep: UC.newBlank({class:"pop-sep"}),
bottom: UC.newBoolean(LANG.cf_botm_s, undefined, {title:LANG.cf_botm_l, show:(op,conf) => conf.process.camZBottom}),
end: UC.endExpand(),
ov_topz: UC.newInput(LANG.ou_ztop_s, {title:LANG.ou_ztop_l, convert:UC.toFloat, units:true}),
ov_botz: UC.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:UC.toFloat, units:true}),
exp_end: UC.endExpand(),
sep: UC.newBlank({class:"pop-sep"}),
menu: UC.newRow([ UC.newButton("select", func.traceAdd) ], {class:"ext-buttons f-row"}),
};
@ -1522,6 +1524,8 @@ CAM.init = function(kiri, api) {
contour: 'camPocketContour',
engrave: 'camPocketEngrave',
outline: 'camPocketOutline',
ov_topz: 'camPocketZTop',
ov_botz: 'camPocketZBottom',
tolerance: 'camTolerance',
}).inputs = {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
@ -1542,6 +1546,11 @@ CAM.init = function(kiri, api) {
contour: UC.newBoolean(LANG.cp_cont_s, undefined, {title:LANG.cp_cont_s}),
outline: UC.newBoolean(LANG.cp_outl_s, undefined, {title:LANG.cp_outl_l, show:() => !poppedRec.contour}),
engrave: UC.newBoolean(LANG.cp_engr_s, undefined, {title:LANG.cp_engr_l, show:() => poppedRec.contour}),
exp: UC.newExpand("overrides"),
sep: UC.newBlank({class:"pop-sep"}),
ov_topz: UC.newInput(LANG.ou_ztop_s, {title:LANG.ou_ztop_l, convert:UC.toFloat, units:true}),
ov_botz: UC.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:UC.toFloat, units:true}),
exp_end: UC.endExpand(),
sep: UC.newBlank({class:"pop-sep"}),
menu: UC.newRow([ UC.newButton("select", func.surfaceAdd) ], {class:"ext-buttons f-row"}),
};

View file

@ -953,14 +953,19 @@ class OpTrace extends CamOp {
async slice(progress) {
let { op, state } = this;
let { tool, rate, down, plunge, offset, offover, thru } = op;
let { tool, rate, down, plunge, offset, offover, thru, ov_topz, ov_botz } = op;
let { settings, widget, addSlices, zThru, tabs, workarea } = state;
let { updateToolDiams, cutTabs, cutPolys, healPolys, color } = state;
let { process, stock } = settings;
let { camStockClipTo, camZBottom } = process;
let { camStockClipTo } = process;
if (state.isIndexed) {
throw 'trace op not supported with indexed stock';
}
// apply overrides
workarea.recalc({
top_z: ov_topz,
bottom_z: ov_botz
});
// generate tracing offsets from chosen features
let zTop = workarea.top_z;
let zBottom = workarea.bottom_z;
@ -995,7 +1000,7 @@ class OpTrace extends CamOp {
return slice;
}
function minZ(z) {
return op.bottom && zBottom ? Math.max(zBottom, z - thru) : z - thru;
return zBottom ? Math.max(zBottom, z - thru) : z - thru;
}
function followZ(poly) {
if (op.dogbone) {
@ -1193,9 +1198,16 @@ class OpPocket extends CamOp {
const debug = false;
let { op, state } = this;
let { tool, rate, down, plunge, expand, contour, smooth, tolerance } = op;
let { ov_topz, ov_botz } = op;
let { settings, widget, addSlices, zBottom, zThru, tabs, color } = state;
let { updateToolDiams, cutTabs, cutPolys, healPolys, shadowAt, workarea } = state;
let { process, stock } = settings;
let { updateToolDiams, cutTabs, healPolys, shadowAt, workarea } = state;
let { process } = settings;
// apply overrides
workarea.recalc({
top_z: ov_topz,
bottom_z: ov_botz
});
zBottom = ov_botz ? workarea.bottom_stock + ov_botz : zBottom;
// generate tracing offsets from chosen features
let sliceOut;
let pockets = this.pockets = [];

View file

@ -78,11 +78,18 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
workarea = util.round({
top_stock,
top_part,
top_gap,
top_z,
bottom_stock,
bottom_part,
bottom_gap,
bottom_z,
bottom_cut
bottom_cut,
recalc(val) {
if (val.top_z) workarea.top_z = bottom_stock + val.top_z;
if (val.bottom_z) workarea.bottom_z = bottom_stock + val.bottom_z;
if (val.bottom_z) workarea.bottom_cut = Math.max(workarea.bottom_z, -zThru)
}
}, 3);
// console.table({ workarea });

View file

@ -497,7 +497,9 @@ const conf = exports({
camTracePlunge: 200,
camTraceOffOver: 0,
camTraceLines: false,
camTraceBottom: false,
// camTraceBottom: false,
camTraceZTop: 0,
camTraceZBottom: 0,
camPocketSpindle: 1000,
camPocketTool: 1000,
camPocketOver: 0.25,
@ -511,6 +513,8 @@ const conf = exports({
camPocketContour: false,
camPocketEngrave: false,
camPocketOutline: false,
camPocketZTop: 0,
camPocketZBottom: 0,
camDrillTool: 1000,
camDrillSpindle: 1000,
camDrillDownSpeed: 250,