From e84a86d4ac0caf29d6074728376ff0a594243fec Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Thu, 4 Mar 2021 18:40:53 +0100 Subject: Update for Inkscape 1.0 (#880) * update for inkscape 1.0 * add about extension * Build improvements for the inkscape1.0 branch (#985) * zip: export real svg not stitch plan * #411 and #726 * Tools for Font Creators (#1018) * ignore very small holes in fills * remove embroider (#1026) * auto_fill: ignore shrink_or_grow if result is empty (#589) * break apart: do not ignore small fills Co-authored-by: Hagen Fritsch Co-authored-by: Lex Neva --- lib/extensions/convert_to_satin.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'lib/extensions/convert_to_satin.py') diff --git a/lib/extensions/convert_to_satin.py b/lib/extensions/convert_to_satin.py index e2b287dd..048c08da 100644 --- a/lib/extensions/convert_to_satin.py +++ b/lib/extensions/convert_to_satin.py @@ -1,12 +1,13 @@ import math +import sys from itertools import chain, groupby +import inkex import numpy +from lxml import etree from numpy import diff, setdiff1d, sign from shapely import geometry as shgeo -import inkex - from ..elements import Stroke from ..i18n import _ from ..svg import PIXELS_PER_MM, get_correction_transform @@ -26,7 +27,7 @@ class ConvertToSatin(InkstitchExtension): if not self.get_elements(): return - if not self.selected: + if not self.svg.selected: inkex.errormsg(_("Please select at least one line to convert to a satin column.")) return @@ -120,8 +121,15 @@ class ConvertToSatin(InkstitchExtension): path = shgeo.LineString(path) - left_rail = path.parallel_offset(stroke_width / 2.0, 'left', **style_args) - right_rail = path.parallel_offset(stroke_width / 2.0, 'right', **style_args) + try: + left_rail = path.parallel_offset(stroke_width / 2.0, 'left', **style_args) + right_rail = path.parallel_offset(stroke_width / 2.0, 'right', **style_args) + except ValueError: + # TODO: fix this error automatically + # Error reference: https://github.com/inkstitch/inkstitch/issues/964 + inkex.errormsg(_("Ink/Stitch cannot convert your stroke into a satin column. " + "Please break up your path and try again.") + '\n') + sys.exit(1) if not isinstance(left_rail, shgeo.LineString) or \ not isinstance(right_rail, shgeo.LineString): @@ -304,12 +312,11 @@ class ConvertToSatin(InkstitchExtension): d += "%s,%s " % (x, y) d += " " - return inkex.etree.Element(SVG_PATH_TAG, - { - "id": self.uniqueId("path"), - "style": path_style, - "transform": correction_transform, - "d": d, - INKSTITCH_ATTRIBS['satin_column']: "true", - } - ) + return etree.Element(SVG_PATH_TAG, + { + "id": self.uniqueId("path"), + "style": path_style, + "transform": correction_transform, + "d": d, + INKSTITCH_ATTRIBS['satin_column']: "true", + }) -- cgit v1.2.3