From 2164c63e98c4a46b302f45e1e309c03af2cac8da Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Thu, 8 Apr 2021 22:00:37 +0200 Subject: [PATCH] Modernized ExportXY extension --- extensions/fablabchemnitz/exportxy.py | 37 +++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/extensions/fablabchemnitz/exportxy.py b/extensions/fablabchemnitz/exportxy.py index c87d699c..8c21fcaf 100644 --- a/extensions/fablabchemnitz/exportxy.py +++ b/extensions/fablabchemnitz/exportxy.py @@ -6,12 +6,14 @@ # John Cliff # Neon22 # Jens N. Lallensack +# Mario Voigt # # Copyright (C) 2011 Jean Moreno # Copyright (C) 2011 John Cliff # Copyright (C) 2011 Neon22 # Copyright (C) 2019 Jens N. Lallensack -# +# Copyright (C) 2021 Mario Voigt + # Released under GNU GPL v3, see https://www.gnu.org/licenses/gpl-3.0.en.html for details. # import inkex @@ -19,28 +21,25 @@ import sys from inkex.paths import CubicSuperPath from inkex import transforms -def warn(*args, **kwargs): - pass -import warnings -warnings.warn = warn - class ExportXY(inkex.EffectExtension): + def __init__(self): inkex.Effect.__init__(self) + def effect(self): - for node in self.svg.selected.items(): + if len(self.svg.selected) > 0: output_all = output_nodes = "" - for id, node in self.svg.selected.items(): - if node.tag == inkex.addNS('path','svg'): - output_all += "" - output_nodes += "" - node.apply_transform() - d = node.get('d') - p = CubicSuperPath(d) - for subpath in p: - for csp in subpath: - output_nodes += str(csp[1][0]) + "\t" + str(csp[1][1]) + "\n" - sys.stderr.write(output_nodes) - + for node in self.svg.selection.filter(inkex.PathElement): + node.apply_transform() + p = CubicSuperPath(node.get('d')) + for subpath in p: + for csp in subpath: + output_nodes += str(csp[1][0]) + "\t" + str(csp[1][1]) + "\n" + output_nodes += "\n" + sys.stderr.write(output_nodes.strip()) + else: + inkex.errormsg('Please select some paths first.') + return + if __name__ == '__main__': ExportXY().run() \ No newline at end of file