summaryrefslogtreecommitdiff
path: root/lib/extensions/reorder.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2021-03-04 18:40:53 +0100
committerGitHub <noreply@github.com>2021-03-04 18:40:53 +0100
commite84a86d4ac0caf29d6074728376ff0a594243fec (patch)
tree888c79ed0094ba2916a1d329861a85515959913c /lib/extensions/reorder.py
parentb39575a50191307b3b56eab6455626398eec6397 (diff)
Update for Inkscape 1.0 (#880)
* update for inkscape 1.0 * add about extension * Build improvements for the inkscape1.0 branch (#985) * zip: export real svg not stitch plan * #411 and #726 * Tools for Font Creators (#1018) * ignore very small holes in fills * remove embroider (#1026) * auto_fill: ignore shrink_or_grow if result is empty (#589) * break apart: do not ignore small fills Co-authored-by: Hagen Fritsch <rumpeltux-github@irgendwo.org> Co-authored-by: Lex Neva <github.com@lexneva.name>
Diffstat (limited to 'lib/extensions/reorder.py')
-rw-r--r--lib/extensions/reorder.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/extensions/reorder.py b/lib/extensions/reorder.py
new file mode 100644
index 00000000..4db02760
--- /dev/null
+++ b/lib/extensions/reorder.py
@@ -0,0 +1,36 @@
+import inkex
+
+from .base import InkstitchExtension
+
+
+class Reorder(InkstitchExtension):
+ # Remove selected objects from the document and readd them in the order they
+ # were selected.
+
+ def get_selected_in_order(self):
+ selected = []
+
+ for i in self.options.ids:
+ path = '//*[@id="%s"]' % i
+ for node in self.document.xpath(path, namespaces=inkex.NSS):
+ selected.append(node)
+
+ return selected
+
+ def effect(self):
+ objects = self.get_selected_in_order()
+
+ for obj in objects[1:]:
+ obj.getparent().remove(obj)
+
+ insert_parent = objects[0].getparent()
+ insert_pos = insert_parent.index(objects[0])
+
+ insert_parent.remove(objects[0])
+
+ insert_parent[insert_pos:insert_pos] = objects
+
+
+if __name__ == '__main__':
+ e = Reorder()
+ e.affect()