August 2009

Tonight I made two really cool things.

First up is the JavaScript G-Code Translate, Scale, Rotate tool.

I made this because sometimes I may get G-code from another generator or another person that I want to scale. This utility will scale all coordinates by a given value. X,Y,Z can be scaled independently.

It also can translate coordinates. Say you have a file that is 6″x6″ on theĀ  XY plane starts at 0,0 and ends at 6,6. But you like to have objects centered at 0,0. No problem just paste the g-code tell it you want to translate X by -3 and Y by -3. Now the object will be centered at 0,0.

The second thing I wrote tonight was a Spoil Board Surfacing g-code Generator. I had written this before in php. So tonight I ported it to JavaScript and added input boxes to make generating spoil board code super easy.

I have started writing a little collection of functions in JavaScript that will generate g-code for me.

The idea is that I wanted an easy way to script gcode. For example if I want to drill a circle centered at X=0,Y=0,Z=0 and a radius of 1″, I wanted to be able to write drawCircle(x,y,z,radius); instead of the very unwieldy g-code:
(circle x=0 y=0 z=0 radius=1)
G0 X-1.000000 Y0.000000 (rapid to start)
G1 Z0.000000
G17 G2 X-1.000000 Y0.000000 I1.000000 J0.000000 Z0.000000
G0 Z0.500000 (safe z)
(end of circle)

Source code:

This version supports: Lines, Boxes, Circles, Arcs, and deep circles.