summaryrefslogtreecommitdiff
path: root/lib/extensions/zigzag_line_to_satin.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/extensions/zigzag_line_to_satin.py')
-rw-r--r--lib/extensions/zigzag_line_to_satin.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/extensions/zigzag_line_to_satin.py b/lib/extensions/zigzag_line_to_satin.py
index 167f4b91..b71bf6a0 100644
--- a/lib/extensions/zigzag_line_to_satin.py
+++ b/lib/extensions/zigzag_line_to_satin.py
@@ -23,11 +23,12 @@ class ZigzagLineToSatin(InkstitchExtension):
self.arg_parser.add_argument("-l", "--reduce-rungs", type=inkex.Boolean, default=False, dest="reduce_rungs")
def effect(self):
- if not self.svg.selection or not self.get_elements():
+ nodes = self.get_selection(self.svg.selection)
+ if not nodes:
inkex.errormsg(_("Please select at least one stroke to convert to a satin column."))
return
- for node in self.svg.selection:
+ for node in nodes:
d = []
point_list = list(node.get_path().end_points)
# find duplicated nodes (= do not smooth)
@@ -49,6 +50,17 @@ class ZigzagLineToSatin(InkstitchExtension):
node.set('d', " ".join(d))
node.set('inkstitch:satin_column', True)
+ def get_selection(self, nodes):
+ selection = []
+ for node in nodes:
+ # we only apply to path elements, no use in converting ellipses or rectangles, etc.
+ if node.TAG == "path":
+ selection.append(node)
+ elif node.TAG == "g":
+ for element in node.descendants():
+ selection.extend(self.get_selection(element))
+ return selection
+
def _get_sharp_edge_nodes(self, point_list):
points = []
sharp_edges = []