From 5e387d76a77d9f4a780a4e8ee4ac9f88f842f512 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sat, 17 Aug 2024 17:27:29 +0200 Subject: satin troubleshoot: do not fail on satins without rails (#3148) --- lib/elements/satin_column.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'lib/elements/satin_column.py') 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 -- cgit v1.2.3