summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/extensions/stitch_plan_preview.py7
-rw-r--r--lib/extensions/utils/inkex_command.py1
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/extensions/stitch_plan_preview.py b/lib/extensions/stitch_plan_preview.py
index 983435bb..464e4200 100644
--- a/lib/extensions/stitch_plan_preview.py
+++ b/lib/extensions/stitch_plan_preview.py
@@ -5,6 +5,7 @@
import sys
from base64 import b64encode
+from re import findall
from tempfile import TemporaryDirectory
from typing import Optional, Tuple
@@ -133,10 +134,14 @@ class StitchPlanPreview(InkstitchExtension):
"export-do" # Inkscape docs say this should be implicit at the end, but it doesn't seem to be.
]))
+ # Extract numbers from returned string. It can include other information such as warnings about the usage of AppImages
+ out = findall(r"(?m)^-?\d+\.?\d*$", out)
+
# The query commands return positions in px, so we need to convert to uu.
px_to_uu = svg.unittouu("1px")
+
# Parse the returned coordinates out.
- x, y, width, height = map(lambda x: px_to_uu*float(x), out.split())
+ x, y, width, height = map(lambda x: px_to_uu*float(x), out)
# Embed the rasterized stitch plan into the SVG, and replace the original stitch plan
with open(temp_png_path, "rb") as f:
diff --git a/lib/extensions/utils/inkex_command.py b/lib/extensions/utils/inkex_command.py
index 3b14db16..20cfc0a5 100644
--- a/lib/extensions/utils/inkex_command.py
+++ b/lib/extensions/utils/inkex_command.py
@@ -208,6 +208,7 @@ def inkscape(svg_file, *args, **kwargs):
to `--export-id` and `--query-id`, by converting the call to the appropriate
action sequence. The stdout is cleaned to resemble non-interactive mode.
"""
+ os.environ["SELF_CALL"] = "true" # needed for inkscape versions 1.3 and 1.3.1
actions = kwargs.get("actions", None)
strip_stdout = False
# Keep some safe margin to the 8191 character limit.