From ea6d620b1b9d4ae441f48e2fe1f2e6d99066eccc Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 17 Sep 2019 08:55:27 -0400 Subject: [PATCH] svg to gcode requires more work (missing widget, output info) --- js/kiri-print.js | 6 +++--- js/kiri.js | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/kiri-print.js b/js/kiri-print.js index bfd31347..bc40d6fe 100644 --- a/js/kiri-print.js +++ b/js/kiri-print.js @@ -59,13 +59,13 @@ var gs_kiri_print = exports; PRO.parseSVG = function(code, offset) { let scope = this, + svg = new DOMParser().parseFromString(code, 'text/xml'), + lines = [...svg.getElementsByTagName('polyline')], output = scope.output = [], bounds = scope.bounds = { max: { 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 => { let seq = []; let points = [...line.points]; @@ -85,6 +85,7 @@ var gs_kiri_print = exports; output.push(seq); }); scope.lines = lines.length; + scope.bytes = code.length; }; PRO.parseGCode = function(gcode, offset) { @@ -216,7 +217,6 @@ var gs_kiri_print = exports; mode = settings.mode; if (remote) { - // executed from kiri.js KIRI.work.printGCode(function(reply) { scope.lines = reply.lines; diff --git a/js/kiri.js b/js/kiri.js index 14c40776..ccd1a1c8 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -924,6 +924,11 @@ self.kiri.license = exports.LICENSE; showSlices(); switch (type) { case 'svg': + currentPrint.exportGCode(false, gcode => { + // console.log({svg_to_gcode: gcode}); + }, line => { + // console.log({gcode_line: line}); + }); break; default: exportGCode(code);