From 782afcf3f6608e2a6dcc0a8acfc0cf671ff400f6 Mon Sep 17 00:00:00 2001 From: leyghisbb Date: Fri, 7 May 2021 16:54:21 +0200 Subject: [PATCH] added support for group/child handling for reverse order of subpaths --- .../fablabchemnitz/reverse_order_subpaths.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/extensions/fablabchemnitz/reverse_order_subpaths.py b/extensions/fablabchemnitz/reverse_order_subpaths.py index 5740efd6..33b9f9f9 100644 --- a/extensions/fablabchemnitz/reverse_order_subpaths.py +++ b/extensions/fablabchemnitz/reverse_order_subpaths.py @@ -21,22 +21,25 @@ from inkex import PathElement, CubicSuperPath class ReverseOrderSubpaths(inkex.EffectExtension): + def reverse(self, element): + if element.tag == inkex.addNS('path','svg'): + new = [] + sub = element.path.to_superpath() + i = 0 + while i < len(sub): + new.append(sub[-1-i]) + i += 1 + element.path = CubicSuperPath(new).to_path(curves_only=True) + elif element.tag == inkex.addNS('g','svg'): + for child in element.getchildren(): + self.reverse(child) + def effect(self): """Reverse order of subpaths (combined paths) without reversing node-order or order of paths""" if not self.svg.selected: raise inkex.AbortExtension("Please select an object.") - for id, elem in self.svg.selection.id_dict().items(): - - new=[] - sub=elem.path.to_superpath() - - i=0 - while i