99## Usage
1010
1111``` js
12- var GCodeToolpath = require (' gcode-toolpath' ). GCodeToolpath ;
12+ const Toolpath = require (' gcode-toolpath' );
1313
14- var toolpaths = [];
15- var gcode = new GCodeToolpath ({
16- modalState : { // [optional] initial modal state
14+ const toolpaths = [];
15+ const gcode = new Toolpath ({
16+ modal : { // [optional] initial modal state
1717 motion: ' G0' , // G0, G1, G2, G3, G38.2, G38.3, G38.4, G38.5, G80
18- coordinate : ' G54' , // G54, G55, G56, G57, G58, G59
18+ wcs : ' G54' , // G54, G55, G56, G57, G58, G59
1919 plane: ' G17' , // G17: xy-plane, G18: xz-plane, G19: yz-plane
2020 units: ' G21' , // G20: Inches, G21: Millimeters
2121 distance: ' G90' , // G90: Absolute, G91: Relative
22- feedrate: ' G94' , // G93: Inverse Time Mode , G94: Units Per Minutes
23- program: ' M0' ,
24- spindle: ' M5' ,
25- coolant: ' M9'
22+ feedrate: ' G94' , // G93: Inverse time mode , G94: Units per minute, G95: Units per rev
23+ program: ' M0' , // M0, M1, M2, M30
24+ spindle: ' M5' , // M3, M4, M5
25+ coolant: ' M9' // M7, M8, M9
2626 },
27- addLine : (modalState , v1 , v2 ) => {
28- var motion = modalState .motion ;
27+ addLine : (modal , v1 , v2 ) => {
28+ var motion = modal .motion ;
2929 toolpaths .push ({ motion: motion, v1: v1, v2: v2 });
3030 },
31- addArcCurve : (modalState , v1 , v2 , v0 ) => {
32- var motion = modalState .motion ;
31+ addArcCurve : (modal , v1 , v2 , v0 ) => {
32+ var motion = modal .motion ;
3333 toolpaths .push ({ motion: motion, v1: v1, v2: v2, v0: v0 });
3434 }
3535});
3636
3737// Load G-code from file
38- var file = ' example.nc' ;
38+ const file = ' example.nc' ;
3939gcode .loadFromFile (file, function (err , data ) {
4040});
4141
4242// Load G-code from stream
43- var stream = fs .createReadStream (file, { encoding: ' utf8' });
43+ const stream = fs .createReadStream (file, { encoding: ' utf8' });
4444gcode .loadFromStream (stream, function (err , data ) {
4545});
4646
4747// Load G-code from string
48- var str = fs .readFileSync (file, ' utf8' );
48+ const str = fs .readFileSync (file, ' utf8' );
4949gcode .loadFromString (str, function (err , data ) {
5050});
5151```
@@ -54,7 +54,7 @@ gcode.loadFromString(str, function(err, data) {
5454
5555Run this example with babel-node:
5656``` js
57- import { GCodeToolpath } from ' gcode-toolpath' ;
57+ import Toolpath from ' gcode-toolpath' ;
5858
5959const GCODE = [
6060 ' N1 G17 G20 G90 G94 G54' ,
@@ -70,14 +70,14 @@ const GCODE = [
7070 ' N11 G00 X0. Y0. Z0.25'
7171].join (' \n ' );
7272
73- let toolpaths = [];
74- let gcode = new GCodeToolpath ({
75- addLine : (modalState , v1 , v2 ) => {
76- var motion = modalState .motion ;
73+ const toolpaths = [];
74+ const gcode = new Toolpath ({
75+ addLine : (modal , v1 , v2 ) => {
76+ const motion = modal .motion ;
7777 toolpaths .push ({ motion: motion, v1: v1, v2: v2 });
7878 },
79- addArcCurve : (modalState , v1 , v2 , v0 ) => {
80- var motion = modalState .motion ;
79+ addArcCurve : (modal , v1 , v2 , v0 ) => {
80+ const motion = modal .motion ;
8181 toolpaths .push ({ motion: motion, v1: v1, v2: v2, v0: v0 });
8282 }
8383});
0 commit comments