From 29b72801cd0973559ac04b584d376286f58746ff Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Thu, 16 Mar 2023 16:32:46 +0100 Subject: Auto route satin: apply path effects (#2145) --- lib/stitches/auto_satin.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/stitches') diff --git a/lib/stitches/auto_satin.py b/lib/stitches/auto_satin.py index 228f1325..09f331bf 100644 --- a/lib/stitches/auto_satin.py +++ b/lib/stitches/auto_satin.py @@ -6,25 +6,25 @@ import math from itertools import chain +import inkex import networkx as nx from shapely import geometry as shgeo from shapely.geometry import Point as ShapelyPoint -import inkex - from ..commands import add_commands from ..elements import SatinColumn, Stroke from ..i18n import _ from ..svg import PIXELS_PER_MM, generate_unique_id, line_strings_to_csp -from ..svg.tags import INKSCAPE_LABEL, INKSTITCH_ATTRIBS +from ..svg.tags import (INKSCAPE_LABEL, INKSTITCH_ATTRIBS, ORIGINAL_D, + PATH_EFFECT) from ..utils import Point as InkstitchPoint from ..utils import cache, cut +from ..utils.threading import check_stop_flag from .utils.autoroute import (add_elements_to_group, add_jumps, create_new_group, find_path, get_starting_and_ending_nodes, preserve_original_groups, remove_original_elements) -from ..utils.threading import check_stop_flag class SatinSegment(object): @@ -331,6 +331,14 @@ def auto_satin(elements, preserve_order=False, starting_point=None, ending_point parent = elements[0].node.getparent() index = parent.index(elements[0].node) + # apply live path effects + # It would be nice if we could preserve them, but this could have unwanted side effects + # if the path needs to be broken up for better routing + for element in elements: + if element.node.get(PATH_EFFECT, None): + element.node.pop(PATH_EFFECT) + element.node.pop(ORIGINAL_D) + graph = build_graph(elements, preserve_order) add_jumps(graph, elements, preserve_order) starting_node, ending_node = get_starting_and_ending_nodes( -- cgit v1.2.3