Using Inkscape to Generate Gcode

Inkscape is a free vector drawing program similar to Adobe Ilustrator. We can use it to draw lines and shapes that can be turned into gcode. It is important to understand the diffence between vector art and raster art.

Raster artwork is any digital art composed of horizontal and vertical rows of pixels. … Vector artwork is digital art composed of mathematical lines and curves. As a result, vector images can be reduced or enlarged in size indefinitely, without any loss in image quality.

Vector, think math…Raster, think pixels.

When you need to draw or paint a free-style line or shape, we can draw it in Inkscape and turn it into gcode to be run on our painting machine. 

This page takes you through the entire process of creating a free-style curve and drawing it on our painting machine. Here are the steps in brief:

  • Set up Inkscape for our Machine,
  • Draw a freestyle bezeir curve in Inkscape,
  • Set up the Extensions > Gcodetools,
  • Generate and Save the gcode,
  • Prepare the machine and Run the Job

Step 1: Set up Inkscape for our Machine

This assumes you have some understanding of how to draw in Inkscape. If not, here are a series of videos by TJ Free. Before we start we need to setup a custom document that represents the size and orientation of your canvas. 

Document Setup

Open Inkscape:

  1. Go to File > Document Properties
  2. Select the Landscape radio button.
  3. In Units choose mm
  4. In Custom size use:
    1. Width: 1480
    2. Height: 870
  5. Make the Background color: white, ffffffff
  6. Make the Border color: red, ff0000ff
  7. Close Document Properties dialogue box.

Note: the last two FFs set the transparancy to none or opague.

Note: there is not save, it automatically saves when you close the box.

In Zoom mode, click Zoom to fit page in window (5).

Your Inkscape window should look something like the image below.

Important Machine Measurements:
(all in millimeters)

  • Actual size of the bed: 1664 x 1248
  • Drawing limit size: 1480 x 870
  • Offset to Canvas: X-74, Y148
    (from DOT-corner to closest canvas corner)

Step 2: Draw a Freestyle Bezier Curve in Inkscape

Drawing Bezier curves is an issential skill you will need to operate this machine. Even if you take a raster image and turn it into a vector file, you will still need to clean it up using Bezier curves. Here is a TJ Free video on Bezier Tools and Nodes

In Inkscape:

  1. Select the Bezier tool.
  2. Draw a simple curve with just two nodes about 100mm apart.
  3. Give it a small arc.
  4. Give it a stroke weight of 2mm.
  5. With the color black.

The Bezier tool is in the left column and it looks like this:

Step 3: Set Up the Extensions > Gcodetools,

The function that let’s us generate gcode from a path in Inkscape is a third-party extension. This tutorial assumes the Gcodetools extensions are already installed in Inkscape. If not, view this video How to install Extensions for Inkscape and download the extensions here at Github.

Gcodetools extensions work very well, but are not very intuitive and are difficult to setup. But once setup properly they are easy to use. Follow these instructions carefully.

Choose a Tool

Select Extensions > Gcodetools > Tool library and choose the cone tool type and click Apply.

A light green box will appear below your drawing. Find it and zoom in in it. You have the ability to change the settings for this tool. 

  • Change Feed to: 20000
  • Change Penetration feed to: 10000

Zoom back to the red canvas view.

Set Orientation Points

Select Extensions > Gcodetools > Orientation points. A dialogue box will appear. 

  1. Under Orientation type: choose the first radio button entitled, which is:
    point mode (move and rotate, maintained aspect ratio X/Y)
  2. Z surface: 0
  3. Z depth: 0
  4. Units (mm or in): mm
When you click the Apply button another object will appear on the document. This object needs to be Adjusts to match your Work 00 and be resized to match your scale.

0,0,0 is automatically placed in the bottom left of your canvas. For now, keep it there. To the right of 0,0,0 is 100,0,0. But this does not correspond to the our canvas’ 100mm…it’s more like 357mm. So we need to adjust it down to match the 100mm point on our canvas.

So let’s draw a square box from the bottom left corner 100mm square. Make sure it’s snapped to canvas corner. Now move the left side of the Orientation Points object to touch the 100mm square.

Now when you draw something it should draw the right size. Note to Self: this needs to be checked.

Ratio Note: 356.923 (357) to 100

Path to Gcode

Select Extensions > Gcodetools > Path to Gcode. A dialogue box will appear. Note=ice that this one has tabs. We will start with the Preferences tab.

Under the Preferences tab:

  1. File: enter the file name for your gcode with the extension .gcode
  2. Add numeric suffixto filename: place a checkmark.
  3. Directory: enter the path to the directory where you will store your gcode files.
    Example: C:\InkscapeGcodeFiles 
  4. Z safe height for G00 move over blank: 30mm
  5. Units (mm or in): mm
  6. Post-processor: ???

Under the Options Tab: basically leave as is.

  • Scale along Z axis: 1
  • Offset along Z axis: 0

Under the Path to Gcode tab:

  • Biarc interpolation tolerance: 
  • Maximum splitting depth: 5
  • Cutting order: Subpath by subpath
  • Depth function: -1 (avoids mulitiple layers)
    (Can not be zero)

Note to Self: In footer it goes back to 00, but not to Zo

With an path sellected, clicking the Apply button should start generating gcode.

Look in your your gcode folder. 

To check it, open with Notepad++.

If it looks good, you can upload it to OctoPrint.

Note: since our matterial is paper or canvas, we can assume zero depth. Remember gcode is designed for CNC machines that route out hard matterials like wood and metal.

Note to Self: once the we go through this process once successfully, most of the settings will remain. I needs to identify what is likely to change and talk about this.

This is text from dialogue box:
Orientation points are used to calculate transformation (offset, scale, mirror, rotation in XY plane) o the path. 

If there are no orientation points inside current layer they are taken from the upper layer.

Do not ungroup orientation points! You can select them using double click to enter the group or Ctrl+Click.

Independent set for each layer.

They are automatically put 000 in the bottom left corner of canvas.

 

Step 4: Prepare Machine and Run the Job

The gcode file is not yet in the OctoPrint file structure. We need to upload it into OctoPrint.

Here is our operational workflow:

  • Start the machine
  • Login to OctoPrint
  • Connect to the machine
  • Raise Z up to 30mm
  • Jog XY into hardstops
  • Remove marker cap
  • Jog down until the tooltip touches the bed
  • Jog down another 2mm to insure full contact
  • Make this location Work 000.

You can alway check that you are at Work 000 by clicking Check Coordinates. Physcally the tooltip is touch the canvas and against the DOT-corner hardstops.

Now we are ready for an Inkscape job.

Back in OctoPrint:

  • Create a folder for this painting with an appropriate name. We used PAINTING 1.
  • Upload the job to this folder.
CAUTION: At this point the Painting machine MUST be against the DOT-corner hardstops and at work zero 000.

In the left corner of OctoPrint:

  • Select the Sandify job by name
  • Click Print

Hopefully all will work out successfully and the job will end back at work zero.

Note:  Even a simple painting may have many files.

Note to Self: Do we really want to come all the way back to work zero every time?