Ad

EnglishFrenchSpanish

Free editor online | DOC > | XLS > | PPT >


OffiDocs favicon

Inkscape – G-Code Tools

 

Inkscape – G-Code Tools Linux Desktop app information

August 22, 2021, 5:38 pm

Inkscape - G Code Tools

DO MORE with Inkscape - G-Code Tools

Inkscape, the most used and loved tool of the Fedora design team, is not just a program for making good vector graphics. With vector graphics (in our case SVG) you can do much more. ...

 

 

 

... Many programs can import this format. Inkscape can also do much more than graphics. This series will show you some things you can do in addition to graphics with Inkscape. This first article in the series will show how Inkscape's G-Code Tools extension can be used to produce G-Code. G-Code, in turn, is useful for programming machines such as laser plotters and engravers.

What is G-Code and what is it used for?

The construction of machines for the hobby sector is booming. The publication of the source code of RepRap 3D printers for self-build and the availability of electronic components, such as Arduino or Raspberry Pi, are probably some of the causes of this boom. Mechanical engineering as a hobby is finding more and more adopters. This trend has not stopped with 3D printers. There are also CNC mills, plotters, laser engravers, cutters, and even machines that you can build yourself.

You don't have to design or build these machines yourself. You can buy these machines at a relatively low price as a kit or already assembled. All of these machines have one thing in common: they are computer controlled. Computer-aided manufacturing (CAM), which has become widespread in manufacturing, is now also carried out at home.

G-Code or G programming language

The most widely used language for programming CAM machines is G-Code. G-Code is also known as the G programming language. This language was developed at MIT in the 1950s. Since then, various organizations have developed versions of this programming language. Keep this in mind when working with it. Different countries have different standards for this language. The name comes from the fact that many instructions in this code begin with the letter G. This letter is used to convey travel or route commands to the machine.

The commands go, in the true sense of the word, from A (absolute or incremental position around the X axis; rotating around X) to Z (absolute or incremental in the direction of the Z axis). Commands with the prefix M (many) transmit other instructions to the machine. The coolant on / off is an example of an M command. If you want a more comprehensive list of G code commands, there is a table on Wikipedia.

%
G00 X0 Y0 F70
G01 Z-1 F50
G01 X0 Y20 F50
G02 X20 Y0 J-20
G01 X0 Y0
G00 Z0 F70
M30
%
This little example would mill a square. You can write this G-code in any editor of your choice. But when it comes to more complex things, you usually won't do this kind of low-level encoding by hand. When it comes to 3D printing, the cutter writes the G-code for you. But what about when you want to use a plotter or laser engraver?

Other software for writing G code

Then you will need a program to do this work for you. Sure, some CAD programs can write G-Code. But not all open source CAD programs can do this. Here are some other open source solutions for this:

dxf2gcode, normally a command line tool but has a GUI implemented in Python
dmap2gcode, you can import raster graphics and convert them
Millcrum, a browser-based tool
LinuxCNC, can import raster graphics and convert them to G code
TrueTypeTracer or F-Engrave if you want to engrave fonts
As you can see, there is no problem finding a tool to do this. What I don't like is the use of raster graphics. I use a CNC machine because it works more precisely than I could do by hand. Using raster graphics and plotting them to make a path for G-Code is no longer accurate. I find using vector graphics, which has paths anyway, is much more accurate.

When it comes to vector graphics, there's no getting around Inkscape; at least not if you use Linux. There are some other programs. But they are nowhere near the capacity that Inkscape has. Or they are designed for other purposes. So the question is: "Can Inkscape be used to create G-Code?" And the answer is yes! "Since version 0.91, Inkscape has been bundled with an extension called GCode Tools. This extension does exactly what we want: it converts paths to G code.

So all you have to do, if you haven't already, is install Inkscape:

$ sudo dnf install Inkscape
One thing to keep in mind up front (where the light is, so is the shadow): the GCode Tools extension has a lot of features that are not well documented. The developer thinks it is a good idea to use a forum for documentation. In addition, basic knowledge of G-Code and CAM is required to understand the functions.

Another point to note is that development is not as dynamic as it was at the time the GCode tools were packaged with Inkscape.

Introduction to the Inkscape G-Code Tools extension

