From b932f6a4439718416adf781510f4f19eddca2137 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Mon, 12 Dec 2022 18:36:02 +0100 Subject: fix #1936 (#1955) --- lib/extensions/cutwork_segmentation.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/cutwork_segmentation.py b/lib/extensions/cutwork_segmentation.py index 672aeade..22b39e4b 100644 --- a/lib/extensions/cutwork_segmentation.py +++ b/lib/extensions/cutwork_segmentation.py @@ -61,9 +61,9 @@ class CutworkSegmentation(InkstitchExtension): self.sectors = {index: sector for index, sector in self.sectors.items() if sector['start'] != sector['end']} self.new_elements = [] + parent = None for element in self.elements: if isinstance(element, Stroke): - # save parent and index to be able to position and insert new elements later on parent = element.node.getparent() index = parent.index(element.node) @@ -73,8 +73,11 @@ class CutworkSegmentation(InkstitchExtension): # fill self.new_elements list with line segments self._prepare_line_sections(element, linestring.coords) - self._insert_elements(parent, element, index) + if parent is None: + inkex.errormsg(_("Please select at least one element with a stroke color.")) + return + self._insert_elements(parent, index) self._remove_originals() def _get_sectors(self, angle): @@ -150,7 +153,7 @@ class CutworkSegmentation(InkstitchExtension): # clear point_list in self.sectors self.sectors[sector['id']].update({'point_list': []}) - def _insert_elements(self, parent, element, index): + def _insert_elements(self, parent, index): self.new_elements.reverse() if self.options.sort_by_color is True: self.new_elements = sorted(self.new_elements, key=lambda x: x[1], reverse=True) -- cgit v1.2.3