blob: 834dcd0ca52a9726bd90e83c008623ea5167ec54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
|