diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2025-04-19 07:11:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-19 07:11:57 +0200 |
| commit | b009a5355e7ceea477ea55eacba2149a9398b37e (patch) | |
| tree | 3061490b8f44638676b82bcc1adbbe11191c94c2 /lib | |
| parent | 54bc44daaf62ed1e65d7eb48e5cd245c252c14c2 (diff) | |
duplicate-consistant autoroute element selection (#3638)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/extensions/redwork.py | 3 | ||||
| -rw-r--r-- | lib/extensions/select_elements.py | 15 | ||||
| -rw-r--r-- | lib/stitches/auto_run.py | 3 | ||||
| -rw-r--r-- | lib/stitches/auto_satin.py | 3 |
4 files changed, 21 insertions, 3 deletions
diff --git a/lib/extensions/redwork.py b/lib/extensions/redwork.py index ee0ad141..53c6131c 100644 --- a/lib/extensions/redwork.py +++ b/lib/extensions/redwork.py @@ -162,9 +162,11 @@ class Redwork(InkstitchExtension): def _insert_element(self, index, path, group, style, transform, redwork=True): if redwork: path_id = self.svg.get_unique_id('redwork_') + path_type = 'redwork-top' label = _("Redwork") + f' {index}' else: path_id = self.svg.get_unique_id('underpath_') + path_type = 'redwork-underpath' label = _("Redwork Underpath") + f' {index}' element = PathElement( @@ -177,6 +179,7 @@ class Redwork(InkstitchExtension): element.label = label element.set('inkstitch:running_stitch_length_mm', self.options.redwork_running_stitch_length_mm) + element.set('inkstitch:path_type', path_type) if redwork: element.set('inkstitch:bean_stitch_repeats', self.options.redwork_bean_stitch_repeats) diff --git a/lib/extensions/select_elements.py b/lib/extensions/select_elements.py index 2b3cb142..be073ec6 100644 --- a/lib/extensions/select_elements.py +++ b/lib/extensions/select_elements.py @@ -163,9 +163,18 @@ class SelectElements(InkstitchExtension): element_id = element.node.get_id() or '' conditions = { 'all': True, - 'autorun-top': element_id.startswith('autorun') or element_id.startswith('redwork'), - 'autorun-underpath': element_id.startswith('underpath'), - 'autosatin-underpath': element_id.startswith('autosatinrun')} + 'autorun-top': ( + element_id.startswith('autorun') or # legacy search, doesn't work when paths have been duplicated within Inkscape + element_id.startswith('redwork') or # legacy search + element.node.get('inkstitch:path_type') == 'redwork-top' or + element.node.get('inkstitch:path_type') == 'autorun-top'), + 'autorun-underpath': ( + element_id.startswith('underpath') or # legacy search + element.node.get('inkstitch:path_type') == 'redwork-underpath' or + element.node.get('inkstitch:path_type') == 'autorun-underpath'), + 'autosatin-underpath': ( + element_id.startswith('autosatinrun') or # legacy search + element.node.get('inkstitch:path_type') == 'satin-underpath')} return conditions[self.options.running_stitch_condition] def _bean_stitch_repeats(self, element): diff --git a/lib/stitches/auto_run.py b/lib/stitches/auto_run.py index 760d0393..85c575bf 100644 --- a/lib/stitches/auto_run.py +++ b/lib/stitches/auto_run.py @@ -273,14 +273,17 @@ def create_element(path, position, direction, element): if direction == "autorun": label = _("AutoRun %d") % index dasharray = 'none' + path_type = 'autorun-top' else: label = _("AutoRun Underpath %d") % index dasharray = '2 1.1' + path_type = 'autorun-underpath' node = inkex.PathElement() node.set("id", generate_unique_id(element.node, el_id)) node.set(INKSCAPE_LABEL, label) node.set("d", path) + node.set("inkstitch:path_type", path_type) node.set("style", element.node.style) node.style["fill"] = 'none' node.style["stroke-dasharray"] = dasharray diff --git a/lib/stitches/auto_satin.py b/lib/stitches/auto_satin.py index 22d489db..67f5de34 100644 --- a/lib/stitches/auto_satin.py +++ b/lib/stitches/auto_satin.py @@ -428,6 +428,8 @@ def _route_single_satin(elements, starting_point, keep_originals): stroke_width = convert_stroke_width(satin) run_element.node.style['stroke-width'] = stroke_width + run_element.node.set('inkstitch:path_type', 'satin-underpath') + parent.insert(index, run_element.node) if not keep_originals: remove_original_elements([satin], True) @@ -598,6 +600,7 @@ def name_elements(new_elements, preserve_order): element.node.set("id", generate_unique_id(element.node, "autosatin")) else: element.node.set("id", generate_unique_id(element.node, "autosatinrun")) + element.node.set("inkstitch:path_type", 'satin-underpath') if not (preserve_order and INKSCAPE_LABEL in element.node.attrib): if isinstance(element, SatinColumn): |
