From 23ac0a4f7fb6d7c47728d42a03085a732cb75a10 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Tue, 2 Jul 2019 18:38:48 +0200 Subject: Ignore commands on input files --- lib/extensions/input.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/extensions/input.py') diff --git a/lib/extensions/input.py b/lib/extensions/input.py index 0ca85df5..fbc37bd7 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -19,9 +19,9 @@ class Input(object): for raw_stitches, thread in pattern.get_as_colorblocks(): color_block = stitch_plan.new_color_block(thread) for x, y, command in raw_stitches: - color_block.add_stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0, - jump=(command == pyembroidery.JUMP), - trim=(command == pyembroidery.TRIM)) + # let's ignore commands for now + if command == pyembroidery.STITCH: + color_block.add_stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0) extents = stitch_plan.extents svg = etree.Element("svg", nsmap=inkex.NSS, attrib={ -- cgit v1.2.3 From f039ef4c8d05628ebf6e13fb011ec054dc4c8740 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Thu, 4 Jul 2019 15:35:31 +0200 Subject: respect trim commands --- lib/extensions/input.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/extensions/input.py') diff --git a/lib/extensions/input.py b/lib/extensions/input.py index fbc37bd7..9f1314eb 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -18,10 +18,21 @@ class Input(object): for raw_stitches, thread in pattern.get_as_colorblocks(): color_block = stitch_plan.new_color_block(thread) + trim_after = False + jump_counter = 0 for x, y, command in raw_stitches: - # let's ignore commands for now if command == pyembroidery.STITCH: + if trim_after: + color_block.add_stitch(trim=True) + trim_after = False color_block.add_stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0) + jump_counter = 0 + elif len(color_block) > 0: + # some file formats use 3 or more jump stitches in a row to indicate a trim + if command == pyembroidery.JUMP: + jump_counter += 1 + if command == pyembroidery.TRIM or jump_counter >=3: + trim_after = True extents = stitch_plan.extents svg = etree.Element("svg", nsmap=inkex.NSS, attrib={ -- cgit v1.2.3 From 3ef2ad9be4173d5c154b3ba0ea39439fb2a274d8 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Thu, 4 Jul 2019 15:41:52 +0200 Subject: fix style --- lib/extensions/input.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/extensions/input.py') diff --git a/lib/extensions/input.py b/lib/extensions/input.py index 9f1314eb..a8402fdc 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -31,7 +31,7 @@ class Input(object): # some file formats use 3 or more jump stitches in a row to indicate a trim if command == pyembroidery.JUMP: jump_counter += 1 - if command == pyembroidery.TRIM or jump_counter >=3: + if command == pyembroidery.TRIM or jump_counter >= 3: trim_after = True extents = stitch_plan.extents -- cgit v1.2.3 From 1b18d915a91f838dce7126d80674e3207efe6374 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sat, 6 Jul 2019 11:24:56 +0200 Subject: use get_pattern_interpolate_trim This has the same inaccuracy as the previous version, but we can actually use a pyembroidery function to turn a specific number of jumps into trims. --- lib/extensions/input.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'lib/extensions/input.py') diff --git a/lib/extensions/input.py b/lib/extensions/input.py index a8402fdc..bfb488f1 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -12,6 +12,7 @@ class Input(object): def affect(self, args): embroidery_file = args[0] pattern = pyembroidery.read(embroidery_file) + pattern = pattern.get_pattern_interpolate_trim(2) stitch_plan = StitchPlan() color_block = None @@ -19,20 +20,14 @@ class Input(object): for raw_stitches, thread in pattern.get_as_colorblocks(): color_block = stitch_plan.new_color_block(thread) trim_after = False - jump_counter = 0 for x, y, command in raw_stitches: if command == pyembroidery.STITCH: if trim_after: color_block.add_stitch(trim=True) trim_after = False color_block.add_stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0) - jump_counter = 0 - elif len(color_block) > 0: - # some file formats use 3 or more jump stitches in a row to indicate a trim - if command == pyembroidery.JUMP: - jump_counter += 1 - if command == pyembroidery.TRIM or jump_counter >= 3: - trim_after = True + if len(color_block) > 0 and command == pyembroidery.TRIM: + trim_after = True extents = stitch_plan.extents svg = etree.Element("svg", nsmap=inkex.NSS, attrib={ -- cgit v1.2.3 From fccefb3e0d9cf9a512983e3dbf4927ade1867f81 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 7 Jul 2019 15:55:48 +0200 Subject: rescue VP3 --- lib/extensions/input.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/extensions/input.py') diff --git a/lib/extensions/input.py b/lib/extensions/input.py index bfb488f1..53961e91 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -18,7 +18,8 @@ class Input(object): color_block = None for raw_stitches, thread in pattern.get_as_colorblocks(): - color_block = stitch_plan.new_color_block(thread) + if len(raw_stitches) > 1: + color_block = stitch_plan.new_color_block(thread) trim_after = False for x, y, command in raw_stitches: if command == pyembroidery.STITCH: -- cgit v1.2.3 From 0cd562a4fcfe7ddec45103cf417e14409e378bff Mon Sep 17 00:00:00 2001 From: Momo Date: Sun, 7 Jul 2019 16:25:21 +0200 Subject: delete empty color block --- lib/extensions/input.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/extensions/input.py') 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), -- cgit v1.2.3 From cff12ce18ff94a4d7b779b3c7063eb6b82afa526 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 9 Jul 2019 20:39:07 -0400 Subject: remove all empty color blocks --- lib/extensions/input.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/extensions/input.py') diff --git a/lib/extensions/input.py b/lib/extensions/input.py index 826e7e04..03148832 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -1,11 +1,12 @@ import os +import pyembroidery + from inkex import etree import inkex -import pyembroidery +from ..stitch_plan import StitchPlan from ..svg import PIXELS_PER_MM, render_stitch_plan from ..svg.tags import INKSCAPE_LABEL -from ..stitch_plan import StitchPlan class Input(object): @@ -29,7 +30,7 @@ class Input(object): if len(color_block) > 0 and command == pyembroidery.TRIM: trim_after = True - stitch_plan.delete_empty_color_block(color_block) + stitch_plan.delete_empty_color_blocks() extents = stitch_plan.extents svg = etree.Element("svg", nsmap=inkex.NSS, attrib={ -- cgit v1.2.3 From 7ce4387ff6f8d4302ff374921d0b93b7b491b9a5 Mon Sep 17 00:00:00 2001 From: Momo Date: Wed, 10 Jul 2019 08:08:39 +0200 Subject: trim >= 3 jumps --- lib/extensions/input.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/extensions/input.py') diff --git a/lib/extensions/input.py b/lib/extensions/input.py index 03148832..a82cdfca 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -13,7 +13,7 @@ class Input(object): def affect(self, args): embroidery_file = args[0] pattern = pyembroidery.read(embroidery_file) - pattern = pattern.get_pattern_interpolate_trim(2) + pattern = pattern.get_pattern_interpolate_trim(3) stitch_plan = StitchPlan() color_block = None -- cgit v1.2.3