SVG to G-code... "hello world" !

Today I wanted to print more with doing less work. Making the previous program took quite some time and concentration for making some straight lines. Nothing Fancy about that.

I wanted to have a program where you can print (plot) fancy work. In a way that drawings made by my kids (when they will do so in the future) can be plotted. I searched and found an Inkscape extension (I frequently use Inkscape). It didn't work for me.

What I actually wanted was to get all the points from a line and convert them to coordinates in G-code. Basically it means instructing a machine to go to point X... Y...

Here is how I came from this:

to this:

I needed to investigate the .svg file to see if I could easily change the coordinates. I opened Inkscape and first drew a simple line consisting of a few points. I found out that (0,0) is the upper left corner of the canvas. I drew the line in millimeters but the .svg file gives coordinates in 'px' (pixels). After some calculating I decided to scale the line in Inkscape so my coordinates would be in mm. (90 dpi (pixels per inch) gives 28,222 pixels per mm so the line needed to be scaled to 28,2222 percent of the original size)

What is x and y in Inkscape translates to y and x in the .svg file... good to know.

Now the file needs to be opened in a text editor. I highly recommend Sublime Text 2 for this since it is a very powerful editor (I'll come to that later on).

Here are the coordinates:

Delete the rest of the file since we don't need it. Also in my case the first coordinate was written as 0,-1.484375e-5. I changed it to 0,0

Now here's what is so shizzle about Sublime Text... Select one space, and with a shortcut you can select ALL spaces. If you then press "backspace" and after that "enter" and type "G1 Y" you have changed all spaces in "G1 Y"!!! Timesaver!!!

Select all spaces:

Change all spaces:

The same goes for the comma, select "," and change all to " X"

Finish the textfile (add other G-code for putting the pen on paper etc) and it is ready to use for printing...


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.