From c6aa4d8eb08132dc25a56be4187d5b14d7449fc5 Mon Sep 17 00:00:00 2001 From: leyghisbb Date: Sun, 30 Aug 2020 11:25:16 +0200 Subject: [PATCH] fix in destructive clip extension (handling of VH lines) --- extensions/fablabchemnitz_destructiveclip.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/extensions/fablabchemnitz_destructiveclip.py b/extensions/fablabchemnitz_destructiveclip.py index 295a5363..f7c73adb 100644 --- a/extensions/fablabchemnitz_destructiveclip.py +++ b/extensions/fablabchemnitz_destructiveclip.py @@ -35,8 +35,7 @@ class DestructiveClip(inkex.Effect): inkex.Effect.__init__(self) self.error_messages = [] - self.curve_error = 'Unable to parse path.\nConsider removing curves ' - self.curve_error += 'with Extensions > Modify Path > Flatten Beziers...' + self.curve_error = 'Unable to parse path.\nConsider removing curves with Extensions > Modify Path > Flatten Beziers...' def approxEqual(self, a, b): # compare with tiny tolerance @@ -153,6 +152,7 @@ class DestructiveClip(inkex.Effect): clippedLines.extend(self.cullSegmentedLine(self.clipLine(lineToClip, clippingLineSegments), clippingLineSegments, self.maxX(clippingLineSegments))) return clippedLines + #you can also run the extension Modify Path > To Absolute Coordinates to convert VH to L def fixVHbehaviour(self, elem): raw = Path(elem.get("d")).to_arrays() subpaths, prev = [], 0 @@ -163,9 +163,8 @@ class DestructiveClip(inkex.Effect): subpaths.append(raw[prev:]) seg = [] for simpath in subpaths: - closed = False if simpath[-1][0] == 'Z': - closed = True + simpath[-1][0] = 'L' if simpath[-2][0] == 'L': simpath[-1][1] = simpath[0][1] else: simpath.pop() for i in range(len(simpath)): @@ -194,10 +193,12 @@ class DestructiveClip(inkex.Effect): if node.tag == pathTag: path = self.fixVHbehaviour(node) if clippingLineSegments is None: # first path is the clipper + #(clippingLineSegments, errors) = self.simplepathToLineSegments(node.path.to_arrays()) (clippingLineSegments, errors) = self.simplepathToLineSegments(path) self.error_messages.extend(['{}: {}'.format(id, err) for err in errors]) else: # do all the work! + #segmentsToClip, errors = self.simplepathToLineSegments(node.path.to_arrays()) segmentsToClip, errors = self.simplepathToLineSegments(path) self.error_messages.extend(['{}: {}'.format(id, err) for err in errors]) clippedSegments = self.clipLineSegments(segmentsToClip, clippingLineSegments) @@ -215,4 +216,4 @@ class DestructiveClip(inkex.Effect): for error in self.error_messages: inkex.errormsg(error) -DestructiveClip().run() \ No newline at end of file +DestructiveClip().run()