diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2018-10-30 17:43:21 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-30 17:43:21 -0600 |
| commit | be833f898ff4912b4f1e54be37e6b8ff3c3f2c42 (patch) | |
| tree | f9ea2a1e69c6ea916e7933f9d84cc4178bbec75f /lib/extensions/base.py | |
| parent | d9525968a2462270ed5ef0f2ec1742c8ae325079 (diff) | |
new extension: Auto-Route Satin Columns (#330)
**video demo:** https://www.youtube.com/watch?v=tbghtqziB1g
This branch adds a new extension, Auto-Route Satin Columns, implementing #214! This is a huge new feature that opens the door wide for exciting stuff like lettering (#142).
To use it, select some satin columns and run the extension. After a few seconds, it will replace your satins with a new set with a logical stitching order. Under-pathing and jump-stitches will be added as necessary, and satins will be broken to facilitate jumps. The resulting satins will retain all of the parameters you had set on the original satins, including underlay, zig-zag spacing, etc.
By default, it will choose the left-most extreme as the starting point and the right-most extreme as the ending point (even if these occur partway through a satin such as the left edge of a letter "o"). You can override this by attaching the new "Auto-route satin stitch starting/ending position" commands.
There's also an option to add trims instead of jump stitches. Any jump stitch over 1mm is trimmed. I might make this configurable in the future but in my tests it seems to do a good job. Trim commands are added to the SVG, so it's easy enough to modify/delete as you see fit.
Diffstat (limited to 'lib/extensions/base.py')
| -rw-r--r-- | lib/extensions/base.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/extensions/base.py b/lib/extensions/base.py index 25de441f..b9bba617 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -1,14 +1,15 @@ -import inkex -import re -import json -from copy import deepcopy from collections import MutableMapping +from copy import deepcopy +import json +import re + +import inkex from stringcase import snakecase -from ..svg.tags import SVG_GROUP_TAG, INKSCAPE_GROUPMODE, SVG_DEFS_TAG, EMBROIDERABLE_TAGS, SVG_POLYLINE_TAG -from ..elements import AutoFill, Fill, Stroke, SatinColumn, Polyline, EmbroideryElement from ..commands import is_command, layer_commands +from ..elements import AutoFill, Fill, Stroke, SatinColumn, Polyline, EmbroideryElement from ..i18n import _ +from ..svg.tags import SVG_GROUP_TAG, INKSCAPE_GROUPMODE, SVG_DEFS_TAG, EMBROIDERABLE_TAGS, SVG_POLYLINE_TAG SVG_METADATA_TAG = inkex.addNS("metadata", "svg") @@ -21,7 +22,7 @@ def strip_namespace(tag): <<< namedview """ - match = re.match('^\{[^}]+\}(.+)$', tag) + match = re.match(r'^\{[^}]+\}(.+)$', tag) if match: return match.group(1) @@ -211,8 +212,20 @@ class InkstitchExtension(inkex.Effect): return svg_filename + def uniqueId(self, prefix, make_new_id=True): + """Override inkex.Effect.uniqueId with a nicer naming scheme.""" + i = 1 + while True: + new_id = "%s%d" % (prefix, i) + if new_id not in self.doc_ids: + break + i += 1 + self.doc_ids[new_id] = 1 + + return new_id + def parse(self): - """Override inkex.Effect to add Ink/Stitch xml namespace""" + """Override inkex.Effect.parse to add Ink/Stitch xml namespace""" # SVG parsers don't actually look for anything at this URL. They just # care that it's unique. That defines a "namespace" of element and |
