Writing Inkscape extensions for the Eggbot

127 views
Skip to first unread message

Dan Newman

unread,
Oct 20, 2010, 7:28:45 PM10/20/10
to eggbo...@googlegroups.com
For those interested in writing their own Inkscape extensions for use with
the Eggbot, there's a lot which can be learned by looking at the Eggbot
extensions for Inkscape. Their file names begin with eggbot_ and they can
be found in Inkscape's extension directory:

Windows: C:\Program Files\Inkscape\extensions
Macs: /Applications/Inkscape.app/Contents/Resources/extensions/
Linux: somewhere, I'm sure

To help others write extensions, I wanted to distill down to mostly bare
bones an extension which acts upon an existing drawing (selection),
manipulates the path data in the drawing (selection), and then puts the
revision back into the drawing (selection). What I came up with is attached
below. It includes complete code to do most of the tedious heavy lifting
(e.g., traversing the SVG paths and reducing the path data down to lists
of absolute (x,y) coordinates). I'll eventually put a Wiki page up along
with a zip file at the code site if this proves sufficiently useful to
others.

The attached extension is in two files: twist.py and twist.inx. You can
put them in your private extensions directory,

Windows: ?
Macs: ~/.config/inkscape/extensions/
Linux: ~/.config/inkscape/extensions/

and then restart Inkscape to see the extension. While it is *not* an Eggbot
extension, it will (owing to the contents of twist.inx) appear under "EggBot"
in the list of extensions. Namely Extensions > EggBot > Twist. The .py file
is the Python code for the extension, while the .inx file is the
extension description which Inkscape uses to know what input the extension
needs and how to run it.

Cheers,
Dan

twist.py
twist.inx
twist.png

Cary Swoveland

unread,
Oct 22, 2010, 12:35:15 AM10/22/10
to EggBotUser
Many thanks for your work on this, Dan. I'm just reading through your
extension. I don't know Python, but it's close enough to Ruby, which
I do know, that I can follow it pretty well. A bigger obstacle is
that the SVG standard is completely new to me. I'm reading through
http://www.w3.org/TR/SVG/index.html, and also the tutorials by example
at the same site, but the standard covers a lot of ground.

Cary



Dan Newman

unread,
Oct 22, 2010, 12:44:44 AM10/22/10
to eggbo...@googlegroups.com

You may also find the lxml.etree tutorials & docs of some help when you
start trying to do manipulations of a parsed SVG document. lxml is the
parser with Inkscape's Python extension framework uses.

BTW, the twist.inx wasn't a good example of useful text for an extension
GUI. I had as the intro text a random snippet from a hatch fill extension
I had written. I forgot to make the text relevant to the "twist"
extension. Oh well.

If you have any questions, don't hesitate to ask.

Dan

Dan Newman

unread,
Oct 22, 2010, 1:54:33 AM10/22/10
to eggbo...@googlegroups.com
My apologies: when I sent this message yesterday, I somehow managed to
attach an older, ever so slightly different (and wrong) version of twist.py.
The correct version is attached.

Dan

P.S. FWIW, the issue was that Apple Mail's "attach" won't let me navigate
down a hidden directory (.config/inkscape/extensions/) and so I had to move
the file somewhere else where I could attach it from. However, I somehow
picked up an older, non-working version. Sigh.

twist.inx
twist.py
Reply all
Reply to author
Forward
0 new messages