diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-07-04 22:08:08 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-07-12 20:13:46 -0400 |
| commit | 7ccc6aa72ce02ea335f129577c8984698a987d0e (patch) | |
| tree | 14b4bc4fc33fb34c716aaa31424068c947aaf99e /lib/extensions | |
| parent | 1c5e4fbf73e673a12d67d27a1f0e88c2265c762f (diff) | |
remove legacy params when attaching the equivalent command
Diffstat (limited to 'lib/extensions')
| -rw-r--r-- | lib/extensions/commands.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/extensions/commands.py b/lib/extensions/commands.py index aeda2cc2..9c080b4e 100644 --- a/lib/extensions/commands.py +++ b/lib/extensions/commands.py @@ -87,8 +87,26 @@ class Commands(InkstitchExtension): outline = element.shape.buffer(30).exterior return outline.interpolate(index / float(total), normalized=True) + def remove_legacy_param(self, element, command): + if command == "trim" or command == "stop": + # If they had the old "TRIM after" or "STOP after" attributes set, + # automatically delete them. THe new commands will do the same + # thing. + # + # If we didn't delete these here, then things would get confusing. + # If the user were to delete a "trim" symbol added by this extension + # but the "embroider_trim_after" attribute is still set, then the + # trim would keep happening. + + attribute = "embroider_%s_after" % command + + if attribute in element.node.attrib: + del element.node.attrib[attribute] + def add_command(self, element, commands): for i, command in enumerate(commands): + self.remove_legacy_param(element, command) + pos = self.get_command_pos(element, i, len(commands)) symbol = inkex.etree.SubElement(element.node.getparent(), SVG_USE_TAG, @@ -125,4 +143,4 @@ class Commands(InkstitchExtension): self.ensure_symbol(command) for element in self.elements: - self.add_command(element, commands) + self.add_command(element, commands) |
