Modernized ExportXY extension
This commit is contained in:
parent
8533d56b60
commit
2164c63e98
@ -6,12 +6,14 @@
|
|||||||
# John Cliff <john.cliff@gmail.com>
|
# John Cliff <john.cliff@gmail.com>
|
||||||
# Neon22 <https://github.com/Neon22?tab=repositories>
|
# Neon22 <https://github.com/Neon22?tab=repositories>
|
||||||
# Jens N. Lallensack <jens.lallensack@gmail.com>
|
# Jens N. Lallensack <jens.lallensack@gmail.com>
|
||||||
|
# Mario Voigt <mario.voigt@stadtfabrikanten.org>
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Jean Moreno
|
# Copyright (C) 2011 Jean Moreno
|
||||||
# Copyright (C) 2011 John Cliff
|
# Copyright (C) 2011 John Cliff
|
||||||
# Copyright (C) 2011 Neon22
|
# Copyright (C) 2011 Neon22
|
||||||
# Copyright (C) 2019 Jens N. Lallensack
|
# 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.
|
# Released under GNU GPL v3, see https://www.gnu.org/licenses/gpl-3.0.en.html for details.
|
||||||
#
|
#
|
||||||
import inkex
|
import inkex
|
||||||
@ -19,28 +21,25 @@ import sys
|
|||||||
from inkex.paths import CubicSuperPath
|
from inkex.paths import CubicSuperPath
|
||||||
from inkex import transforms
|
from inkex import transforms
|
||||||
|
|
||||||
def warn(*args, **kwargs):
|
|
||||||
pass
|
|
||||||
import warnings
|
|
||||||
warnings.warn = warn
|
|
||||||
|
|
||||||
class ExportXY(inkex.EffectExtension):
|
class ExportXY(inkex.EffectExtension):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
inkex.Effect.__init__(self)
|
inkex.Effect.__init__(self)
|
||||||
|
|
||||||
def effect(self):
|
def effect(self):
|
||||||
for node in self.svg.selected.items():
|
if len(self.svg.selected) > 0:
|
||||||
output_all = output_nodes = ""
|
output_all = output_nodes = ""
|
||||||
for id, node in self.svg.selected.items():
|
for node in self.svg.selection.filter(inkex.PathElement):
|
||||||
if node.tag == inkex.addNS('path','svg'):
|
node.apply_transform()
|
||||||
output_all += ""
|
p = CubicSuperPath(node.get('d'))
|
||||||
output_nodes += ""
|
for subpath in p:
|
||||||
node.apply_transform()
|
for csp in subpath:
|
||||||
d = node.get('d')
|
output_nodes += str(csp[1][0]) + "\t" + str(csp[1][1]) + "\n"
|
||||||
p = CubicSuperPath(d)
|
output_nodes += "\n"
|
||||||
for subpath in p:
|
sys.stderr.write(output_nodes.strip())
|
||||||
for csp in subpath:
|
else:
|
||||||
output_nodes += str(csp[1][0]) + "\t" + str(csp[1][1]) + "\n"
|
inkex.errormsg('Please select some paths first.')
|
||||||
sys.stderr.write(output_nodes)
|
return
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ExportXY().run()
|
ExportXY().run()
|
Reference in New Issue
Block a user