From 40e95f9b5ccc6ea92119098d7adbbdc6f6dfda93 Mon Sep 17 00:00:00 2001 From: Teja Date: Tue, 7 Apr 2015 09:21:39 +0200 Subject: [PATCH] fixes gcode preview. first line is not omitted anymore. --- src/octoprint/plugins/svgtogcode/static/js/gcode_parser.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/gcode_parser.js b/src/octoprint/plugins/svgtogcode/static/js/gcode_parser.js index 1185355c..ff5430d1 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/gcode_parser.js +++ b/src/octoprint/plugins/svgtogcode/static/js/gcode_parser.js @@ -63,6 +63,7 @@ $(function() { y = prevY + Number(args[j].slice(1)) + offset.y; } else { y = Number(args[j].slice(1)) + offset.y; +// console.log('#', gcode_lines[i-2], gcode_lines[i-1], line, y); } break; @@ -346,8 +347,8 @@ $(function() { z = 0; } } - - if (addToModel) { + + if (addToModel && !isNaN(x) && !isNaN(y)) { // TODO: hack. unclear why y sometimes is undefined. model.push({ x: x, y: y, @@ -403,7 +404,7 @@ $(function() { if (typeof (blockCallback) === 'function' && typeof (blockDelimiter) !== 'undefined' && blockDelimiter.test(line)) { blockCallback(model); - model = []; + model = model.slice(-1); // keep the last element as start of the next block } }