add comment rewrite option to support parenthesis fixes #231
This commit is contained in:
parent
130da4f2d1
commit
bbb98eda41
1 changed files with 30 additions and 17 deletions
|
|
@ -53,6 +53,7 @@ CAM.export = function(print, online) {
|
|||
mode,
|
||||
point,
|
||||
points = 0,
|
||||
rewrite_comments = false,
|
||||
lasering = false,
|
||||
laserOp,
|
||||
stock = settings.stock || { },
|
||||
|
|
@ -94,6 +95,16 @@ CAM.export = function(print, online) {
|
|||
if (line) {
|
||||
lines++;
|
||||
bytes += line.length;
|
||||
if (rewrite_comments) {
|
||||
const spos = line.indexOf(';');
|
||||
if (spos >= 0) {
|
||||
const left = line.substring(0, spos);
|
||||
const right = '(' + line.substring(spos)
|
||||
.replace(/; /g,'')
|
||||
.replace(/;/g,'') + ')';
|
||||
line = [ left, right ].join('');
|
||||
}
|
||||
}
|
||||
output.append(line);
|
||||
}
|
||||
if (!line || output.length > 1000) {
|
||||
|
|
@ -305,23 +316,6 @@ CAM.export = function(print, online) {
|
|||
points++;
|
||||
}
|
||||
|
||||
section('header');
|
||||
if (!stripComments) {
|
||||
append(`; Generated by Kiri:Moto ${kiri.version}`);
|
||||
append(`; ${new Date().toString()}`);
|
||||
filterEmit(["; Bed left:{left} right:{right} top:{top} bottom:{bottom}"], consts);
|
||||
if (hasStock) {
|
||||
append(`; Stock X:${stock.x.round(2)} Y:${stock.y.round(2)} Z:${stock.z.round(2)}`);
|
||||
}
|
||||
append(`; Target: ${settings.filter[settings.mode]}`);
|
||||
append("; --- process ---");
|
||||
for (let pk in spro) {
|
||||
if (pk !== "ops" && pk !== "op2") {
|
||||
append("; " + pk + " = " + spro[pk]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// look for SCALE header directive
|
||||
let gcodePre = [];
|
||||
for (let line of device.gcodePre) {
|
||||
|
|
@ -336,11 +330,30 @@ CAM.export = function(print, online) {
|
|||
} catch (e) {
|
||||
console.log('malformed scale directive', line);
|
||||
}
|
||||
} else if (line.indexOf(';; REWRITE-COMMENTS-PARENS') === 0) {
|
||||
rewrite_comments = true;
|
||||
} else {
|
||||
gcodePre.push(line);
|
||||
}
|
||||
}
|
||||
|
||||
section('header');
|
||||
if (!stripComments) {
|
||||
append(`; Generated by Kiri:Moto ${kiri.version}`);
|
||||
append(`; ${new Date().toString()}`);
|
||||
filterEmit(["; Bed left:{left} right:{right} top:{top} bottom:{bottom}"], consts);
|
||||
if (hasStock) {
|
||||
append(`; Stock X:${stock.x.round(2)} Y:${stock.y.round(2)} Z:${stock.z.round(2)}`);
|
||||
}
|
||||
append(`; Target: ${settings.filter[settings.mode]}`);
|
||||
append("; --- process ---");
|
||||
for (let pk in spro) {
|
||||
if (pk !== "ops" && pk !== "op2") {
|
||||
append("; " + pk + " = " + spro[pk]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// collect tool info to add to header
|
||||
let toolz = {}, ctool;
|
||||
// remap points as necessary for origins, offsets, inversions
|
||||
|
|
|
|||
Loading…
Reference in a new issue