Skip to content

Commit 1eea480

Browse files
authored
pyembroidery-CLI
1 parent 83494c0 commit 1eea480

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

mass_convert.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from pyembroidery import *
2+
3+
for file_stream in os.listdir("convert"):
4+
convert_file = os.path.join("convert", file_stream)
5+
pattern = read(convert_file)
6+
if pattern is None:
7+
continue
8+
pattern = pattern.get_pattern_interpolate_trim(3)
9+
# pattern = pattern.get_pattern_merge_jumps()
10+
for emb_format in supported_formats():
11+
if emb_format.get('writer', None) is None:
12+
continue
13+
results_file = os.path.join("results", file_stream) + \
14+
'.' + emb_format["extension"]
15+
if emb_format["extension"] == "csv":
16+
write(pattern, results_file, {"encode": False, "deltas": True})
17+
else:
18+
# write(pattern, results_file, {"pes version": 6, "truncated": True})
19+
write(pattern, results_file, {})

pyembroidery-convert.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import print_function
2+
3+
import sys
4+
from pyembroidery import *
5+
6+
if len(sys.argv) <= 1:
7+
print("No command arguments")
8+
exit(1)
9+
input_file = sys.argv[1]
10+
if len(sys.argv) >= 3:
11+
output_file = sys.argv[2]
12+
else:
13+
output_file = input_file + ".csv"
14+
pattern = read(input_file)
15+
write = write(pattern, output_file)

pyembroidery-exporter.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from __future__ import print_function
2+
3+
import sys
4+
from pyembroidery import *
5+
6+
if len(sys.argv) <= 1:
7+
print("No command arguments")
8+
exit(1)
9+
input_file = sys.argv[1]
10+
pattern = read(input_file)
11+
12+
write(pattern, input_file + ".dst")
13+
write(pattern, input_file + ".exp")
14+
write(pattern, input_file + ".vp3")
15+
write(pattern, input_file + ".pes")
16+
write(pattern, input_file + ".jef")
17+
write(pattern, input_file + ".u01")

stitch_entry_pmv.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from __future__ import print_function
2+
3+
from pyembroidery import *
4+
5+
6+
def value_input(prompt):
7+
try:
8+
return str(raw_input(prompt))
9+
except NameError:
10+
return str(input(prompt))
11+
12+
13+
pattern = EmbPattern()
14+
while True:
15+
triple = False
16+
prompt = value_input("(T)riple/(S)ingle/(Q)uit?")
17+
if "t" in prompt or "T" in prompt:
18+
triple = True
19+
if "s" in prompt or "S" in prompt:
20+
triple = False
21+
if "q" in prompt or "Q" in prompt:
22+
break
23+
while True:
24+
needle_position = value_input(" - :")
25+
try:
26+
int_needle = int(needle_position)
27+
except ValueError:
28+
break
29+
fabric_position = value_input(" | : ")
30+
try:
31+
int_fabric = int(fabric_position)
32+
except ValueError:
33+
break
34+
int_needle -= 7
35+
int_needle *= 2
36+
pattern.stitch_abs(int_fabric * 2.5, int_needle * 2.5)
37+
if triple:
38+
try:
39+
previous = pattern.stitches[-2]
40+
pattern.stitch_abs(previous[0], previous[1])
41+
pattern.stitch_abs(int_fabric * 2.5, int_needle * 2.5)
42+
except IndexError:
43+
pass
44+
45+
filename = value_input("Filename? ")
46+
if filename is None:
47+
filename = "stitch.pmv"
48+
if filename[:3] != 'pmv':
49+
filename += '.pmv'
50+
write(pattern, filename)

0 commit comments

Comments
 (0)