From 3ed7e2ae3a98e61986738726b692d9b1b07e419e Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Tue, 19 Oct 2021 14:07:12 +0200 Subject: [PATCH] small enhancements --- .../fablabchemnitz/join_paths/join_paths.inx | 1 + .../fablabchemnitz/join_paths/join_paths.py | 23 +++++++++++-------- extensions/fablabchemnitz/mirror/meta.json | 2 +- .../fablabchemnitz/move_path_node/meta.json | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/extensions/fablabchemnitz/join_paths/join_paths.inx b/extensions/fablabchemnitz/join_paths/join_paths.inx index 0e263103..a8d05bd9 100644 --- a/extensions/fablabchemnitz/join_paths/join_paths.inx +++ b/extensions/fablabchemnitz/join_paths/join_paths.inx @@ -8,6 +8,7 @@ true + true 0.0100 diff --git a/extensions/fablabchemnitz/join_paths/join_paths.py b/extensions/fablabchemnitz/join_paths/join_paths.py index 087fd7c9..b66d2386 100644 --- a/extensions/fablabchemnitz/join_paths/join_paths.py +++ b/extensions/fablabchemnitz/join_paths/join_paths.py @@ -126,6 +126,7 @@ class JoinPaths(inkex.EffectExtension): def add_arguments(self, pars): pars.add_argument("--optimized", type=inkex.Boolean, default=True) + pars.add_argument("--reverse", type=inkex.Boolean, default=False) pars.add_argument("--margin", type=float, default=0.0100) pars.add_argument("--add_dimples", type=inkex.Boolean, default=False) pars.add_argument("--draw_dimple_centers", type=inkex.Boolean, default=False) @@ -146,23 +147,24 @@ class JoinPaths(inkex.EffectExtension): pars.add_argument("--tab", default="sampling", help="Tab") def effect(self): - selections = self.svg.selected - if len(self.svg.selected) == 0: - self.msg('Please select some paths first.') - return + pathNodes = self.document.xpath('//svg:path',namespaces=inkex.NSS) - paths = {p.get('id'): getPartsFromCubicSuper(CubicSuperPath(p.get('d'))) for p in pathNodes } + if self.options.reverse is True: #helps debugging some strange Z orders (try out) + pathNodes = pathNodes[::-1] + #pathNodes[0].path = pathNodes[0].path.reverse() + #pathNodes[0].path = pathNodes[-1].path.reverse() + + paths = {p.get('id'): getPartsFromCubicSuper(CubicSuperPath(p.get('d'))) for p in pathNodes } #paths.keys() Order disturbed pathIds = [p.get('id') for p in pathNodes] - + if self.options.dimples_to_group is True: dimpleUnifyGroup = self.svg.get_current_layer().add(inkex.Group(id=self.svg.get_unique_id("dimplesCollection"))) if(len(paths) > 1): if(self.options.optimized): startPathId = pathIds[0] - pathIds = getArrangedIds(paths, startPathId) - + pathIds = getArrangedIds(paths, startPathId) newParts = [] firstElem = None for key in pathIds: @@ -171,7 +173,7 @@ class JoinPaths(inkex.EffectExtension): start = parts[0][0][0] try: elem = self.svg.selected[key] - + if(len(newParts) == 0): newParts += parts[:] firstElem = elem @@ -373,6 +375,9 @@ class JoinPaths(inkex.EffectExtension): except: pass #elem might come from group item - in this case we need to ignore it + if firstElem is None: + self.msg('Please select some paths first. Check if you selected a group or an object instead.') + exit() newElem = copy.copy(firstElem) oldId = firstElem.get('id') newElem.set('d', CubicSuperPath(getCubicSuperFromParts(newParts))) diff --git a/extensions/fablabchemnitz/mirror/meta.json b/extensions/fablabchemnitz/mirror/meta.json index 84f1636b..9bfc5258 100644 --- a/extensions/fablabchemnitz/mirror/meta.json +++ b/extensions/fablabchemnitz/mirror/meta.json @@ -11,7 +11,7 @@ "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/mirror", "fork_url": "https://inkscape.org/~jeko/%E2%98%85mirror", "documentation_url": "https://stadtfabrikanten.org/display/IFM/Mirror", - "inkscape_gallery_url": "https://inkscape.org/~MarioVoigt/%E2%98%85move-path-node", + "inkscape_gallery_url": null, "main_authors": [ "inkscape.org/jeko", "github.com/vmario89" diff --git a/extensions/fablabchemnitz/move_path_node/meta.json b/extensions/fablabchemnitz/move_path_node/meta.json index d930d988..e946a739 100644 --- a/extensions/fablabchemnitz/move_path_node/meta.json +++ b/extensions/fablabchemnitz/move_path_node/meta.json @@ -11,7 +11,7 @@ "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/move_path_node", "fork_url": null, "documentation_url": "https://stadtfabrikanten.org/display/IFM/Move+Path+Node", - "inkscape_gallery_url": null, + "inkscape_gallery_url": "https://inkscape.org/~MarioVoigt/%E2%98%85move-path-node", "main_authors": [ "github.com/vmario89" ]