This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/exportxy/exportxy.py

42 lines
1.3 KiB
Python
Raw Normal View History

2020-07-30 01:16:18 +02:00
#!/usr/bin/env python3
#
# curve xy co-ordinate export
# Authors:
# Jean Moreno <jean.moreno.fr@gmail.com>
# John Cliff <john.cliff@gmail.com>
# Neon22 <https://github.com/Neon22?tab=repositories>
# Jens N. Lallensack <jens.lallensack@gmail.com>
2021-04-08 22:00:37 +02:00
# Mario Voigt <mario.voigt@stadtfabrikanten.org>
2020-07-30 01:16:18 +02:00
#
# Copyright (C) 2011 Jean Moreno
# Copyright (C) 2011 John Cliff
# Copyright (C) 2011 Neon22
# Copyright (C) 2019 Jens N. Lallensack
2021-04-08 22:00:37 +02:00
# Copyright (C) 2021 Mario Voigt
2020-07-30 01:16:18 +02:00
# Released under GNU GPL v3, see https://www.gnu.org/licenses/gpl-3.0.en.html for details.
#
import inkex
import sys
from inkex.paths import CubicSuperPath
2020-07-30 01:16:18 +02:00
from inkex import transforms
2021-04-04 01:51:59 +02:00
class ExportXY(inkex.EffectExtension):
2021-04-08 22:00:37 +02:00
2020-07-30 01:16:18 +02:00
def effect(self):
2021-04-08 22:00:37 +02:00
if len(self.svg.selected) > 0:
2020-07-30 01:16:18 +02:00
output_all = output_nodes = ""
2021-04-08 22:00:37 +02:00
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()