Skip to content

Commit

Permalink
https://github.com/LaserWeb/LaserWeb4/issues/492
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerobles committed Jun 20, 2018
1 parent 7225613 commit d358301
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/lib/action2gcode/generators/abstract-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ class AbstractGenerator {
this.settings = settings;
}

}
postProcessRaster(gcode){
if (this.settings.gcodeToolOn && this.settings.gcodeToolOff){
return gcode.replace(new RegExp("G0(.*?)G1","gis"),'G0$1\n'+this.settings.gcodeToolOn+'\nG1').replace(new RegExp("G1(.*?)G0","gis"),'G1$1\n'+this.settings.gcodeToolOff+'\nG0')
}
return gcode;
}

}

// Exports
export { AbstractGenerator }
export default AbstractGenerator
6 changes: 4 additions & 2 deletions src/lib/cam-gcode-raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DOCUMENT_INITIALSTATE } from '../reducers/document'
import RasterToGcode from './lw.raster2gcode/raster-to-gcode';
import queue from 'queue'
import { promisedImage } from '../components/image-filters.js';

import { getGenerator } from "./action2gcode/gcode-generator"

const getImageBounds=(t,w,h)=>{
let tx = (x, y) => t[0] * x + t[2] * y;
Expand Down Expand Up @@ -59,6 +59,8 @@ export function getLaserRasterGcodeFromOp(settings, opIndex, op, docsWithImages,
QE.timeout = 3600 * 1000
QE.chunk = 100 / docsWithImages.length

var generator=getGenerator(settings.gcodeGenerator,settings)

// POSTPROCESS GCODE;
const postProcessing = (gc) => {

Expand Down Expand Up @@ -118,7 +120,7 @@ export function getLaserRasterGcodeFromOp(settings, opIndex, op, docsWithImages,
//g += `${settings.gcodeToolOn} \r\n`;
}

g += raster; //g += (raster.replace(/G1/gi,'\nM5;\nM3;\nG1').replace(/G0/gi,'M5;\nG0')); TOOL ON OFF?
g += generator.postProcessRaster(raster); //g += (raster.replace(/G1/gi,'\nM5;\nM3;\nG1').replace(/G0/gi,'M5;\nG0')); TOOL ON OFF?

if (settings.gcodeToolOff && settings.gcodeToolOff.length)
g += `${settings.gcodeToolOff} \r\n`;
Expand Down

0 comments on commit d358301

Please sign in to comment.