Skip to content

Instantly share code, notes, and snippets.

@jacobian
Last active July 15, 2019 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobian/5b0d04d0a58a6b236e3fa172a969fac5 to your computer and use it in GitHub Desktop.
Save jacobian/5b0d04d0a58a6b236e3fa172a969fac5 to your computer and use it in GitHub Desktop.
import pyembroidery as em
pattern = em.EmbPattern()
# units are in 1/10mm
# max size in DST is 12mm so if we go bigger need to fuck with max_stitch
SIZE = 32
# start with a stitch at the origin to get the needle down (see the docs)
pattern.stitch_abs(0, 0)
# stitch a 10x10 block
# do y first so we stitch across then down
# this doesn't really matter though
for y in range(5):
for x in range(5):
# A single stitch:
#
# 1 4 1. jump to start of stitch (1)
# \ / 2. 1. stitch diagonal down (1 -> 2)
# \/ 3. jump back left (2 -> 3)
# /\ 4. stitch diagonal up (3 -> 4) - next stitch starts here usually
# / \
# 3 -- 2 remember: +x is to the right, +y is down
pattern.move_abs(x * SIZE, y * SIZE) # <--- this sucks at the end of a row, generates a huge jump :(
pattern.stitch(SIZE, SIZE)
pattern.move(-SIZE, 0)
pattern.stitch(SIZE, -SIZE)
# XXX repeat a few times?
# causes difficulty in stitch routing
# tie off and cut (don't know if cut works)
pattern.stitch(0, 0)
pattern.trim()
pattern.end()
em.write_pes(pattern, "pattern.pes")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment