summaryrefslogtreecommitdiff
path: root/inkscape.py
diff options
context:
space:
mode:
Diffstat (limited to 'inkscape.py')
-rw-r--r--inkscape.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/inkscape.py b/inkscape.py
new file mode 100644
index 0000000..834dcd0
--- /dev/null
+++ b/inkscape.py
@@ -0,0 +1,35 @@
+import xml.etree.ElementTree as et
+import subprocess
+
+
+def distribute(ids, mode):
+ print(ids)
+ with open("/home/mike/neuron.d/static/currently_editing", "r") as f:
+ currently_editing = f.readline()
+
+ print(currently_editing)
+
+ selected = ""
+ for id in ids:
+ selected = selected + "select-by-id:" + id + ";"
+
+ subprocess.run([
+ 'inkscape', '--actions',
+ f'{selected}object-distribute:{mode};export-filename:{currently_editing};export-overwrite;export-do;',
+ currently_editing
+ ])
+ # inkscape --actions="select-by-id:rect878;select-by-id:rect1814;select-by-id:rect1812;object-distribute:hgap;export-filename:/home/mike/neuron.d/static/index/another-one.svg;export-overwrite;export-do;" /home/mike/neuron.d/static/index/another-one.svg
+
+
+def ids_from_xml(xml_string):
+ ids = []
+ root = et.fromstring(xml_string)
+ for child in root:
+ # TODO: match for actual tag somehow
+ if child.tag[-2:] == "}g":
+ copied_objects = child
+ break
+ print(copied_objects.get("id"))
+ for obj in copied_objects:
+ ids.append(obj.get("id"))
+ return ids