diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-03-26 07:10:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-26 07:10:40 +0100 |
| commit | 8e70f3d2feaab8a14f775a5ef84002bdab9688f0 (patch) | |
| tree | f34d46ead8eb8d15317dc98de4113ccaf8acd0e9 /lib/stitch_plan/stitch_group.py | |
| parent | ea394f6d3b7de3bc0818b6a9921f64e8bcbc4fbf (diff) | |
Add object based min stitch length (#2792)
* add object based min stitch length (overwrites global)
* add object based minimum jump stitch (overwrites global)
* rename patches to stitch_groups
Diffstat (limited to 'lib/stitch_plan/stitch_group.py')
| -rw-r--r-- | lib/stitch_plan/stitch_group.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/stitch_plan/stitch_group.py b/lib/stitch_plan/stitch_group.py index c85fc5f5..0730101c 100644 --- a/lib/stitch_plan/stitch_group.py +++ b/lib/stitch_plan/stitch_group.py @@ -17,8 +17,17 @@ class StitchGroup: between them by the stitch plan generation code. """ - def __init__(self, color=None, stitches=None, trim_after=False, stop_after=False, - lock_stitches=(None, None), force_lock_stitches=False, tags=None): + def __init__( + self, + color=None, + stitches=None, + min_jump_stitch_length=False, + trim_after=False, + stop_after=False, + lock_stitches=(None, None), + force_lock_stitches=False, + tags=None + ): # DANGER: if you add new attributes, you MUST also set their default # values in __new__() below. Otherwise, cached stitch plans can be # loaded and create objects without those properties defined, because @@ -29,6 +38,7 @@ class StitchGroup: self.stop_after = stop_after self.lock_stitches = lock_stitches self.force_lock_stitches = force_lock_stitches + self.min_jump_stitch_length = min_jump_stitch_length self.stitches = [] if stitches: @@ -55,9 +65,13 @@ class StitchGroup: raise TypeError("StitchGroup can only be added to another StitchGroup") def __len__(self): - # This method allows `len(patch)` and `if patch: + # This method allows `len(stitch_group)` and `if stitch_group: return len(self.stitches) + def set_minimum_stitch_length(self, min_stitch_length): + for stitch in self.stitches: + stitch.min_stitch_length = min_stitch_length + def add_stitches(self, stitches, tags=None): for stitch in stitches: self.add_stitch(stitch, tags=tags) @@ -66,7 +80,6 @@ class StitchGroup: if not isinstance(stitch, Stitch): # probably a Point stitch = Stitch(stitch, tags=tags) - self.stitches.append(stitch) def reverse(self): |
