diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2020-03-05 18:15:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-05 18:15:34 +0100 |
| commit | 7cc8b0c14e91d2e68212248b8ce66797ade7bb65 (patch) | |
| tree | 18e857c32fbef9d44eccd067d9f1394ccc8206c2 /lib/extensions | |
| parent | 86901a2ab5f94f73ee66fb19b832c9905b2182fc (diff) | |
fix remove commands for foreign languages (#618)
Diffstat (limited to 'lib/extensions')
| -rw-r--r-- | lib/extensions/remove_embroidery_settings.py | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/extensions/remove_embroidery_settings.py b/lib/extensions/remove_embroidery_settings.py index c467e797..d87a216a 100644 --- a/lib/extensions/remove_embroidery_settings.py +++ b/lib/extensions/remove_embroidery_settings.py @@ -38,24 +38,35 @@ class RemoveEmbroiderySettings(InkstitchExtension): def remove_commands(self): if not self.selected: - commands = ".//*[starts-with(@inkscape:label, 'Ink/Stitch Command:')]" - self.remove_elements(commands) + # we are not able to grab commands by a specific id + # so let's move through every object instead and see if it has a command + xpath = ".//svg:path|.//svg:circle|.//svg:rect|.//svg:ellipse" + elements = self.find_elements(xpath) + else: + elements = [] + for node in self.selected: + elements.extend(self.get_selected_elements(node)) + if elements: + for element in elements: + for command in find_commands(element): + group = command.connector.getparent() + group.getparent().remove(group) + + if not self.selected: + # remove standalone commands + standalone_commands = ".//svg:use[starts-with(@xlink:href, '#inkstitch_')]" + self.remove_elements(standalone_commands) + + # let's remove the symbols (defs), we won't need them in the document symbols = ".//*[starts-with(@id, 'inkstitch_')]" self.remove_elements(symbols) - else: - for node in self.selected: - elements = self.get_selected_elements(node) - for element in elements: - for command in find_commands(element): - group = command.connector.getparent() - group.getparent().remove(group) def get_selected_elements(self, element_id): - xpath = ".//svg:path[@id='%s']" % element_id + xpath = ".//svg:g[@id='%(id)s']//svg:path|.//svg:g[@id='%(id)s']//svg:use" % dict(id=element_id) elements = self.find_elements(xpath) if not elements: - xpath = ".//svg:g[@id='%s']//svg:path" % element_id + xpath = ".//*[@id='%s']" % element_id elements = self.find_elements(xpath) return elements |
