Node tool to manipulate G-Code

macbook frame

For the production part of our company we needed a tool to manipulate machine readable G-Code to add additional commands, and edit current ones.

The main thing we needed was to calculate the E command, which in our case was responsible for the extrusion of a glue in a CNC machine. This extrusion value was calculated by taking the vector of the position and calculation the volume based on the diameter of the nozzle the glue would be dispensed through.

Input

G1 Z0.200
G1 E0.80000 F2100.00000
M204 S1000
G1 F1200
X248.447 Y0.596
X250.447 Y3.162
X250.694 Y3.714
X250.782 Y4.316
X250.782 Y206.067

Output

N36 G1 Z0.2 E0
N37 G1 E0 F2100
N38 M204 S1000
N39 G1 E0 F1200
N40 G1 X248.447 Y0.596 E0.0016208280556292073
N41 G1 X250.447 Y3.162 E0.0057677309233079895
N42 G1 X250.694 Y3.714 E0.0010721189474371072
N43 G1 X250.782 Y4.316 E0.001078600148241265
N44 G1 X250.782 Y206.067 E0.35767490304709154

At the end we wrapped the node tool in an electron wrapper to make it easy to use for everyone on the team.

macbook frame