kopia lustrzana https://github.com/inkstitch/inkstitch
add 'Embroider Params' extension to set XML attributes on svg nodes
rodzic
acd9db29d3
commit
cf2db11d60
|
@ -28,7 +28,7 @@
|
|||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu _name="Render"/>
|
||||
<submenu _name="Embroidery"/>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
|
|
|
@ -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>
|
|
@ -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()
|
Ładowanie…
Reference in New Issue