diff --git a/extensions/fablabchemnitz/contourscanner/contour_scanner.inx b/extensions/fablabchemnitz/contourscanner/contour_scanner.inx index 907f56d6..e3023989 100644 --- a/extensions/fablabchemnitz/contourscanner/contour_scanner.inx +++ b/extensions/fablabchemnitz/contourscanner/contour_scanner.inx @@ -6,7 +6,7 @@ This tool helps you to find nasty contours which might bug you and prevent your work from being ready for production. You can find the complete documentation at the Wiki space of https://fablabchemnitz.de General - false + false false 1.0 Highlight paths @@ -24,11 +24,14 @@ false false - - Written by Mario Voigt (Stadtfabrikanten e.V. / FabLab Chemnitz) (https://gitea.fablabchemnitz.de) - Last update: 09.08.2020 - This piece of software is part of the MightyScape for InkScape 1.0/1.1dev Extension Collection - you found a bug or got some fresh code? Just report to mario.voigt@stadtfabrikanten.org. Thanks! + + + + + + + + diff --git a/extensions/fablabchemnitz/contourscanner/contour_scanner.py b/extensions/fablabchemnitz/contourscanner/contour_scanner.py index 22d05b42..9776dbcf 100644 --- a/extensions/fablabchemnitz/contourscanner/contour_scanner.py +++ b/extensions/fablabchemnitz/contourscanner/contour_scanner.py @@ -63,8 +63,9 @@ class ContourScanner(inkex.Effect): self.arg_parser.add_argument("--main_tabs") #split combined contours into single contours if enabled - this is exactly the same as "Path -> Break Apart" + replacedNodes = [] + def breakContours(self, node): - replacedNodes = [] if node.tag == inkex.addNS('path','svg'): parent = node.getparent() idx = parent.index(node) @@ -84,11 +85,10 @@ class ContourScanner(inkex.Effect): replacedNode.set('id', oldId + str(idSuffix).zfill(5)) parent.insert(idx, replacedNode) idSuffix += 1 - replacedNodes.append(replacedNode) + self.replacedNodes.append(replacedNode) parent.remove(node) for child in node: self.breakContours(child) - return replacedNodes def scanContours(self, node): if node.tag == inkex.addNS('path','svg'): @@ -176,7 +176,12 @@ class ContourScanner(inkex.Effect): node.getparent().remove(node) except Exception as e: # we skip AssertionError #inkex.utils.debug("Accuracy Error. Try to reduce the precision of the paths using the extension called Rounder to cutoff unrequired decimals.") - print(str(e)) + print(str(e)) + #if the dot_group was created but nothing attached we delete it again to prevent messing the SVG XML tree + if len(dot_group.getchildren()) == 0: + dot_group.getparent().remove(dot_group) + else: #put the node into the dot_group to bundle the path with it's error markers + dot_group.insert(0, node) for child in node: self.scanContours(child) @@ -188,10 +193,9 @@ class ContourScanner(inkex.Effect): else: newContourSet = [] for id, item in self.svg.selected.items(): - newContourSet.append(self.breakContours(item)) - for newContours in newContourSet: - for newContour in newContours: - self.scanContours(newContour) + self.breakContours(item) + for newContours in self.replacedNodes: + self.scanContours(newContours) else: if len(self.svg.selected) == 0: self.scanContours(self.document.getroot())