small fix in join paths

This commit is contained in:
Mario Voigt 2020-08-09 04:24:05 +02:00
parent 675a71af69
commit 6b27a2fee8

View File

@ -131,26 +131,29 @@ class JoinPathsOptimEffect(inkex.Effect):
parts = paths[key] parts = paths[key]
# ~ parts = getPartsFromCubicSuper(cspath) # ~ parts = getPartsFromCubicSuper(cspath)
start = parts[0][0][0] start = parts[0][0][0]
elem = self.svg.selected[key] try:
elem = self.svg.selected[key]
if(len(newParts) == 0):
newParts += parts[:] if(len(newParts) == 0):
firstElem = elem newParts += parts[:]
else: firstElem = elem
if(vectCmpWithMargin(start, newParts[-1][-1][-1], margin = .01)):
newParts[-1] += parts[0]
else: else:
newSeg = [newParts[-1][-1][-1], newParts[-1][-1][-1], start, start] if(vectCmpWithMargin(start, newParts[-1][-1][-1], margin = .01)):
newParts[-1].append(newSeg) newParts[-1] += parts[0]
newParts[-1] += parts[0] else:
newSeg = [newParts[-1][-1][-1], newParts[-1][-1][-1], start, start]
newParts[-1].append(newSeg)
newParts[-1] += parts[0]
if(len(parts) > 1):
newParts += parts[1:]
if(len(parts) > 1): parent = elem.getparent()
newParts += parts[1:] idx = parent.index(elem)
parent.remove(elem)
parent = elem.getparent() except:
idx = parent.index(elem) pass #elem might come from group item - in this case we need to ignore it
parent.remove(elem)
newElem = copy.copy(firstElem) newElem = copy.copy(firstElem)
oldId = firstElem.get('id') oldId = firstElem.get('id')
newElem.set('d', CubicSuperPath(getCubicSuperFromParts(newParts))) newElem.set('d', CubicSuperPath(getCubicSuperFromParts(newParts)))