diff --git a/extensions/fablabchemnitz/contourscanner/contour_scanner.py b/extensions/fablabchemnitz/contourscanner/contour_scanner.py index 7d15b647..1f2046da 100644 --- a/extensions/fablabchemnitz/contourscanner/contour_scanner.py +++ b/extensions/fablabchemnitz/contourscanner/contour_scanner.py @@ -13,8 +13,11 @@ Features Author: Mario Voigt / FabLab Chemnitz Mail: mario.voigt@stadtfabrikanten.org Date: 09.08.2020 -Last patch: 14.04.2021 +Last patch: 19.05.2021 License: GNU GPL v3 + +ToDo: +- add option to replace last segment of closed paths by 'Z' or 'z' in case the first and last segment touch each other (coincident point) """ import sys @@ -131,9 +134,13 @@ class ContourScanner(inkex.EffectExtension): subPaths.append(raw[prev:]) for simpath in subPaths: + closed = False - if simpath[-1][0] == 'Z': - closed = True + if simpath[-1][0] == 'Z' or \ + (simpath[-1][0] == 'L' and simpath[0][1] == simpath[-1][1]) or \ + (simpath[-1][0] == 'C' and simpath[0][1] == [simpath[-1][1][-2], simpath[-1][1][-1]]) : #if first is last point the path is also closed. The "Z" command is not required + closed = True + if simpath[-2][0] == 'L': simpath[-1][1] = simpath[0][1] else: simpath.pop() points = [] diff --git a/extensions/fablabchemnitz/create_links/create_links.py b/extensions/fablabchemnitz/create_links/create_links.py index 34f6f33d..f550a000 100644 --- a/extensions/fablabchemnitz/create_links/create_links.py +++ b/extensions/fablabchemnitz/create_links/create_links.py @@ -93,11 +93,14 @@ class LinksCreator(inkex.EffectExtension): def effect(self): def createLinks(element): elementParent = element.getparent() - - pathIsClosed = False path = element.path.to_arrays() #to_arrays() is deprecated. How to make more modern? - if path[-1][0] == 'Z' or path[0][1] == path[-1][1]: #if first is last point the path is also closed. The "Z" command is not required + pathIsClosed = False + if path[-1][0] == 'Z' or \ + (path[-1][0] == 'L' and path[0][1] == path[-1][1]) or \ + (path[-1][0] == 'C' and path[0][1] == [path[-1][1][-2], path[-1][1][-1]]) \ + : #if first is last point the path is also closed. The "Z" command is not required pathIsClosed = True + if self.options.path_types == 'open_paths' and pathIsClosed is True: return #skip this loop iteration elif self.options.path_types == 'closed_paths' and pathIsClosed is False: