Advanced checks for openClosedPath extension

This commit is contained in:
Mario Voigt 2021-04-13 14:23:20 +02:00
parent 67859849e9
commit 48c9a9630e
1 changed files with 8 additions and 2 deletions

View File

@ -30,8 +30,14 @@ class OpenClosedPath(inkex.EffectExtension):
def effect(self):
elements = self.svg.selection.filter(PathElement).values()
for elem in elements:
pp=elem.path.to_absolute() #remove transformation matrix
pp = elem.path.to_absolute() #remove transformation matrix
elem.path = re.sub(r"Z","",str(pp))
sp = elem.path.to_superpath()
if sp[0] == sp[-1]: #if first is last point the path is also closed. The "Z" command is not required
raw = elem.path.to_arrays()
del raw[-1] #delete last point in path
elem.path = raw
if __name__ == '__main__':
OpenClosedPath().run()
OpenClosedPath().run()