diff options
| -rw-r--r-- | lib/extensions/input.py | 5 | ||||
| -rw-r--r-- | lib/stitch_plan/stitch_plan.py | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/extensions/input.py b/lib/extensions/input.py index 53961e91..826e7e04 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -18,8 +18,7 @@ class Input(object): color_block = None for raw_stitches, thread in pattern.get_as_colorblocks(): - if len(raw_stitches) > 1: - color_block = stitch_plan.new_color_block(thread) + color_block = stitch_plan.new_color_block(thread) trim_after = False for x, y, command in raw_stitches: if command == pyembroidery.STITCH: @@ -30,6 +29,8 @@ class Input(object): if len(color_block) > 0 and command == pyembroidery.TRIM: trim_after = True + stitch_plan.delete_empty_color_block(color_block) + extents = stitch_plan.extents svg = etree.Element("svg", nsmap=inkex.NSS, attrib={ "width": str(extents[0] * 2), diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index 808fa626..0b12c2c5 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -72,6 +72,10 @@ class StitchPlan(object): self.color_blocks.append(color_block) return color_block + def delete_empty_color_block(self, color_block): + if len(color_block) == 0: + self.color_blocks.remove(color_block) + def add_color_block(self, color_block): self.color_blocks.append(color_block) |
