summaryrefslogtreecommitdiff
path: root/embroider.py
diff options
context:
space:
mode:
authorStefan Siegl <stesie@brokenpipe.de>2015-01-03 03:00:02 +0100
committerStefan Siegl <stesie@brokenpipe.de>2015-01-03 03:00:02 +0100
commit65d037d335f044738d5b1a0fcfa9aa6eebd3f4b4 (patch)
treea96fe3482488fbd4745d780d7f5cd74b907f15bf /embroider.py
parent160b08062c6366e7e1f4b1b4b2da94d59c8dab58 (diff)
Fix preamble generation for very short patches
Diffstat (limited to 'embroider.py')
-rw-r--r--embroider.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/embroider.py b/embroider.py
index f038307a..f582487d 100644
--- a/embroider.py
+++ b/embroider.py
@@ -391,18 +391,25 @@ class EmbroideryObject:
i = 0
nextp = PyEmb.Point(patch.stitches[i].x, -patch.stitches[i].y)
- for j in xrange(1, 4):
- if locs[-1] == nextp:
- i += 1
- nextp = PyEmb.Point(patch.stitches[i].x, -patch.stitches[i].y)
- locs.append(self.make_preamble_stitch(locs[-1], nextp))
+ try:
+ for j in xrange(1, 4):
+ if locs[-1] == nextp:
+ i += 1
+ nextp = PyEmb.Point(patch.stitches[i].x, -patch.stitches[i].y)
+ locs.append(self.make_preamble_stitch(locs[-1], nextp))
+ except IndexError:
+ # happens when the patch is very short and we increment i beyond the number of stitches
+ pass
dbg.write("preamble locations: %s\n" % locs)
for j in add_preamble[1:]:
- stitch = deepcopy(locs[int(j)])
- stitch.color = patch.color
- stitch.jumpStitch = False
- emb.addStitch(stitch)
+ try:
+ stitch = deepcopy(locs[int(j)])
+ stitch.color = patch.color
+ stitch.jumpStitch = False
+ emb.addStitch(stitch)
+ except IndexError:
+ pass
jumpStitch = False
lastStitch = newStitch