Inkscape G-code Tutorial

Is it hard to learn cnc?

Getting started with a Cnc mill or router can be overwhelming, there are many aspects you will need to grasp and learn to apply.

Starting with simple decorative craft projects can be an easier way to learn the basics of cnc machining.

After reading this inkscape G Code tutorial and using this to learn the basics, then you will be more able to progress to more complex and dimensionally accurate projects.

Many of you may just want to only do craft projects, it can be really enjoyable and is actually pretty easy once you have learnt the basic steps to follow.

This is where the free software “inkscape” comes in. It is a vector graphics program that allows you to draw freeform shapes which can then be converted to G-code using the ‘gcode tools’ extension.

Inkscapes ability as cad cam software is very limited though, the G-code function is an extra add on extension and not the software’s main purpose.

The words it uses to explain the processes bear no resemblance to any ‘proper’ cnc terminology.

Also it only produces the code for the paths you draw, some additional G-code will be needed to create a proper functioning program, more on this later.

We’re an affiliate
We hope you love the products we recommend. Just so you know, we may earn a small commission at no cost to you if you make a purchase through one of our links.

The first task to accomplish is to get familiar with inkscape, you could try and figure it out yourself, but I would highly recommend a dedicated course.

Udemy have a good selection to choose from including the one in the link below which I can recommend.

Can Inkscape do 3D?

There is a simple answer to this question. No, Inkscape cannot produce 3D tool paths.

All Inkscape can produce are simple 2D contours, which is what this article will (attempt) to teach you to do. So if this is the information you need, keep reading!

You can find and download a vector graphics file (.SVG) on the web or you can draw a shape yourself.

You can also find a picture of the shape you want, import the jpeg file into inkscape and trace around it using the bezier pen tool. 

For this tutorial I am going to draw the outline of a bat and create a very simple program that will cut a shallow path in a piece of wood. Not very artistic or mind blowing but it will demonstrate the basic process needed to use this software.

picture of a bat
The Bat shape I am going to replicate in G-Code using Inkscape

How do I generate g codes in inkscape?

After you have practised using Inkscape a few times and you are ready to create your shape, start with a new document.

Go to File>Document Properties. Select the ‘page’ tab and enter your chosen units in the two boxes. Then in the custom size section, enter the overall size of the stock you will be using and make sure the scale is set to ‘1’.

g-code generation in inkscape

If you are creating an object or drawing a shape ‘freehand’, go ahead and do that now. If you are importing a shape to trace around like I am, you will need to import it.

Go to File>Import and select your image/vector file. Resize the file to fit on the page you created, making sure it will fit in the boundary of your stock size.

I used a jpeg image of a bat, so I have to trace around it to create a vector that the software can use for the G-code generation.

g-code generation in inkscape
After tracing your image you can delete it

Trace your image

To do this you use the bezier pen tool. There is a tutorial on YouTube here that should help with using the bezier pen tool.

Once you have traced around your picture you can move it to one side or delete it. You will not need the picture again once you have the outline completed.

Object to Path

If you didn’t trace around a jpeg or you created an object using a shape tool you need to convert it to a path.

To do this, select your object (important), then go to Path>Object to path. I have shown the process below even though I had already created a path by tracing.

g-code generation in inkscape
Make sure your object is selected

Create your G-Code

The next step in the process is to set your tool library. 

To do this go to Extensions>Gcodetools>tools library. A box will pop up for you to choose what type of tool you want. For now just choose ‘cone’. I assume this is meant to be a pointed engraving tool. We will be programming the tool “on” the outline so this will be ok.

Click ‘apply’ and a green box will appear with tool information in it. If you are creating a small part, the green box may appear very large in size. If it does, select it and resize it by dragging the corner arrow.

You can now change the parameters in the box by selecting the number you want to change and then double clicking on it. Type in your new value, this is mainly dependant on what units you are using, e.g. inches or millimeters.

g-code generation in inkscape
Creating a tool

Setting Your Datum position

The next task is to select Extensions>gcodetools>orientation points. Another box will appear which I think is the equivalent to selecting your datum offset positions.

Choose in-out reference point, this option seemed to work best for me.

If you choose 2 points mode it will repeat the G-Code two more times. I think this is for transforming the shape to produce multiple positions.

Press Apply. 

The word ‘in out’ should appear with an arrow pointing somewhere on your page, it should also set the bottom left hand corner of your page as your X Y datum positions.

There is an option to input your Z axis depth here but it didn’t work for me and kept posting it as zero. This wasn’t difficult to change in the text editor though.

g-code generation in inkscape
Setting the Z axis depth did not transfer it to the G-Code for me…???

Create Your G-Code

Make sure you click your shape to select your path, then Extensions>gcodetools>path to gcode.

Another option box will appear.

