diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-11-06 19:13:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-06 19:13:38 +0100 |
| commit | eafa256418af2d26497a623422b8777412b6f223 (patch) | |
| tree | 0ae1ee3376934108dadb5dd0dae386edbb192c89 /lib/stitches | |
| parent | 3922dce723a815ce32ebd8077b7e9589190c79ba (diff) | |
redwork/auto-run: keep stroke width (#3264)
Diffstat (limited to 'lib/stitches')
| -rw-r--r-- | lib/stitches/auto_run.py | 12 | ||||
| -rw-r--r-- | lib/stitches/utils/autoroute.py | 5 |
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/stitches/auto_run.py b/lib/stitches/auto_run.py index 38e05305..28da5482 100644 --- a/lib/stitches/auto_run.py +++ b/lib/stitches/auto_run.py @@ -13,7 +13,7 @@ from shapely.ops import nearest_points, substring, unary_union from ..commands import add_commands from ..elements import Stroke from ..i18n import _ -from ..svg import PIXELS_PER_MM, generate_unique_id +from ..svg import PIXELS_PER_MM, generate_unique_id, get_correction_transform from ..svg.tags import INKSCAPE_LABEL, INKSTITCH_ATTRIBS from ..utils.threading import check_stop_flag from .utils.autoroute import (add_elements_to_group, add_jumps, @@ -136,7 +136,7 @@ def autorun(elements, preserve_order=False, break_up=None, starting_point=None, else: parent = elements[0].node.getparent() insert_index = parent.index(elements[0].node) - group = create_new_group(parent, insert_index, _("Auto-Route")) + group = create_new_group(parent, insert_index, _("Auto-Route"), False) add_elements_to_group(new_elements, group) if trim: @@ -240,9 +240,9 @@ def path_to_elements(graph, path, trim): # noqa: C901 path_direction = direction if d == "": - d = "M %s %s, %s %s" % (start_coord.x, start_coord.y, end_coord.x, end_coord.y) + d = f"M {start_coord.x} {start_coord.y}, {end_coord.x} {end_coord.y}" else: - d += ", %s %s" % (end_coord.x, end_coord.y) + d += f", {end_coord.x} {end_coord.y}" elif el and d: # this is a jump, so complete the element whose path we've been building element_list.append(create_element(d, position, path_direction, el)) @@ -266,7 +266,7 @@ def create_element(path, position, direction, element): if not path: return - el_id = "%s_%s_" % (direction, position) + el_id = f"{direction}_{position}_" index = position + 1 if direction == "autorun": @@ -283,6 +283,8 @@ def create_element(path, position, direction, element): node.set("style", element.node.style) node.style["fill"] = 'none' node.style["stroke-dasharray"] = dasharray + node.transform = get_correction_transform(element.node.getparent(), child=True) + node.apply_transform() # Set Ink/Stitch attributes stitch_length = element.node.get(INKSTITCH_ATTRIBS['running_stitch_length_mm'], '') diff --git a/lib/stitches/utils/autoroute.py b/lib/stitches/utils/autoroute.py index ed07c9a4..a83e8002 100644 --- a/lib/stitches/utils/autoroute.py +++ b/lib/stitches/utils/autoroute.py @@ -230,11 +230,12 @@ def remove_from_parent(node): node.getparent().remove(node) -def create_new_group(parent, insert_index, label): +def create_new_group(parent, insert_index, label, correction_transform=True): group = inkex.Group(attrib={ INKSCAPE_LABEL: label, - "transform": get_correction_transform(parent, child=True) }) + if correction_transform: + group.transform = get_correction_transform(parent, child=True) parent.insert(insert_index, group) return group |
