EmbroidePy / pyembroidery

pyembroidery library for reading and writing a variety of embroidery formats.
MIT License
181 stars 33 forks source link

Brother embroiderer wants to embroid exported PES three times #139

Open mmeester opened 2 years ago

mmeester commented 2 years ago

For a small project, I'm trying to autogenerate names from files where each letter has it's own file. So for example, I would like to generate the name of Jan, I need the following files and put them into one pattern:

# Start a blank canvas
pattern = EmbPattern()
# Set first stich to add the rest of the letters to the canvas
pattern.add_block([(0, 0)], "black")

J = read_pes("font/707xxxxxxSMj.pes")
# Coordinates are off but that doesn't matter for this demo
pattern.add_pattern(J, 0, 0)

a = read_pes("font/707xxxxxxSMa.pes")
pattern.add_pattern(a, 0, 0)

n = read_pes("font/707xxxxxxSMn.pes")
pattern.add_pattern(n, 0, 0)

write_pes(pattern, 'Jan.pes')

When running Jan.pes through a stitching simulator (on my mac) it looks like the file is only stitched once, but when loading it into our Brother Embroidery machine it starts stitching it three times in total ending at the n moving back to the J and again.

This happens with all names, not only three letter words but also 7 letters the machine is stitching the file 3 times.

Another fact is that a .dst is only embroided once but is missing the nice preview on our Brother machine which makes it a lot harder to position the name on a piece of cloth.

The resulted png is: Jan

The Jan.pes file can be found here: https://www.dropbox.com/s/ocvqgwbcciensly/Jan.pes?dl=0

tatarize commented 2 years ago

Sorry for the delay in replying. Simulation in brother's software says one time stitching.

https://user-images.githubusercontent.com/3302478/165318933-48f9e8ef-2180-4c8a-b5d4-e93045feef1f.mp4

Ah, I see. The file contains what is called a bean stitch. Basically for each segment it goes forward and back for each of them. You can see here stitches 60 to 80 that we go and duplicate stitch 61 with 63. This isn't something that pyembroidery does, it wouldn't be a bad idea to allow you to apply a bean stitch of a pattern but this data is loaded from the original embroidery font files.

If I'm wrong feel free to provide me the J a or n files for verification. Pyembroidery would require you script a bean stitch yourself and could not do one for you.


60: Stitch 6 21
61: Stitch 0 -20
62: Stitch -1 20
63: Stitch 0 -20
64: Stitch 0 20
65: Stitch 1 -20
66: Stitch 0 20
67: Stitch 1 -21
68: Stitch 0 21
69: Stitch 0 19
70: Stitch -8 -19
71: Stitch 6 18
72: Stitch -7 -18
73: Stitch 8 18
74: Stitch -8 -18
75: Stitch 8 19
76: Stitch -6 -18
77: Stitch 8 18
78: Stitch -9 -11
79: Stitch 19 12
80: Stitch -17 -11