@@ -56,18 +56,6 @@ Run this example with babel-node:
5656``` js
5757import { GCodeToolpath } from ' gcode-toolpath' ;
5858
59- let toolpaths = [];
60- let gcode = new GCodeToolpath ({
61- addLine : (modalState , v1 , v2 ) => {
62- var motion = modalState .motion ;
63- toolpaths .push ({ motion: motion, v1: v1, v2: v2 });
64- },
65- addArcCurve : (modalState , v1 , v2 , v0 ) => {
66- var motion = modalState .motion ;
67- toolpaths .push ({ motion: motion, v1: v1, v2: v2, v0: v0 });
68- }
69- });
70-
7159const GCODE = [
7260 ' N1 G17 G20 G90 G94 G54' ,
7361 ' N2 G0 Z0.25' ,
@@ -82,9 +70,28 @@ const GCODE = [
8270 ' N11 G00 X0. Y0. Z0.25'
8371].join (' \n ' );
8472
85- gcode .loadFromString (GCODE , (err , results ) => {
86- console .log (toolpaths);
73+ let toolpaths = [];
74+ let gcode = new GCodeToolpath ({
75+ addLine : (modalState , v1 , v2 ) => {
76+ var motion = modalState .motion ;
77+ toolpaths .push ({ motion: motion, v1: v1, v2: v2 });
78+ },
79+ addArcCurve : (modalState , v1 , v2 , v0 ) => {
80+ var motion = modalState .motion ;
81+ toolpaths .push ({ motion: motion, v1: v1, v2: v2, v0: v0 });
82+ }
8783});
84+
85+ gcode
86+ .loadFromString (GCODE , (err , results ) => {
87+ console .log (toolpaths);
88+ })
89+ .on (' data' , (data ) => {
90+ // 'data' event listener
91+ })
92+ .on (' end' , (results ) => {
93+ // 'end' event listener
94+ });
8895```
8996
9097and you will see the output as below:
0 commit comments