The first step is the same as when you would do anything else in Inkscape: adjust the properties of your document. So open the document settings with Shift + Ctrl + D or by clicking the icon on the command bar and set the document properties to the size of your workpiece.

Next, set the orientation points by going to Extensions> Gcodetools> Orientation Points. You can use the default settings. The default settings will probably give you something similar to what is shown below.

Inkscape with document settings and orientation points

The next step is to edit the tool library (Extensions> Gcodetools> Tool Library). This will open the dialog window for the configuration of the tool. There you choose the tool you will use. The default tool is fine. Once you've chosen the tool and hit Apply, a rectangle will appear on the canvas with the tool's settings. These settings can be edited with the Text Tool (T). But this is a bit tricky.

Inkscape with default tool library settings added to document

The G-Code Tools extension will use these settings later. These tool settings are grouped with an identifiable name. If you ungroup these settings, this name will be lost.

There are two possibilities to avoid losing the handle if you ungroup the tool settings. You can use 4-click ungrouping with the selection tool activated. Or you can ungroup it using Shift + Ctrl + G and then give the group a name later using the XML editor.

In the first case, you need to watch that the group is restored before drawing something new. Otherwise, the newly drawn object will be added to this group.

Now you can draw the routes that you want to later convert to G-Code. Objects such as rectangles, circles, stars, and polygons, as well as text, must be converted to paths (Path> Object to Path or Shift + Ctrl + C).

Hershey fonts or stroke fonts

Regarding fonts, note that TTF and OTF are called outline fonts. This means that the outline of the individual character is defined and will be engraved or cut as such. If you don't want this and want to use for example a script font then you should use Stroke Fonts instead. Inkscape itself comes with a small collection of them by default (see Extensions> Text> Hershey's Text).

The Inkscape Hershey Text Extension Stroke Fonts
The Hershey Text Extension Stroke Fonts
Here's another article on how to create your own stroke fonts. They are not only useful for engraving, but also for embroidery.

Area fill functions

In some cases, it may be necessary to fill the paths with a pattern. The G-Code Tools extension has a feature that offers two ways to fill objects with patterns: zig zag and spiral. There is another feature that is currently not working (Inkscape changed some parts of the extensions with the release of version 1.0). The last function would populate the object with the help of compensation functions in Inkscape. These functions are found in Extensions> Gcodetools> Area.


The Fill Area function of the G-Code Tools extension.

On the left the pattern fill and on the right (currently not working) the offset fill. The extension will run the active tab!
The area fills of the GCode tool, at the top of the Zigzag and at the bottom of the Spiral. Note that the results will look different if you use this letter-by-letter function instead of the full path.
The G-code tool area fills, at the top Zig zag and at the bottom Spiral. Note that the results will look different if you apply this feature letter by letter rather than the entire path.

With more and different area fills, you will often have to draw the paths by hand (about 90% of the time). The EggBot extension has a function to fill regions with patterns. You can also use the classic hatch patterns. But you will have to convert the fill pattern back to an object. Otherwise, the G-Code Tools extension cannot convert it. Besides these, Evilmadscientist has a nice wiki page that describes the fill methods.

Converting routes to G code

To convert the drawn paths to G-Code, use the Extensions> Gcodetools> Paths to G-Code function. This function will be executed on the selected objects. If no object is selected, all paths in the document will be converted.

There is currently no functionality to save G-code using the file menu. This must be done from the G-Code Tools extension dialog when converting the paths to G-Code. In the Preferences tab, you need to specify the path and name of the output file.

Different colored lines and arrows will be rendered on the canvas. The blue and green lines show curves (G02 and G03). Red lines show straight lines (G01). When you see this style then you know you are working with G-Code.


Conclusion

Opinions differ as to whether Inkscape is the right tool for creating G-Code. If you keep in mind that Inkscape only works in two dimensions and you don't expect too much, you can create G-Code with it. For simple jobs like tracing some letters or logos, it is definitely enough. The main disadvantage of the G-Code Tools extension is that it lacks documentation. This makes it difficult to get started with G-Code Tools. Another downside is that there is currently not much active development of G-Code Tools. There are other extensions for Inkscape that also target G-Code. But they are already history or they are not actively developing either. The Makerbot Unicorn GCode Output extension and the GCode Plot extension are some examples of the latter case. There is definitely a need for an easy way to export G-Code directly.

 


Run Chrome Extensions

Ad