Combining .pes files into a new design
Closed this issue · 3 comments
I have an alphabet of .pes files that I'm trying to arrange as monograms. For instance, say that I needed to generate the monogram ABC, I would like to combine the A.pes, B.pes, and C.pes files together into one ABC.pes file. The spacing doesn't have to be exact just saving 3 letters in the same file would be a fine start.
Is there a way to do this in pyembroidery?
This is my first time working with this library or embroidery in general, so any help is appreciated!
Thanks in advance!
Yes. You can do that with pyembroidery. Load up two patterns and add them together. You can also do this applying an offset so they work together fairly reasonably.
def add_pattern(self, pattern, dx=None, dy=None, sx=None, sy=None, rotate=None):
"""
add_pattern merges the given pattern with the current pattern. It accounts for some edge conditions but
not all of them.
If there is an end command on the current pattern, that is removed.
If the color ending the current pattern is equal to the color starting the next those color blocks are merged.
Any prepended thread change command to the merging pattern is suppressed.
:param pattern: pattern to add to current pattern
:param dx: position change of the added pattern x
:param dy: position change of the added pattern y
:param sx: scale of the added pattern x
:param sy: scale of the added pattern y
:param rotate: rotation of the added pattern
:return:
"""
So yeah, add_pattern is your best option there. You can add the other patterns offset by a value there. So:
a = EmbPattern("A.pes")
b = EmbPattern("B.pes")
a.add_pattern(b, dx=0, dy=200)
or something like that.
Actually it's likely easier to add the pattern with the name.
q = EmbPattern('A.pes')
q.add_pattern('B.pes', dx=500)
q.write('AB.pes')
So,
q = EmbPattern('duck.pes')
q.add_pattern('duck.pes', dx=500, sx=.8, rotate=22)
q.add_pattern('duck.pes', dx=500, sx=.8, rotate=22)
q.add_pattern('duck.pes', dx=500, sx=.8, rotate=22)
q.write('myy.png')
That's great! Thanks for your help!