Skip to content

Instantly share code, notes, and snippets.

@zdavkeos
Created November 21, 2013 04:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdavkeos/7576048 to your computer and use it in GitHub Desktop.
Save zdavkeos/7576048 to your computer and use it in GitHub Desktop.
Simple DOT importer extension for Inkscape. Import DOT files directly into Inkscape for editing and exporting as SVG. Relies on the `dot` program for conversion.
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>DOT Input</_name>
<id>org.inkscape.input.dot</id>
<dependency type="executable" location="extensions">dot.py</dependency>
<input>
<extension>.dot</extension>
<mimetype>text/plain</mimetype>
<_filetypename>DOT (*.dot)</_filetypename>
<_filetypetooltip>DOT</_filetypetooltip>
</input>
<script>
<command reldir="extensions" interpreter="python">dot.py</command>
</script>
</inkscape-extension>
#!/usr/bin/env python
'''
Copyright (C) 2013 Zach Davis, zdavkeos -at- gmail.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
import sys
from run_command import run
fname = sys.argv[1:][-1].replace("%","%%")
cmd = 'dot -Tsvg -o"%s" "' + fname + '"'
run(cmd, 'dot')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment