svg to gcode requires more work (missing widget, output info)
This commit is contained in:
parent
c51444d631
commit
ea6d620b1b
2 changed files with 8 additions and 3 deletions
|
|
@ -59,13 +59,13 @@ var gs_kiri_print = exports;
|
||||||
|
|
||||||
PRO.parseSVG = function(code, offset) {
|
PRO.parseSVG = function(code, offset) {
|
||||||
let scope = this,
|
let scope = this,
|
||||||
|
svg = new DOMParser().parseFromString(code, 'text/xml'),
|
||||||
|
lines = [...svg.getElementsByTagName('polyline')],
|
||||||
output = scope.output = [],
|
output = scope.output = [],
|
||||||
bounds = scope.bounds = {
|
bounds = scope.bounds = {
|
||||||
max: { x:-Infinity, y:-Infinity, z:-Infinity},
|
max: { x:-Infinity, y:-Infinity, z:-Infinity},
|
||||||
min: { x:Infinity, y:Infinity, z:Infinity}
|
min: { x:Infinity, y:Infinity, z:Infinity}
|
||||||
};
|
};
|
||||||
let svg = new DOMParser().parseFromString(code, 'text/xml');
|
|
||||||
let lines = [...svg.getElementsByTagName('polyline')];
|
|
||||||
lines.forEach(line => {
|
lines.forEach(line => {
|
||||||
let seq = [];
|
let seq = [];
|
||||||
let points = [...line.points];
|
let points = [...line.points];
|
||||||
|
|
@ -85,6 +85,7 @@ var gs_kiri_print = exports;
|
||||||
output.push(seq);
|
output.push(seq);
|
||||||
});
|
});
|
||||||
scope.lines = lines.length;
|
scope.lines = lines.length;
|
||||||
|
scope.bytes = code.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
PRO.parseGCode = function(gcode, offset) {
|
PRO.parseGCode = function(gcode, offset) {
|
||||||
|
|
@ -216,7 +217,6 @@ var gs_kiri_print = exports;
|
||||||
mode = settings.mode;
|
mode = settings.mode;
|
||||||
|
|
||||||
if (remote) {
|
if (remote) {
|
||||||
|
|
||||||
// executed from kiri.js
|
// executed from kiri.js
|
||||||
KIRI.work.printGCode(function(reply) {
|
KIRI.work.printGCode(function(reply) {
|
||||||
scope.lines = reply.lines;
|
scope.lines = reply.lines;
|
||||||
|
|
|
||||||
|
|
@ -924,6 +924,11 @@ self.kiri.license = exports.LICENSE;
|
||||||
showSlices();
|
showSlices();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'svg':
|
case 'svg':
|
||||||
|
currentPrint.exportGCode(false, gcode => {
|
||||||
|
// console.log({svg_to_gcode: gcode});
|
||||||
|
}, line => {
|
||||||
|
// console.log({gcode_line: line});
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exportGCode(code);
|
exportGCode(code);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue