summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embroider.inx2
-rw-r--r--embroider_params.inx23
-rw-r--r--embroider_params.py44
3 files changed, 68 insertions, 1 deletions
diff --git a/embroider.inx b/embroider.inx
index d2682eba..ec2b08c3 100644
--- a/embroider.inx
+++ b/embroider.inx
@@ -28,7 +28,7 @@
<effect>
<object-type>all</object-type>
<effects-menu>
- <submenu _name="Render"/>
+ <submenu _name="Embroidery"/>
</effects-menu>
</effect>
<script>
diff --git a/embroider_params.inx b/embroider_params.inx
new file mode 100644
index 00000000..7e92e6a8
--- /dev/null
+++ b/embroider_params.inx
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Params</_name>
+ <id>jonh.embroider.params</id>
+ <dependency type="executable" location="extensions">embroider_params.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="zigzag_spacing" type="string" _gui-text="Zigzag spacing (pixels)"></param>
+ <param name="running_stitch_length" type="string" _gui-text="Running stitch length (pixels)"></param>
+ <param name="row_spacing" type="string" _gui-text="Row spacing (pixels)"></param>
+ <param name="max_stitch_length" type="string" _gui-text="Maximum stitch length (pixels)"></param>
+ <param name="repeats" type="string" _gui-text="Repeats (stroke only)"></param>
+ <param name="angle" type="string" _gui-text="Angle for lines in fills"></param>
+ <param name="hatching" type="string" _gui-text="Hatching? (yes/no)"></param>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Embroidery"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">embroider_params.py</command>
+ </script>
+</inkscape-extension>
diff --git a/embroider_params.py b/embroider_params.py
new file mode 100644
index 00000000..648c9744
--- /dev/null
+++ b/embroider_params.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+#
+# Set embroidery parameter attributes on all selected objects. If an option
+# value is blank, the parameter is created as blank on all objects that don't
+# already have it. If an option value is given, any existing node parameter
+# values are overwritten on all selected objects.
+
+import sys
+sys.path.append("/usr/share/inkscape/extensions")
+import os
+import inkex
+
+
+class EmbroiderParams(inkex.Effect):
+ def __init__(self, *args, **kwargs):
+ inkex.Effect.__init__(self)
+
+ self.params = ["zigzag_spacing",
+ "running_stitch_length",
+ "row_spacing",
+ "max_stitch_length",
+ "repeats",
+ "angle",
+ "hatching",
+ ]
+
+ for param in self.params:
+ self.OptionParser.add_option("--%s" % param, default="")
+
+ def effect(self):
+ for node in self.selected.itervalues():
+ for param in self.params:
+ value = getattr(self.options, param).strip()
+ param = "embroider_" + param
+
+ if node.get(param) is not None and not value:
+ # only overwrite existing params if they gave a value
+ continue
+ else:
+ node.set(param, value)
+
+if __name__ == '__main__':
+ e = EmbroiderParams()
+ e.affect()