From d744bf83703740a0cd831222ec2ad232de1b2a0b Mon Sep 17 00:00:00 2001 From: amandaghassaei <amandaghassaei@gmail.com> Date: Sat, 14 Mar 2015 03:48:28 -0400 Subject: [PATCH] sbp units always in inches --- js/cam/Assembler.js | 15 ++++++++------- js/cam/GCodeExporter.js | 5 ++++- js/cam/ShopbotExporter.js | 12 +++++++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/js/cam/Assembler.js b/js/cam/Assembler.js index 89851849..2d92f056 100644 --- a/js/cam/Assembler.js +++ b/js/cam/Assembler.js @@ -35,6 +35,7 @@ Assembler = Backbone.Model.extend({ this.listenTo(dmaGlobals.appState, "change:units", this._setNeedsPostProcessing); this.listenTo(this, "change:originPosition " + + "change:stockPosition " + "change:feedRate " + "change:rapidSpeeds " + "change:camProcess " + @@ -54,11 +55,10 @@ Assembler = Backbone.Model.extend({ dmaGlobals.three.sceneAdd(origin); this.set("origin", origin); //init stock mesh - var stock = dmaGlobals.lattice.makeCellForLatticeType(null); - var stockMesh = stock.cellMesh.clone(); - stockMesh.scale.set(scale.x, scale.y, scale.z); - dmaGlobals.three.sceneAdd(stockMesh); - this.set("stock", stockMesh); + var stock = new THREE.Mesh(new THREE.SphereGeometry(dmaGlobals.lattice.get("scale")/4), + new THREE.MeshBasicMaterial({color:0xff00ff})); + dmaGlobals.three.sceneAdd(stock); + this.set("stock", stock); this._setCAMVisibility(); }, @@ -129,15 +129,16 @@ Assembler = Backbone.Model.extend({ var order; if (strategy == "xRaster") order = "XYZ"; else if (strategy == "yRaster") order = "YXZ"; + var stockPosition = this.get("stockPosition"); dmaGlobals.lattice.rasterCells(order, function(cell, x, y, z){ if (!cell) return; - data += exporter.rapidXY(0, 0); + data += exporter.rapidXY(stockPosition.x-wcs.x, stockPosition.y-wcs.y); data += exporter.moveZ(stockHeight); data += exporter.moveZ(rapidHeight); var cellPosition = cell.getPosition(); - data += exporter.rapidXY((cellPosition.x-wcs.x).toFixed(3), (cellPosition.y-wcs.y).toFixed(3)); + data += exporter.rapidXY(cellPosition.x-wcs.x, cellPosition.y-wcs.y); data += exporter.moveZ(stockHeight); data += exporter.moveZ(rapidHeight); diff --git a/js/cam/GCodeExporter.js b/js/cam/GCodeExporter.js index 99c18b8a..64ba054f 100644 --- a/js/cam/GCodeExporter.js +++ b/js/cam/GCodeExporter.js @@ -29,7 +29,10 @@ GCodeExporter.prototype.addLine = function(command, params, comment){ data += command + " "; _.each(params, function(param){ if (!param) return; - data += param + " "; + if (isNaN(parseFloat(param))) { + data += param + " "; + } + data += param.toFixed(3) + " "; }); if (comment) data += "(" + comment + ")"; data += "\n"; diff --git a/js/cam/ShopbotExporter.js b/js/cam/ShopbotExporter.js index 4b89f60b..4fe28e78 100644 --- a/js/cam/ShopbotExporter.js +++ b/js/cam/ShopbotExporter.js @@ -21,8 +21,14 @@ ShopbotExporter.prototype.makeHeader = function(){ ShopbotExporter.prototype.addLine = function(command, params, comment){ var data = ""; data += command + " "; + var self = this; _.each(params, function(param){ - data += param + ", "; + if (isNaN(parseFloat(param))) { + data += param + ", "; + return; + } + if (dmaGlobals.appState.get("units") == "mm") param = self.convertToInches(param);//all shopbot stuff must be in inches + data += param.toFixed(3) + ", "; }); if (comment) data += "'" +comment; data += "\n"; @@ -69,3 +75,7 @@ ShopbotExporter.prototype.save = function(data){ var blob = new Blob([data], {type: "text/plain;charset=utf-8"}); saveAs(blob, "ShopbotExport" + ".sbp"); }; + +ShopbotExporter.prototype.convertToInches = function(mm){ + return mm*0.0393701; +} -- GitLab