From 697b6c64f8ae7b2564fbf6ff57488c7ca8025049 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 29 Mar 2024 11:09:17 +0100 Subject: [PATCH] add options to remove specific params only (#2774) --- lib/extensions/remove_embroidery_settings.py | 9 +- templates/jump_to_stroke.xml | 2 +- templates/remove_embroidery_settings.xml | 154 ++++++++++++++++--- 3 files changed, 142 insertions(+), 23 deletions(-) diff --git a/lib/extensions/remove_embroidery_settings.py b/lib/extensions/remove_embroidery_settings.py index b90d590ba..a082f70fe 100644 --- a/lib/extensions/remove_embroidery_settings.py +++ b/lib/extensions/remove_embroidery_settings.py @@ -13,14 +13,15 @@ from .base import InkstitchExtension class RemoveEmbroiderySettings(InkstitchExtension): def __init__(self, *args, **kwargs): InkstitchExtension.__init__(self, *args, **kwargs) - self.arg_parser.add_argument("-p", "--del_params", dest="del_params", type=Boolean, default=True) + self.arg_parser.add_argument("--tabs") + self.arg_parser.add_argument("-p", "--del_params", dest="del_params", type=str, default=True) self.arg_parser.add_argument("-c", "--del_commands", dest="del_commands", type=str, default="none") self.arg_parser.add_argument("-d", "--del_print", dest="del_print", type=Boolean, default=False) def effect(self): self.svg = self.document.getroot() - if self.options.del_params: + if self.options.del_params != 'none': self.remove_params() if self.options.del_commands != 'none': self.remove_commands() @@ -103,7 +104,9 @@ class RemoveEmbroiderySettings(InkstitchExtension): element.getparent().remove(element) def remove_inkstitch_attributes(self, elements): + param_to_remove = self.options.del_params for element in elements: for attrib in element.attrib: if attrib.startswith(NSS['inkstitch'], 1): - del element.attrib[attrib] + if param_to_remove == 'all' or attrib.endswith(param_to_remove): + del element.attrib[attrib] diff --git a/templates/jump_to_stroke.xml b/templates/jump_to_stroke.xml index 653423681..061ccf2d1 100644 --- a/templates/jump_to_stroke.xml +++ b/templates/jump_to_stroke.xml @@ -38,7 +38,7 @@ 2.0 - + diff --git a/templates/remove_embroidery_settings.xml b/templates/remove_embroidery_settings.xml index 083f953b2..50785b530 100644 --- a/templates/remove_embroidery_settings.xml +++ b/templates/remove_embroidery_settings.xml @@ -2,26 +2,142 @@ Remove embroidery settings org.{{ id_inkstitch }}.remove_embroidery_settings - - true - - - - {%- for command, description in object_commands -%} - - {% endfor %} - {% for command, description in layer_commands %} - - {% endfor %} - {% for command, description in global_commands %} - - {% endfor %} - - false remove_embroidery_settings + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {%- for command, description in object_commands -%} + + {% endfor %} + {% for command, description in layer_commands %} + + {% endfor %} + {% for command, description in global_commands %} + + {% endfor %} + + false + + + + + + + + + + + all