add relative support to gcode parsing
This commit is contained in:
parent
f41d166199
commit
ef32999dfc
3 changed files with 30 additions and 9 deletions
|
|
@ -1165,7 +1165,6 @@
|
||||||
}
|
}
|
||||||
poly.parent = parent || this.parent;
|
poly.parent = parent || this.parent;
|
||||||
poly.area2 = this.area2;
|
poly.area2 = this.area2;
|
||||||
poly.open = this.open;
|
|
||||||
return poly;
|
return poly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,11 +168,14 @@
|
||||||
|
|
||||||
lines.forEach(function(line) {
|
lines.forEach(function(line) {
|
||||||
if (line.indexOf('- LAYER ') > 0) {
|
if (line.indexOf('- LAYER ') > 0) {
|
||||||
|
seq.height = defh;
|
||||||
const hd = line.replace('(','').replace(')','').split(' ');
|
const hd = line.replace('(','').replace(')','').split(' ');
|
||||||
defh = parseFloat(hd[4]);
|
defh = parseFloat(hd[4]);
|
||||||
|
if (fdm) dz = -defh / 2;
|
||||||
}
|
}
|
||||||
line = line.split(";")[0].split(" ");
|
line = line.split(";")[0].split(" ").filter(v => v);
|
||||||
let cmd = line.shift();
|
let cmd = line.shift();
|
||||||
|
if (!cmd) return;
|
||||||
if (cmd.charAt(0) === 'T') {
|
if (cmd.charAt(0) === 'T') {
|
||||||
let ext = scope.settings.device.extruders;
|
let ext = scope.settings.device.extruders;
|
||||||
let pos = parseInt(cmd.charAt(1));
|
let pos = parseInt(cmd.charAt(1));
|
||||||
|
|
@ -201,10 +204,21 @@
|
||||||
G0G1(true);
|
G0G1(true);
|
||||||
break;
|
break;
|
||||||
case 'G1':
|
case 'G1':
|
||||||
|
const mov = {};
|
||||||
line.forEach(function(tok) {
|
line.forEach(function(tok) {
|
||||||
pos[tok.charAt(0)] = parseFloat(tok.substring(1));
|
if (abs) {
|
||||||
|
pos[tok.charAt(0)] = parseFloat(tok.substring(1));
|
||||||
|
} else {
|
||||||
|
mov[tok.charAt(0)] = parseFloat(tok.substring(1));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
G0G1(fdm ? pos.E == 0 : false);
|
if (!abs) {
|
||||||
|
for (let [k,v] of Object.entries(mov)) {
|
||||||
|
console.log(k, v, line);
|
||||||
|
pos[k] += v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
G0G1(fdm ? pos.E <= 0 : false);
|
||||||
break;
|
break;
|
||||||
case 'M6':
|
case 'M6':
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -436,6 +436,13 @@
|
||||||
const output = new KIRI.Render();
|
const output = new KIRI.Render();
|
||||||
layers.push(output);
|
layers.push(output);
|
||||||
|
|
||||||
|
// const updateTool = (toolid) => {
|
||||||
|
// toolid = toolid || 0;
|
||||||
|
// const array = prints[toolid] = prints[toolid] || [];
|
||||||
|
// const tool = tools[toolid] || {};
|
||||||
|
// array.width = (tool.extNozzle || 1) / 2;
|
||||||
|
// }
|
||||||
|
|
||||||
const pushPrint = (toolid, poly) => {
|
const pushPrint = (toolid, poly) => {
|
||||||
toolid = toolid || 0;
|
toolid = toolid || 0;
|
||||||
const array = prints[toolid] = prints[toolid] || [];
|
const array = prints[toolid] = prints[toolid] || [];
|
||||||
|
|
@ -462,6 +469,7 @@
|
||||||
current.color = color(out);
|
current.color = color(out);
|
||||||
pushPrint(out.tool, current);
|
pushPrint(out.tool, current);
|
||||||
}
|
}
|
||||||
|
// updateTool(out.tool);
|
||||||
current.push(out.point);
|
current.push(out.point);
|
||||||
} else {
|
} else {
|
||||||
if (lastOut.emit) {
|
if (lastOut.emit) {
|
||||||
|
|
@ -483,11 +491,11 @@
|
||||||
}
|
}
|
||||||
lastOut = out;
|
lastOut = out;
|
||||||
});
|
});
|
||||||
if (lastOut.emit) {
|
// if (lastOut.emit) {
|
||||||
// pushPrint(lastOut.tool, current)
|
// pushPrint(lastOut.tool, current)
|
||||||
} else {
|
// } else {
|
||||||
moves.push(current);
|
// moves.push(current);
|
||||||
}
|
// }
|
||||||
output
|
output
|
||||||
.setLayer('move', moveColor, opts.moves !== true)
|
.setLayer('move', moveColor, opts.moves !== true)
|
||||||
.addPolys(moves, { thin: true, z: opts.z });
|
.addPolys(moves, { thin: true, z: opts.z });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue