diff --git a/extensions/fablabchemnitz/contourscanner/contour_scanner.inx b/extensions/fablabchemnitz/contourscanner/contour_scanner.inx index 0fab723a..6ecec05a 100644 --- a/extensions/fablabchemnitz/contourscanner/contour_scanner.inx +++ b/extensions/fablabchemnitz/contourscanner/contour_scanner.inx @@ -4,7 +4,6 @@ fablabchemnitz.de.contour_scanner - false false @@ -33,6 +32,8 @@ + + diff --git a/extensions/fablabchemnitz/convert_polylines.inx b/extensions/fablabchemnitz/convert_polylines.inx new file mode 100644 index 00000000..9978f491 --- /dev/null +++ b/extensions/fablabchemnitz/convert_polylines.inx @@ -0,0 +1,16 @@ + + + Convert To Polylines + fablabchemnitz.de.convert_polylines + + path + + + + + + + + diff --git a/extensions/fablabchemnitz/convert_polylines.py b/extensions/fablabchemnitz/convert_polylines.py new file mode 100644 index 00000000..fc892f5a --- /dev/null +++ b/extensions/fablabchemnitz/convert_polylines.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 + +""" +Extension for InkScape 1.0 + +Converts curves to polylines - a quick and dirty helper for a lot of elements. Basically the same functionality can be done with default UI featureset but with a lot more mouse clicks + +Author: Mario Voigt / FabLab Chemnitz +Mail: mario.voigt@stadtfabrikanten.org +Date: 05.09.2020 +Last patch: 05.09.2020 +License: GNU GPL v3 +""" + +import inkex +from inkex.paths import Path + +class ConvertToPolylines(inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + + def convertPath(self, node): + if node.tag == inkex.addNS('path','svg'): + polypath = [] + i = 0 + for x, y in node.path.end_points: + if i == 0: + polypath.append(['M', [x,y]]) + else: + polypath.append(['L', [x,y]]) + i += 1 + node.set('d', str(Path(polypath))) + children = node.getchildren() + if children is not None: + for child in children: + self.convertPath(child) + + def effect(self): + if len(self.svg.selected) == 0: + self.convertPath(self.document.getroot()) + else: + for id, item in self.svg.selected.items(): + self.convertPath(item) + +if __name__ == '__main__': + ConvertToPolylines().run() \ No newline at end of file