Loading
Hey! This thing is still a Work in Progress. Files, instructions, and other stuff might change!

Unicorn G-Code Extension for Inkscape

by schmarty, published

Unicorn G-Code Extension for Inkscape by schmarty Feb 1, 2011

Description

One problem that has often plagued users of the MakerBot Unicorn[1] is the long and confusing chain of tools required to go from a nice vector drawing to a G-Code file that can be plotted from ReplicatorG.

mifga did an awesome tutorial[2] that made it possible to understand the steps needed to work all of these tools, but it was obvious that something better was needed.

So, I made a mashup of scribbles.py[3] and the Egg-Bot Driver for Inkscape[4] to bring you the inkscape-unicorn extension for Inkscape!

Once installed, this extension allows you to save files in "MakerBot Unicorn G-Code (*.gcode)" format!

Learn more, download, and contribute at the GitHub page for this project:

github.com/martymcguire/inkscape-unicorn

If you're desperate, you can also download the zip file attached to this thing, but it is guaranteed to be out of date. Please get the latest version from GitHub. :)

Thanks to langfordw for the original Unicorn Logo[5] used as an example on this Thing.

UPDATES!

I'm updating and adding features to this script as my first days for the February Thing-A-Day. Updates below:

* Day 1, Release: thing-a-day.com/thing-a-day-2011-1-unicorn-pen-plotter-extens
* Day 2, Registration and Homing: thing-a-day.com/new-features-for-inkscape-unicorn-pen-registr
* Day 3, Copies and Continuous Plotting: thing-a-day.com/thing-a-day-2011-3-copies-and-continuous-plot


[1] Unicorn - store.makerbot.com/makerbot-unicorn-pen-plotter-kit.html
[2] mifga's Unicorn Tutorial - wiki.makerbot.com/unicorn-tutorial-01
[3] scribbles.py - github.com/makerbot/Makerbot/tree/master/Unicorn/Scribbles%20Scripts
[4] Egg-Bot Driver for Inkscape - code.google.com/p/eggbotcode/
[5] Unicorn Logo by langfordw thingiverse.com/thing:4197

Recent Comments

view all
hello, you have solved the problem???
I haven't used this in a bit, but I have seen similar errors in the past.

The plugin is pretty sensitive to weird paths. Open up the XML editor in Inkscape (Ctrl-Shift-x) and check your SVG's XML to look for empty paths. These show up as <svg:path> elements with a missing or empty "d" attribute. If you find any, delete them.

This plugin was written for the Cupcake's cartesian coordinates and platform size. This probably won't map super well onto a sphere, which work on rotational coordinates and has different extents for each motor.

If you're driving it with an EiBotBoard, you would probably have better luck using the EggBot driver/plugin for Inkscape, instead. :)
Anyone use this lately? I keep getting this error trying to save an svg to use on my new spherebot / eggbot:

Traceback (most recent call last):

File "http://unicorn.py", line 108, in <module>

e.affect()

File "/Applications/Inkscape.app/Contents/Resources/extensions/http://inkex.py", line 215, in affect

self.effect()

File "http://unicorn.py", line 104, in effect

entity.get_gcode(self.context)

File "/Applications/Inkscape.app/Contents/Resources/extensions/unicorn/http://entities.py", line 77, in get_gcode

for points in self.segments:

AttributeError: SvgPath instance has no attribute 'segments'</module>

More from Art Tools

view more

Liked By

view all

License

GNU - GPL
Unicorn G-Code Extension for Inkscape by schmarty is licensed under the GNU - GPL license.

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag. Print Thing Tag

Instructions

From the README:

Install

Copy the contents of src/ to your Inkscape extensions/ folder.

Typical locations include:

* OS X - /Applications/Inkscape.app/Contents/Resources/extensions
* Linux - /usr/share/inkscape/extensions
* Windows - C:Program FilesInkscapeshareextensions

Usage

* Size and locate your image appropriately:
** The CupCake CNC build platform size is 100mm x 100mm.
** Setting units to mm in Inkscape makes it easy to size your drawing.
** The extension will automatically attempt to center everything.

* Convert all text to paths:
** Select all text objects.
** Choose Path | Object to Path.

* Save as G-Code:
** File | Save a Copy.
** Select MakerBot Unicorn G-Code (*.gcode).
** Save your file.

* Preview
** For OS X, Pleasant3D is great for this.
** For other operating systems... I don't know!

* Print!
** Open your .gcode file in ReplicatorG
** Set up your Unicorn and pen.
** Center your build platform.
** Click the Build button!
Anyone use this lately? I keep getting this error trying to save an svg to use on my new spherebot / eggbot:

Traceback (most recent call last):

File "http://unicorn.py", line 108, in <module>

e.affect()

