diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-06-12 12:25:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 12:25:52 +0200 |
| commit | 39d9defef4a6c813e40df9a8de254af422af6ccd (patch) | |
| tree | 053a5173de33a7b657f733c9a07bfe7d79350c21 /lib/output.py | |
| parent | 45a3eb49b14ed804bbcf2367b29b3d085a07e6db (diff) | |
improve error message for files with too many color changes (#2984)
Diffstat (limited to 'lib/output.py')
| -rw-r--r-- | lib/output.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/output.py b/lib/output.py index fb4580b7..23f0cf1e 100644 --- a/lib/output.py +++ b/lib/output.py @@ -4,9 +4,12 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. import os +import re import sys import inkex +from pyembroidery.exceptions import TooManyColorChangesError + import pyembroidery from .commands import global_command @@ -113,3 +116,14 @@ def write_embroidery_file(file_path, stitch_plan, svg, settings={}): msg = _("Error writing to %(path)s: %(error)s") % dict(path=file_path, error=e.strerror) inkex.errormsg(msg) sys.exit(1) + except TooManyColorChangesError as e: + num_color_changes = re.search("d+", str(e)).group() + msg = _("Couldn't save embrodiery file.") + msg += '\n\n' + msg += _("There are {num_color_changes} in your design. This is way too many.").format(num_color_changes=num_color_changes) + msg += '\n' + msg += _("Please reduce color changes. Find more information on our website:") + msg += '\n\n' + msg += _("http://inkstitch.org/docs/faq/#too-many-color-changes") + inkex.errormsg(msg) + sys.exit(1) |
