diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-08-17 17:27:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-17 17:27:29 +0200 |
| commit | 5e387d76a77d9f4a780a4e8ee4ac9f88f842f512 (patch) | |
| tree | 9114deb82d01505c56174a6e54666d85b644cc40 /lib | |
| parent | 45c873a3040bb0837ada8fbfab323d189b2a8a2f (diff) | |
satin troubleshoot: do not fail on satins without rails (#3148)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/elements/satin_column.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index 7c29729d..912dad4b 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -752,15 +752,24 @@ class SatinColumn(EmbroideryElement): yield ClosedPathWarning(self.flattened_rails[0].coords[0]) def validation_errors(self): - # The node should have exactly two paths with the same number of points - or it should - # have two rails and at least one rung - if len(self.csp) < 2: - yield TooFewPathsError((0, 0)) - elif len(self.rails) < 2: - yield TooFewPathsError(self.flattened_rails[0].representative_point()) - - if not self.to_stitch_groups(): - yield NotStitchableError(self.flattened_rails[0].representative_point()) + if len(self.flattened_rails) == 0: + # Non existing rails can happen due to insane transforms which reduce the size of the + # satin to zero. The path should still be pointable. + try: + point = self.paths[0][0] + except IndexError: + point = (0, 0) + yield NotStitchableError(point) + else: + # The node should have exactly two paths with the same number of points - or it should + # have two rails and at least one rung + if len(self.csp) < 2: + yield TooFewPathsError((0, 0)) + elif len(self.rails) < 2: + yield TooFewPathsError(self.flattened_rails[0].representative_point()) + + if not self.to_stitch_groups(): + yield NotStitchableError(self.flattened_rails[0].representative_point()) def _center_walk_is_odd(self): return self.center_walk_underlay_repeats % 2 == 1 |
