From ae606c6518e0ffb09aa6be8163abd18e5444d162 Mon Sep 17 00:00:00 2001 From: tatarize Date: Mon, 6 Nov 2023 06:41:37 -0800 Subject: [PATCH 1/2] Cursory 0.3.2 add lock and center options --- README.md | 1 + setup.py | 10 +++++++--- vpype_embroidery/ewrite.py | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e25ade1..85937b8 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ https://github.com/EmbroidePy/pyembroidery * .u01 * .pec * .xxx +* .tbf * .gcode ### Read diff --git a/setup.py b/setup.py index 06ee2f5..23285b8 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, find_packages +from setuptools import setup with open("README.md") as f: @@ -6,7 +6,7 @@ setup( name="vpype-embroidery", - version="0.3.0", + version="0.3.2", description="vpype embroidery plugin", long_description=readme, long_description_content_type="text/markdown", @@ -15,8 +15,12 @@ url="https://github.com/embroidepy/vpype-embroidery/", packages=["vpype_embroidery"], classifiers=[ - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent" ], diff --git a/vpype_embroidery/ewrite.py b/vpype_embroidery/ewrite.py index 4bd3b0e..bdb9670 100644 --- a/vpype_embroidery/ewrite.py +++ b/vpype_embroidery/ewrite.py @@ -1,4 +1,7 @@ +from __future__ import annotations + import click +import pyembroidery import vpype as vp import vpype_cli from pyembroidery import COLOR_BREAK, SEQUENCE_BREAK, STITCH, EmbPattern @@ -19,9 +22,18 @@ type=vpype_cli.TextType(), help="version of embroidery file to write", ) +@click.option( + "-k", "--lock", is_flag=True, help="provide lock-stitches." +) +@click.option( + "-c", "--center", is_flag=True, help="move design center to origin" +) @vpype_cli.global_processor -def ewrite(document: vp.Document, filename: str, version: str): +def ewrite(document: vp.Document, filename: str, version: str, lock: bool, center: bool): pattern = EmbPattern() + if lock: + pattern.add_command(pyembroidery.CONTINGENCY_TIE_ON_THREE_SMALL) + pattern.add_command(pyembroidery.CONTINGENCY_TIE_OFF_THREE_SMALL) for layer in document.layers.values(): for p in layer: m = p * _PX_PER_EMB @@ -29,6 +41,11 @@ def ewrite(document: vp.Document, filename: str, version: str): pattern.add_stitch_absolute(STITCH, int(v.real), int(v.imag)) pattern.add_command(SEQUENCE_BREAK) pattern.add_command(COLOR_BREAK) + if center: + extends = pattern.bounds() + cx = round((extends[2] + extends[0]) / 2.0) + cy = round((extends[3] + extends[1]) / 2.0) + pattern.translate(-cx, -cy) if version is not None: pattern.write(filename, version=version) else: From 812611cba65b2a9a43424e0d780973da7d4271a9 Mon Sep 17 00:00:00 2001 From: tatarize Date: Mon, 6 Nov 2023 07:44:21 -0800 Subject: [PATCH 2/2] Use pyembroidery 1.5.0 --- requirements.txt | 2 +- setup.py | 2 +- vpype_embroidery/ewrite.py | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 0fbce60..4d234bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ click vpype>=1.9,<2.0 numpy -pyembroidery \ No newline at end of file +pyembroidery>=1.5.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 23285b8..f4a31bf 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ "click", "vpype>=1.9,<2.0", "numpy", - "pyembroidery", + "pyembroidery>=1.5.0", ], entry_points=""" [vpype.plugins] diff --git a/vpype_embroidery/ewrite.py b/vpype_embroidery/ewrite.py index bdb9670..3cf2c56 100644 --- a/vpype_embroidery/ewrite.py +++ b/vpype_embroidery/ewrite.py @@ -46,10 +46,13 @@ def ewrite(document: vp.Document, filename: str, version: str, lock: bool, cente cx = round((extends[2] + extends[0]) / 2.0) cy = round((extends[3] + extends[1]) / 2.0) pattern.translate(-cx, -cy) - if version is not None: - pattern.write(filename, version=version) - else: - pattern.write(filename) + try: + if version is not None: + pattern.write(filename, version=version) + else: + pattern.write(filename) + except IOError as e: + print(e) return document