add extruder deselect script. relegate extruder abs/rel to detection via gcode header parsing

This commit is contained in:
Stewart Allen 2021-02-09 10:25:23 -05:00
commit b5c8b19864
6 changed files with 36 additions and 13 deletions

View file

@ -11,10 +11,12 @@
* `P` client/worker interface normalization
* `P` explore widget vertex reloading / replacing (Onshape primarily)
* `F` G2/G3 arc output / input
* `F` add % field type with conversion (like units)
* `F` complete G2/G3 arc output / input (85% now)
* `F` expose grouping feature
* `F` SVG import to 3D part like images
* `F` bundle current profile into exported device
* `F` integrate svg nest arrange algorithm
# FDM
@ -67,6 +69,7 @@
* `B` climb vs conventional not fully consistent after refactor
* `B` outside cutting direction in roughing mode inverted
* `F` add layout spacing preference
* `F` import SVG into a path that can be overlaid onto a 3D mesh (laser?)
* `F` intelligently turn circle hole pocket clear into spiral down
* `F` trace follow hole that matches endmill should turn into a drill op
@ -111,6 +114,7 @@
* http://wiki.imal.org/howto/cnc-milling-introduction-cutting-tools
* http://www.twak.co.uk/2011/01/degeneracy-in-weighted-straight.html
* http://photon.chrisgraf.de/
* https://github.com/Jack000/SVGnest
# More CNC

View file

@ -77,6 +77,7 @@
extFilament: device.filamentSize,
extNozzle: device.nozzleSize,
extSelect: ["T0"],
extDeselect: [],
extOffsetX: 0,
extOffsetY: 0
}];
@ -143,6 +144,7 @@
if (rec.offset_x) e.extOffsetX = rec.offset_x;
if (rec.offset_y) e.extOffsetY = rec.offset_y;
if (rec.select) e.extSelect = rec.select;
if (rec.deselect) e.extDeselect = rec.deselect;
device.extruders.push(e);
});
} else {
@ -273,6 +275,7 @@
extFilament: 1.75,
extNozzle: 0.4,
extSelect: ["T0"],
extDeselect: [],
extOffsetX: 0,
extOffsetY: 0
}]

View file

@ -739,6 +739,12 @@
// add extruder selection buttons
if (dev.extruders) {
for (let ext of dev.extruders) {
// add missing deselect field from legacy configs
if (!ext.extDeselect) {
ext.extDeselect = [];
}
}
let ext = API.lists.extruders = [];
dev.internal = 0;
let selext = $('pop-nozzle');
@ -768,7 +774,6 @@
UI.bedDepth,
UI.bedWidth,
UI.maxHeight,
UI.extrudeAbs,
UI.deviceOrigin,
UI.deviceRound,
UI.deviceBelt,
@ -792,12 +797,12 @@
UI.extDel,
UI.extOffsetX,
UI.extOffsetY,
UI.extSelect
UI.extSelect,
UI.extDeselect
].forEach(function(e) {
e.disabled = !local;
});
UI.extrudeAbs.style.display = mode === 'CAM' ? 'none' : 'flex';
UI.deviceSave.disabled = !local;
UI.deviceDelete.disabled = !local;
UI.deviceExport.disabled = !local;
@ -1570,7 +1575,7 @@
extOffsetX: UC.newInput(LANG.dv_exox_s, {title:LANG.dv_exox_l, convert:UC.toFloat, modes:FDM}),
extOffsetY: UC.newInput(LANG.dv_exoy_s, {title:LANG.dv_exoy_l, convert:UC.toFloat, modes:FDM}),
extSelect: UC.newText(LANG.dv_exts_s, {title:LANG.dv_exts_l, modes:FDM, size:14, height:3, modes:FDM, area:gcode}),
extrudeAbs: UC.newBoolean(LANG.dv_xtab_s, onBooleanClick, {title:LANG.dv_xtab_l, modes:FDM}),
extDeselect: UC.newText(LANG.dv_dext_s, {title:LANG.dv_dext_l, modes:FDM, size:14, height:3, modes:FDM, area:gcode}),
extActions: UC.newRow([
UI.extPrev = UC.newButton(undefined, undefined, {icon:'<i class="fas fa-less-than"></i>'}),
UI.extAdd = UC.newButton(undefined, undefined, {icon:'<i class="fas fa-plus"></i>'}),

View file

@ -1974,6 +1974,7 @@
UI.extAdd.onclick = function() {
let copy = clone(device.extruders[device.internal]);
copy.extSelect = [`T${device.extruders.length}`];
copy.extDeselect = [];
device.extruders.push(copy);
device.internal = device.extruders.length - 1;
updateExtruderFields(device);

View file

@ -28,7 +28,8 @@
extruder = extruders[tool],
offset_x = extruder.extOffsetX,
offset_y = extruder.extOffsetY,
extrudeAbs = device.extrudeAbs,
extrudeAbs = device.extrudeAbs || false,
extrudeSet = false,
time = 0,
layer = 0,
pause = [],
@ -135,7 +136,7 @@
}
function appendAllSub(arr, pad) {
if (!arr) return;
if (!arr || arr.length === 0) return;
if (!Array.isArray(arr)) arr = [ arr ];
arr.forEach(function(line) { appendSub(line, pad) });
}
@ -156,10 +157,16 @@
let line = device.gcodePre[i];
if (line.indexOf('T0') >= 0) t0 = true; else
if (line.indexOf('T1') >= 0) t1 = true; else
if (line.indexOf('M82') >= 0) extrudeAbs = true; else
if (line.indexOf('M83') >= 0) extrudeAbs = false; else
if (line.indexOf('G90') >= 0) extrudeAbs = true; else
if (line.indexOf('G91') >= 0) extrudeAbs = false; else
if (line.indexOf('M82') >= 0) {
extrudeAbs = true;
extrudeSet = true;
} else
if (line.indexOf('M83') >= 0) {
extrudeAbs = false;
extrudeSet = true;
} else
if (line.indexOf('G90') >= 0 && !extrudeSet) extrudeAbs = true; else
if (line.indexOf('G91') >= 0 && !extrudeSet) extrudeAbs = false; else
if (line.indexOf('G92') === 0) {
line.split(";")[0].split(' ').forEach(function (tok) {
let val = parseFloat(tok.substring(1) || 0) || 0;
@ -355,8 +362,9 @@
out = path[pidx];
speedMMM = (out.speed || process.outputFeedrate) * 60;
// look for extruder change and recalc emit factor
// look for extruder change, run scripts, recalc emit factor
if (out.tool !== undefined && out.tool !== tool) {
appendAllSub(extruder.extDeselect);
tool = out.tool;
subst.nozzle = subst.tool = tool;
extruder = extruders[tool];

View file

@ -68,7 +68,9 @@ kiri.lang['en-us'] = {
dv_lzof_s: "laser off",
dv_lzof_l: "gcode laser off script",
dv_exts_s: "select",
dv_exts_l: "gcode to select this extruder",
dv_exts_l: "gcode run to enable this extruder",
dv_dext_s: "deselect",
dv_dext_l: "gcode run before enabling another extruder",
dv_extd_s: "deselect",
dv_extd_l: "gcode to deselect this extruder",
dv_exox_s: "offset x",