File "/Applications/Inkscape.app/Contents/Resources/extensions/http://inkex.py", line 215, in affect

self.effect()

File "http://unicorn.py", line 104, in effect

entity.get_gcode(self.context)

File "/Applications/Inkscape.app/Contents/Resources/extensions/unicorn/http://entities.py", line 77, in get_gcode

for points in self.segments:

AttributeError: SvgPath instance has no attribute 'segments'</module>
hello, you have solved the problem???
I haven't used this in a bit, but I have seen similar errors in the past.

The plugin is pretty sensitive to weird paths. Open up the XML editor in Inkscape (Ctrl-Shift-x) and check your SVG's XML to look for empty paths. These show up as <svg:path> elements with a missing or empty "d" attribute. If you find any, delete them.

This plugin was written for the Cupcake's cartesian coordinates and platform size. This probably won't map super well onto a sphere, which work on rotational coordinates and has different extents for each motor.

If you're driving it with an EiBotBoard, you would probably have better luck using the EggBot driver/plugin for Inkscape, instead. :)
Cool! Thanks! replaced M300 commands with G1 Z0 commands to run on my Prusa Mendel
Sorry if this is a stupid question, what firmware are you using? Does it only work with makerware?
This was written for the Cupcake CNC + Replicator G. It generates G-Code, so it should work with any bot that can speak G-Code, provided that you update the pen-up/pen-down commands to ones that your machine understands.
Thanks for making this. I very slightly modified the code to do z moves for the pen up/down and it worked out great.
TheCuber - in reply to
Hey i know this was along time ago, but how were you able to use the Z axis to control pen up and down? I kinda want to try this out. Any help would greatly be appreciated.
Hey! Glad you want to check it out!

Take a look at my comment about context.py from a few weeks ago. It should get you pointed in the right direction.
Really impressed, thanks for making the G-Code extension. I'm making a Spherebot and this really makes it work! Keep up the great work!
I can't activate unicorn, what's my faught?
Can you add a travel speed option? I've been using this script with my laser unicorn - etch speeds are around 200 - 400 mm/min... I'd love to have it move much faster when not etching.
That's a good idea. I'll add it to the issues list on GitHub for when I next get around to working on it.

If you'd like to make the change yourself, it should be pretty straightforward to hack it into the Python scripts.
Where is the ''Love it'' button? This thing is so awesome. I hated dealing with the python scribbles script. Great job. I have it installed and in use. You should really consider posting a page on the reprap wiki and Makerbot wiki because it is really a huge leap forward on user friendliness. I am very surprised this thing hasn't gotten more attenion. Anyways the thing is awesome! :)
Thanks! mifga and I are planning to write up some new tutorials when we get a chance. I am really excited to see what people come up with using this!
What needs to change so I can use a stock cupcake as a drawbot and this script? The Z just needs to hop up 2mm.
did you found out how to change this? im a total mess in writing code, (but i can make computer drawings)
The Python script in unicorn/http://context.py is the thing to edit. There are several lines that read something like:

self.codes.append("M300 S%0.2F (pen up)" % self.pen_up_angle)

And for pen down:

self.codes.append("M300 S%0.2F (pen down)" % self.pen_down_angle)

The "M300" is an M-Code telling the machine to lift the servo for the Unicorn (more info here: replicat.org/mcodes )

You should be able to replace all of those lines with some reasonable Z moves. For example, if you always start your drawings with the pen 20mm above your drawing surface, you could change all pen up commands to:

self.codes.append("G0 Z20 (pen up)")

And pen down would be:

self.codes.append("G0 Z0 (pen down)")

It's a lot of string replacement (bad code design, my bad!) but it is pretty straightforward.

As I said earlier, you have to be careful not to smush things. The Unicorn toolhead has a lot of "give", allowing the pen to slide up and down. The Z-axis has no such "give" and will happily crush a pen tip.
A good question! You'd need to change the code of the extension itself to turn all pen-up and pen-down commands into Z-axis moves. Shouldn't be too challenging.

Try not to smash/smush anything, though. :)
I couldn't agree more : Today I grabbed four Inkscape svg files that were the source for existing Unicorn plottables at Thingiverse and ran them to gcode with practically no issues. Even the stepping on curves wasn't as noticeable as when you run a big circle. And now that Matt Mets has fixed the G3 issue in ReplicatorG, there is a lot of room to tune this tool up to take over ye olde long process of generating Unicorn gcode. Also, I ran an XKCD webcomic for fun, and within 30 seconds had a unicorn printing, well, what appears to me to be a Klingon language variant. Text still needs some work. (not with the script, with the tools to trace usefully into Inkscape for paths for printing!) Marty -- go for the Hershey font trickery we discussed!
SO SO SO awesome!!!
Top