summaryrefslogtreecommitdiff
path: root/lib/extensions/selection_to_pattern.py
blob: 8b41ff8605c8f1209a1e45faba3ec3c8567b19f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Authors: see git history
#
# Copyright (c) 2021 Authors
# Licensed under the GNU GPL version 3.0 or later.  See the file LICENSE for details.

import inkex

from ..i18n import _
from ..marker import set_marker
from ..svg.tags import EMBROIDERABLE_TAGS
from .base import InkstitchExtension


class SelectionToPattern(InkstitchExtension):

    def effect(self):
        if not self.get_elements():
            return

        if not self.svg.selection:
            inkex.errormsg(_("Please select at least one object to be marked as a pattern."))
            return

        for pattern in self.get_nodes():
            if pattern.tag in EMBROIDERABLE_TAGS:
                set_marker(pattern, 'start', 'pattern')