summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/commands.py2
-rw-r--r--lib/extensions/letters_to_font.py18
-rw-r--r--lib/extensions/zigzag_line_to_satin.py16
-rw-r--r--lib/threads/color.py6
4 files changed, 31 insertions, 11 deletions
diff --git a/lib/commands.py b/lib/commands.py
index d93954ec..8c43aed3 100644
--- a/lib/commands.py
+++ b/lib/commands.py
@@ -124,6 +124,8 @@ class Command(BaseCommand):
def parse_command(self):
path = self.parse_connector_path()
+ if len(path) == 0:
+ raise CommandParseError("connector has no path information")
neighbors = [
(self.get_node_by_url(self.connector.get(CONNECTION_START)), path[0][0][1]),
diff --git a/lib/extensions/letters_to_font.py b/lib/extensions/letters_to_font.py
index 56a33ad8..d4d9e60a 100644
--- a/lib/extensions/letters_to_font.py
+++ b/lib/extensions/letters_to_font.py
@@ -39,6 +39,7 @@ class LettersToFont(InkstitchExtension):
glyphs = list(Path(font_dir).rglob(file_format.lower()))
document = self.document.getroot()
+ group = None
for glyph in glyphs:
letter = self.get_glyph_element(glyph)
label = "GlyphLayer-%s" % letter.get(INKSCAPE_LABEL, ' ').split('.')[0][-1]
@@ -59,15 +60,20 @@ class LettersToFont(InkstitchExtension):
document.insert(0, group)
group.set('style', 'display:none')
+ # We found no glyphs, no need to proceed
+ if group is None:
+ return
+
# users may be confused if they get an empty document
# make last letter visible again
group.set('style', None)
- # In most cases trims are inserted with the imported letters.
- # Let's make sure the trim symbol exists in the defs section
- ensure_symbol(document, 'trim')
+ if self.options.import_commands == "symbols":
+ # In most cases trims are inserted with the imported letters.
+ # Let's make sure the trim symbol exists in the defs section
+ ensure_symbol(document, 'trim')
- self.insert_baseline(document)
+ self.insert_baseline()
def get_glyph_element(self, glyph):
stitch_plan = generate_stitch_plan(str(glyph), self.options.import_commands)
@@ -77,5 +83,5 @@ class LettersToFont(InkstitchExtension):
stitch_plan.attrib.pop(INKSCAPE_GROUPMODE)
return stitch_plan
- def insert_baseline(self, document):
- document.namedview.add_guide(position=0.0, name="baseline")
+ def insert_baseline(self):
+ self.svg.namedview.add_guide(position=0.0, name="baseline")
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 = []
diff --git a/lib/threads/color.py b/lib/threads/color.py
index c75778d2..44fa709c 100644
--- a/lib/threads/color.py
+++ b/lib/threads/color.py
@@ -17,10 +17,10 @@ class ThreadColor(object):
'''
avoid error messages:
* set colors with a gradient to black
- * currentColor should not just be black, but we want to avoid error messages
- until inkex will be able to handle this css property
+ * currentColor/context-fill/context-stroke: should not just be black, but we want to avoid
+ error messages until inkex will be able to handle these css properties
'''
- if type(color) == str and color.startswith(('url', 'currentColor')):
+ if type(color) == str and color.startswith(('url', 'currentColor', 'context')):
color = None
elif type(color) == str and color.startswith('rgb'):
color = tuple(int(value) for value in color[4:-1].split(','))