How to get started on writing extensions

Discussion about writing code for Inkscape.
lazygeorge
Posts: 8
Joined: Wed Mar 02, 2011 8:00 am

How to get started on writing extensions

Postby lazygeorge » Sat Apr 09, 2011 2:04 am

Perhaps this part of the forum could begin by asking,

What would you advise a novice programmer for how to go about learning to script Inkscape extensions?

I am not really a programmer myself and struggled to find simple, clear documentation that would help me to write my own scripts. The documentation is there, but their is an expectation of a certain level of programming competency to read it.
I have now written a few extensions and thought I might describe some of the methods I used. If you are a novice programmer like myself, some of this might be useful.

Use a good text editor - I used Notepad++ as it highlights syntax for both SVG, INX(XML) and python, the scripting languages you will be using

Get used to SVG script - open inkscape SVG files in Notepad and try to understand the script, see if you can identify where the different objects are in the script. If you can read XML or HTML you should get it quick enough.

The most useful documention I found was in the inkscape wiki. http://wiki.inkscape.org/wiki/index.php/Script_extensions as well as other pages, is a good starting place.
Jerry Stratton wrote a good intro tutorial as well http://www.hoboes.com/Mimsy/hacks/write-inkscape-extension-create-multiple-duplicates/

Be aware that newer Inkscape versions have changed the python code library it uses for editing SVG files - some older scripts didn't seem to work for me. Inkscape uses the lxml library. I found http://lxml.de/tutorial.html a very good reference for this.

The best way I found to get to understanding extensions is to copy and rename extensions in Inkscape's extension folder and open them in an editor or notepad and edit them.

These are just a few points for getting started. No doubt there are many people with far more experience than me who could add much more to this.

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: How to get started on writing extensions

Postby RobA » Sat Apr 09, 2011 2:34 am

I'd suggest:

1) learn Python.
2) learn about XML & DOM manipulation
3) Look at existing extensions and start by modifying ones that are close to what you want.

-Rob A>

sgmanohar
Posts: 3
Joined: Thu Aug 21, 2014 2:41 pm

Re: How to get started on writing extensions

Postby sgmanohar » Wed Dec 24, 2014 6:23 am

This extension allows you to run a couple of custom lines of python code from within Inkscape - on the fly without having to use an editor and write a complete script.

Useful for doing one-liners while editing your drawing.

http://www.smanohar.com/inkscape.php


Return to “Programming”