add oname and oid params for macro conditions and substitutions

This commit is contained in:
Stewart Allen 2025-09-27 00:19:22 -04:00
commit 7660570f3a
2 changed files with 13 additions and 2 deletions

View file

@ -176,6 +176,14 @@ class Print {
}
constReplace(str, consts, start, pad, short) {
function tryeval(str) {
try {
return eval(`{ ${str} }`)
} catch (e) {
console.log({ eval_error: e, str });
return str;
}
}
let cs = str.indexOf("{", start || 0),
ce = str.indexOf("}", cs),
tok, nutok, nustr;
@ -199,8 +207,7 @@ class Print {
}
eva.push(`function range(a,b) { return (a + (layer / layers) * (b-a)).round(4) }`);
eva.push(`try {( ${tok} )} catch (e) {console.log(e);0}`);
let scr = eva.join('');
let evl = eval(`{ ${scr} }`);
let evl = tryeval(eva.join(''));
nutok = evl;
if (pad === 666) {
return evl;

View file

@ -111,6 +111,8 @@ export function fdm_export(print, online, ondone, ondebug) {
progress: 0,
nozzle: tool,
tool: tool,
oid: '',
oname: '',
model_labels: model_labels.sort().join(',')
},
pidx, path, out, speedMMM, emitMM, emitPerMM, lastp, laste, dist,
@ -620,6 +622,8 @@ export function fdm_export(print, online, ondone, ondebug) {
let b64 = encodeBitOffset(off);
append(`; start object id: ${out.widget.track.grid_id}`);
isBambu && append(`M624 ${b64}`);
subst.oid = out.widget.track.grid_id;
subst.oname = out.widget.meta.file;
}
cwidget = out.widget;
}