Select the ‘preferences’ tab, name the file it will generate, choose the directory to save to, specify your Z axis clearance, e.g. 1.000” or 25mm. On the post processor option you can specify ‘round all values to 4 digits’.

In the ‘options’ tab select zero for ‘scale along Z axis’ and ‘offset along Z axis’. Set the minimum arc radius to 0.005” or 0.127mm.

Lastly choose the ‘path to gcode’ tab. I changed the ‘biarc interpolation tolerance’ to 0.010” .

Stay on the ‘path to gcode’ tab and click apply. 

Your G-Code should now have been saved to the selected destination folder.

producing g-code with inkscape
Make sure your path is selected

Edit Your G-Code

I have copied and pasted the first few lines of G-Code that Inkscape produced for my small bat shape below.

As you can see the header is very minimal and the first move is a rapid move down to Z axis zero*. SCARY!

%
(Header)
(Generated by gcodetools from Inkscape.)
(Using default header. To add your own header create file “header” in the output dir.)
M3
(Header end.)
G20 (All units in inches)

(Start cutting path id: path833)

(Change tool to Cone cutter)

G00 Z 0.0000 (* SCARY)
G00 X 0.2026 Y 0.5735
G01 Z 0.0000 F 10.0000(Penetrate)
G02 X 0.3470 Y 0.9348 Z 0.0000 I 0.4803 J 0.0175 F 40.0000

So what we need to do is add a proper header and footer.

Also note that the Z axis depth is at zero all through the program, this is not what I wanted but is very easy to change.

I am going to paste in the header and footer from my article ‘G-Code programming for Dummies’ overwriting the ones created by inkscape.

Here are the first few lines of the program with my header pasted in and a few minor modifications.

Read the notes in the brackets to see what I changed.

%
OBAT
G17 G20 G40 G49 G80 G90
T1 M06 
G00 G54 X 0.2026 Y 0.5735 S2000 M03 (added X & Y values from the 1st line of code)
G43 H1 Z1.
G00 Z 0.1 (changed to plus .1 in Z axis)
G01 Z -0.01 F10. (changed the Z axis depth to what I want)
G02 X 0.3470 Y 0.9348 Z -0.01 I 0.4803 J 0.0175 F 40.0000
ETC…..

To change the Z axis depths I used the replace command in wordpad to change them all at once. Easypeasy.

Set up your stock

Now you can upload the G-Code to your machine control software. Set up the stock on your machine, pick up the bottom left hand corner for your X and Y datum offsets and set the top as your Z axis datum zero.

You can read my posts on setting your datums and tool length compensation if you need more information on these topics.

For setting my datums I just used a pointed tool positioned over the corner of the stock.

Make sure you are saving the datum positions to the same offset position that you put in the header of your program. In my example I am using G54.

setting datums
Using a pointed tool to pick up the corner of the stock

Your machine control software should display the G-Code so you can check it has correctly interpreted the shape you created.

inkscape g-code displayed in mach3
mach3 screenshot of my Batcode

I did encounter one problem that showed up in mach3, when I loaded the program it would not run because there were ‘special characters’ showing up before or after some of the code.

These ‘special characters’ were not visible when you look at the program in wordpad. The fix was to either delete the spaces that were after the lines with the errors, or copy and paste the whole program into a new text document. I have no idea if this issue was due to something I did incorrectly..

Once you have setup your machine and you are confident that your datums are correct, press that green button!

shape milled from inkscape

The final result was very underwhelming but it proved the process worked and I had an understanding of how to produce G-Code using Inkscape. 

My thoughts on Inkscape G-Code

I have spent my working life as a machinist in an industrial environment, so my initial thoughts about this software were not very positive.

It is definitely not a great solution for generating G-Code for your hobby cnc machine.

It is not very intuitive and the G-Code it produced was very basic and completely limited in options.

But if you know the basics of writing your own G-Code it can be useful for generating lines and arc codes for a complex freeform or artistic contour.

This contour could then be used in a subroutine to cut out decorative shapes etc. 

There are a few more approaches I can try with this software before I ignore it for the rest of my life. One of those ideas is to machine a wooden gear wheel using the gear generator extension in inkscape. So till then……

P.s. If you want to download the G-Code for my bat shape click the button below.

Update….

After trying to use inkscape again to produce an involute gear wheel, my advice is not to bother using this G-code extension. It is buggy and unreliable and you have no control over how it produces the code. By all means try it, it may get you something usable to practise with but ultimately it is a waste of time.

I have now posted a tutorial of a much better software solution for creating G Code from Inkscape files. Hit the link below to read the article and improve your programming results.

If you are interested in learning how to create designs with Inkscape, don’t forget to check out Udemy’s dedicated course..

Share on pinterest
Share on email
Share on print

Table of Contents