Getting Started¶
Types of extensions¶
- There are four types of extensions:
- Effect: Takes the SVG from Inkscape, modifies the selection or the document and returns an SVG to Inkscape.
- Generate: Does not need any SVG, but instead just outputs an SVG fragment which is inserted into Inkscape, centered on the selection.
- Input: Takes any type of file as input and outputs SVG which Inkscape can read.
- Output: Takes the SVG from Inkscape and outputs it to something that’s not an SVG.
Extension Architecture¶
Every extension needs two files: <name>.inx
and <name>.py
. The names
should match up.
Note
(Note: Using Python for the extensions is only a recommendation, but the documentation will focus exclusively on that method.)
Inx file¶
The inx file is a specialized xml
file. Its purpose is to tell Inkscape
various information about your extension. It follows the following format:
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<!-- 1. Replace this with the title of your extension. This will Show in the extensions menu-->
<_name>Your Cool Title</_name>
<!-- 2. Fill this in. It ensures that your extension has a unique ID -->
<id>yourname.yourorganization.title</id>
<!-- 3. Show the relative path to your extension. For example, `~/.config/inkscape/extensions/template.py` would be `template.py`-->
<dependency type="executable" location="extensions">path/to/yourextension.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<effect>
<object-type>all</object-type>
<effects-menu>
<!-- 4. Where is your extension located? (You can nest menus) -->
<submenu _name="submenu"/>
</effects-menu>
</effect>
<script>
<!-- 5. Same as #4 -->
<command reldir="extensions" interpreter="python">path/to/yourextension.py</command>
</script>
</inkscape-extension>