# Using inkscape to generate g-code

**URL:** <https://forum.universal-robots.com/t/using-inkscape-to-generate-g-code/11727>\
**Category:** URCap Development\
**Created:** [January 22, 2021, 9:10am UTC](https://forum.universal-robots.com/t/using-inkscape-to-generate-g-code/11727 "2021-01-22T09:10:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon31171908](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@anon31171908](https://forum.universal-robots.com/u/anon31171908)\
**Post date:** [January 22, 2021, 9:10am UTC](https://forum.universal-robots.com/t/using-inkscape-to-generate-g-code/11727/1 "2021-01-22T09:10:52Z")

</div>

Hello!  
I’m trying to use inkscape with the gcodetools-extenstion to generate G-code for an UR5e, running the “Remote TCP & Toolpath” URCap.  
I want it to draw a drawing from an image.

Has anybody succeeded using gcodetools for this purpose? In polyscope I just get the error about Empty Toolpath in line 0.  
I have tried with Inkscape, pyCam and [jscut.org](http://jscut.org), but all of them make Polyscope throw the same error.

---

<div class="post-metadata">

**Author:** ![anon43187723](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@anon43187723](https://forum.universal-robots.com/u/anon43187723)\
**Post date:** [February 22, 2021, 7:30am UTC](https://forum.universal-robots.com/t/using-inkscape-to-generate-g-code/11727/2 "2021-02-22T07:30:41Z")

</div>

Dear Nicholas,

I am working on a project for my internship wich is also combined with a UR5e and they also want me to look for a program that uses G-codes to run the tool. Did you already find something which works? Or is there no chance its going to work?

I would love to hear something back!

Kind regards,

---

<div class="post-metadata">

**Author:** ![anon31171908](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@anon31171908](https://forum.universal-robots.com/u/anon31171908)\
**Post date:** [February 22, 2021, 9:20am UTC](https://forum.universal-robots.com/t/using-inkscape-to-generate-g-code/11727/3 "2021-02-22T09:20:32Z")

</div>

What I found out after looking at an example code is that the G-code file needs to have .nc extension, and it needs the % sign in top and bottom of the file.  
Also, the G-codes need N-codes in front (which is like line numbering) with an incrementation of five.

I made this python-script to make valid G-codes:

```
path = input('Path: ')
file = open(path, 'r')
Lines = file.readlines()
file.close()
n = 10

with open('mod_' + path, 'w') as file:
    for nbr, line in enumerate(Lines):
        if line[0] == 'G':
            line = 'N' + str(n) + ' '+ line
            n+=5
        if line[0] != "%":
            if nbr == 0:
                line = "%\n" + line
            elif nbr == len(Lines)-1:
                line = line + "%"
        file.write(line)
```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/system/32/1_2.png) [@system](https://forum.universal-robots.com/u/system)\
**Post date:** [February 25, 2021, 3:45pm UTC](https://forum.universal-robots.com/t/using-inkscape-to-generate-g-code/11727/4 "2021-02-25T15:45:54Z")

</div>

Closed on February 25, 2021, 3:45pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
