Loading and modifying svg in Inkscape plugin
I am currently writing an Inkscape plugin using Python. Inside this plugin, I would like to load a template (an existing svg) from the plugin folder and access some of the objects in that template by name or key. Then I would like to change the border and / or fill color of the object and add text to it. How do I do this using the python scripting interface for Inkscape? I found some examples (see below) on how to write a plugin for inkscape, but they all work with documents that are already open.
- http://www.hoboes.com/Mimsy/hacks/write-inkscape-extension-create-multiple-duplicates/
- http://wiki.inkscape.org/wiki/index.php/Script_extensions
- http://ospublish.constantvzw.org/blog/tools/inkscape-plugins-in-python
- http://wiki.inkscape.org/wiki/index.php/Generating_objects_from_extensions
- http://wiki.inkscape.org/wiki/index.php/PythonEffectTutorial
+3
source to share
1 answer
Can you use lxml ?
t = etree.parse("path/test.xml")
Then you could
- manipulate properties directly
t
- this can be done from python without actually opening inkscape. Your tree can be saved witht.write("filename")
- add
t
to the currently open document usingself.document.getroot().append(t)
Also, this is not what you asked for, but might come in handy: an inkscape plugin that allows you to write short python snippets from Inkscape: http://www.smanohar.com/inkscape.php
0
source to share