From 14226a19cb35be4737926a928d2144613c753d2b Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 17 Jan 2023 11:52:35 -0500 Subject: [PATCH 1/2] add COMPACT-OUTPUT and DECIMALS directives in CAM gcode headers --- src/kiri-mode/cam/export.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/kiri-mode/cam/export.js b/src/kiri-mode/cam/export.js index 33120fc4..7ef9eebb 100644 --- a/src/kiri-mode/cam/export.js +++ b/src/kiri-mode/cam/export.js @@ -47,14 +47,16 @@ CAM.export = function(print, online) { spro = settings.process, maxZd = spro.camFastFeedZ, maxXYd = spro.camFastFeed, - decimals = base.config.gcode_decimals || 4, + decimals = base.config.gcode_decimals || 3, pos = { x:null, y:null, z:null, a:undefined, f:null, t:null, emit:null }, line, cidx, mode, point, points = 0, + lastGn = '', rewrite_comments = false, + compact_output = false, lasering = false, laserOp, stock = settings.stock || { }, @@ -249,7 +251,8 @@ CAM.export = function(print, online) { } let speed = out.speed, - nl = [speed ? 'G1' : 'G0'], + gn = speed ? 'G1' : 'G0', + nl = (compact_output && lastGn === gn) ? [] : [gn], dx = opt.dx || newpos.x - pos.x, dy = opt.dy || newpos.y - pos.y, dz = opt.dz || newpos.z - pos.z, @@ -263,6 +266,8 @@ CAM.export = function(print, online) { return; } + lastGn = gn; + if (dx || newpos.x !== pos.x) { pos.x = newpos.x; runbox.min.x = Math.min(runbox.min.x, pos.x); @@ -351,6 +356,12 @@ CAM.export = function(print, online) { } } else if (line.indexOf(';; REWRITE-COMMENTS-PARENS') === 0) { rewrite_comments = true; + } else if (line.indexOf(';; DECMIALS') === 0) { + decimals = parseInt(line.split('=')[1].trim() || 3) || 3; + } else if (line.indexOf(';; COMPACT-OUTPUT') === 0) { + compact_output = true; + stripComments = true; + space = ''; } else { gcodePre.push(line); } From 0dc3f190e4dc2084c9277fc0302f677498201b52 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 17 Jan 2023 19:10:39 -0500 Subject: [PATCH 2/2] add trace support for taper tip diameter and offset override --- release.md | 2 ++ src/kiri-mode/cam/client.js | 2 ++ src/kiri-mode/cam/ops.js | 17 ++++++++++++----- src/kiri-mode/cam/tool.js | 4 ++++ src/kiri/conf.js | 1 + src/kiri/consts.js | 2 +- web/kiri/lang/en.js | 2 ++ 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/release.md b/release.md index 4f2060b3..9ad6ee95 100644 --- a/release.md +++ b/release.md @@ -25,6 +25,8 @@ Full docs @ https://docs.grid.space/projects/kiri-moto * CAM update traces to async slicing, fix use with flip * CAM add threading support for all slicing ops * CAM add omit pocket option to outline op +* CAM add trace support for taper tip diameter +* CAM add trace offset override # Release 3.7 (2022-11-12) diff --git a/src/kiri-mode/cam/client.js b/src/kiri-mode/cam/client.js index 748f4558..a9c628fc 100644 --- a/src/kiri-mode/cam/client.js +++ b/src/kiri-mode/cam/client.js @@ -1313,6 +1313,7 @@ CAM.init = function(kiri, api) { rate: 'camTraceSpeed', plunge: 'camTracePlunge', bottom: 'camTraceBottom', + offover: 'camTraceOffOver', select: 'camTraceMode' }).inputs = { tool: UC.newSelect(LANG.cc_tool, {}, "tools"), @@ -1327,6 +1328,7 @@ CAM.init = function(kiri, api) { step: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,1.0), show:(op) => popOp.trace.rec.mode === "clear"}), down: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, units:true}), thru: UC.newInput(LANG.cc_thru_s, {title:LANG.cc_thru_l, convert:UC.toFloat, units:true}), + offover: UC.newInput(LANG.cc_offd_s, {title:LANG.cc_offd_l, convert:UC.toFloat, units:true, show:() => poppedRec.offset !== "none"}), sep: UC.newBlank({class:"pop-sep", modes:MCAM, show:zBottom, poop:true }), bottom: UC.newBoolean(LANG.cf_botm_s, undefined, {title:LANG.cf_botm_l, show:(op,conf) => conf.process.camZBottom}), sep: UC.newBlank({class:"pop-sep"}), diff --git a/src/kiri-mode/cam/ops.js b/src/kiri-mode/cam/ops.js index f288b33a..e57f84a1 100644 --- a/src/kiri-mode/cam/ops.js +++ b/src/kiri-mode/cam/ops.js @@ -837,7 +837,7 @@ class OpTrace extends CamOp { async slice(progress) { let { op, state } = this; - let { tool, rate, down, plunge, offset, thru } = op; + let { tool, rate, down, plunge, offset, offover, thru } = op; let { settings, widget, addSlices, zMax, zTop, zThru, tabs } = state; let { updateToolDiams, cutTabs, cutPolys, healPolys, color } = state; let { process, stock } = settings; @@ -848,8 +848,10 @@ class OpTrace extends CamOp { // generate tracing offsets from chosen features let sliceOut = this.sliceOut = []; let areas = op.areas[widget.id] || []; - let toolDiam = new CAM.Tool(settings, tool).fluteDiameter(); + let camTool = new CAM.Tool(settings, tool); + let toolDiam = camTool.fluteDiameter(); let toolOver = toolDiam * op.step; + let traceOffset = camTool.traceOffset() let cutdir = process.camConventional; let polys = []; let stockRect = stock.center && stock.x && stock.y ? @@ -975,11 +977,13 @@ class OpTrace extends CamOp { routed.push(poly); }); for (let poly of POLY.nest(routed)) { - let offdist = 0; + let offdist = offover; + if (!offdist) switch (offset) { - case "outside": offdist = toolDiam / 2; break; - case "inside": offdist = -toolDiam / 2; break; + case "outside": offdist = traceOffset; break; + case "inside": offdist = -traceOffset; break; } + console.log({ offdist }); if (offdist) { let pnew = POLY.offset([poly], offdist, { minArea: 0 }); if (pnew) { @@ -1000,6 +1004,9 @@ class OpTrace extends CamOp { followZ(pi.clone().setZ(z)); } } else { + if (thru) { + pi.setZ(pi.getZ() - thru); + } followZ(pi); } } diff --git a/src/kiri-mode/cam/tool.js b/src/kiri-mode/cam/tool.js index 3f048c0a..2889d17a 100644 --- a/src/kiri-mode/cam/tool.js +++ b/src/kiri-mode/cam/tool.js @@ -61,6 +61,10 @@ class Tool { return this.unitScale() * this.tool.taper_tip; } + traceOffset() { + return (this.isTaperMill() ? this.tipDiameter() : this.fluteDiameter()) / 2; + } + shaftLength() { return this.unitScale() * this.tool.shaft_len; } diff --git a/src/kiri/conf.js b/src/kiri/conf.js index 33cc721f..d7e5ad4f 100644 --- a/src/kiri/conf.js +++ b/src/kiri/conf.js @@ -506,6 +506,7 @@ const conf = exports({ camTraceThru: 0, camTraceSpeed: 250, camTracePlunge: 200, + camTraceOffOver: 0, camTraceLines: false, camTraceBottom: false, camPocketSpindle: 1000, diff --git a/src/kiri/consts.js b/src/kiri/consts.js index eb73b0b6..666c22ec 100644 --- a/src/kiri/consts.js +++ b/src/kiri/consts.js @@ -92,7 +92,7 @@ const LISTS = { { name: "clear" } ], traceoff: [ - { name: "center" }, + { name: "none" }, { name: "inside" }, { name: "outside" } ], diff --git a/web/kiri/lang/en.js b/web/kiri/lang/en.js index 10820357..332d41bd 100644 --- a/web/kiri/lang/en.js +++ b/web/kiri/lang/en.js @@ -448,6 +448,8 @@ self.kiri.lang['en-us'] = { cc_sdwn_l: ["step down depth","for each pass","in workspace units","0 to disable"], cc_thru_s: "cut thru", cc_thru_l: ["additional cut depth below trace bottom"], + cc_offd_s: "offset", + cc_offd_l: ["overrides default offset distance (which is the tool radius) when set to any value but zero"], cc_feed_s: "feed rate", cc_feed_l: ["max cutting speed in","workspace units / minute"], cc_plng_s: "plunge rate",