Skip to content
Snippets Groups Projects
Commit d744bf83 authored by amandaghassaei's avatar amandaghassaei
Browse files

sbp units always in inches

parent 720a9ff4
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ Assembler = Backbone.Model.extend({ ...@@ -35,6 +35,7 @@ Assembler = Backbone.Model.extend({
this.listenTo(dmaGlobals.appState, "change:units", this._setNeedsPostProcessing); this.listenTo(dmaGlobals.appState, "change:units", this._setNeedsPostProcessing);
this.listenTo(this, this.listenTo(this,
"change:originPosition " + "change:originPosition " +
"change:stockPosition " +
"change:feedRate " + "change:feedRate " +
"change:rapidSpeeds " + "change:rapidSpeeds " +
"change:camProcess " + "change:camProcess " +
...@@ -54,11 +55,10 @@ Assembler = Backbone.Model.extend({ ...@@ -54,11 +55,10 @@ Assembler = Backbone.Model.extend({
dmaGlobals.three.sceneAdd(origin); dmaGlobals.three.sceneAdd(origin);
this.set("origin", origin); this.set("origin", origin);
//init stock mesh //init stock mesh
var stock = dmaGlobals.lattice.makeCellForLatticeType(null); var stock = new THREE.Mesh(new THREE.SphereGeometry(dmaGlobals.lattice.get("scale")/4),
var stockMesh = stock.cellMesh.clone(); new THREE.MeshBasicMaterial({color:0xff00ff}));
stockMesh.scale.set(scale.x, scale.y, scale.z); dmaGlobals.three.sceneAdd(stock);
dmaGlobals.three.sceneAdd(stockMesh); this.set("stock", stock);
this.set("stock", stockMesh);
this._setCAMVisibility(); this._setCAMVisibility();
}, },
...@@ -129,15 +129,16 @@ Assembler = Backbone.Model.extend({ ...@@ -129,15 +129,16 @@ Assembler = Backbone.Model.extend({
var order; var order;
if (strategy == "xRaster") order = "XYZ"; if (strategy == "xRaster") order = "XYZ";
else if (strategy == "yRaster") order = "YXZ"; else if (strategy == "yRaster") order = "YXZ";
var stockPosition = this.get("stockPosition");
dmaGlobals.lattice.rasterCells(order, function(cell, x, y, z){ dmaGlobals.lattice.rasterCells(order, function(cell, x, y, z){
if (!cell) return; 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(stockHeight);
data += exporter.moveZ(rapidHeight); data += exporter.moveZ(rapidHeight);
var cellPosition = cell.getPosition(); 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(stockHeight);
data += exporter.moveZ(rapidHeight); data += exporter.moveZ(rapidHeight);
......
...@@ -29,7 +29,10 @@ GCodeExporter.prototype.addLine = function(command, params, comment){ ...@@ -29,7 +29,10 @@ GCodeExporter.prototype.addLine = function(command, params, comment){
data += command + " "; data += command + " ";
_.each(params, function(param){ _.each(params, function(param){
if (!param) return; if (!param) return;
data += param + " "; if (isNaN(parseFloat(param))) {
data += param + " ";
}
data += param.toFixed(3) + " ";
}); });
if (comment) data += "(" + comment + ")"; if (comment) data += "(" + comment + ")";
data += "\n"; data += "\n";
......
...@@ -21,8 +21,14 @@ ShopbotExporter.prototype.makeHeader = function(){ ...@@ -21,8 +21,14 @@ ShopbotExporter.prototype.makeHeader = function(){
ShopbotExporter.prototype.addLine = function(command, params, comment){ ShopbotExporter.prototype.addLine = function(command, params, comment){
var data = ""; var data = "";
data += command + " "; data += command + " ";
var self = this;
_.each(params, function(param){ _.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; if (comment) data += "'" +comment;
data += "\n"; data += "\n";
...@@ -69,3 +75,7 @@ ShopbotExporter.prototype.save = function(data){ ...@@ -69,3 +75,7 @@ ShopbotExporter.prototype.save = function(data){
var blob = new Blob([data], {type: "text/plain;charset=utf-8"}); var blob = new Blob([data], {type: "text/plain;charset=utf-8"});
saveAs(blob, "ShopbotExport" + ".sbp"); saveAs(blob, "ShopbotExport" + ".sbp");
}; };
ShopbotExporter.prototype.convertToInches = function(mm){
return mm*0.0393701;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment