Added ability to fix "stroke style" for laser cutting

This commit is contained in:
Mario Voigt 2020-12-16 14:01:01 +01:00
parent 559ecb6d9e
commit 02c98d0b79
2 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Fix Global Stroke Width / Opacity</name>
<name>Fix Global Stroke Width / Opacity / Style</name>
<id>fablabchemnitz.de.cleanup</id>
<param name="stroke_width" type="float" precision="4" min="0" max="5" gui-text="Stroke width">0.1</param>
<param name="stroke_units" gui-text="Units" type="optiongroup" appearance="combo">
@ -11,6 +11,7 @@
<option value="mm">mm</option>
</param>
<param name="opacity" type="float" precision="1" min="0" max="100" gui-text="Opacity (%)">100.0</param>
<param name="remove_styles" type="bool" gui-text="Remove stroke styles">true</param>
<effect needs-live-preview="true">
<object-type>all</object-type>
<effects-menu>

View File

@ -26,6 +26,7 @@ class Cleanup(inkex.Effect):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--stroke_width", type=float, default=0.1, help="Stroke width")
self.arg_parser.add_argument("--stroke_units", default="mm", help="Stroke unit")
self.arg_parser.add_argument("--remove_styles", default="mm", help="Remove stroke styles")
self.arg_parser.add_argument("--opacity", type=float, default="100.0", help="Opacity")
def effect(self):
@ -56,6 +57,16 @@ class Cleanup(inkex.Effect):
if prop == 'stroke-opacity':
new_val = str(self.options.opacity / 100)
declarations[i] = prop + ':' + new_val
if prop == 'stroke-dasharray':
declarations[i] = ''
if prop == 'stroke-dashoffset':
declarations[i] = ''
if prop == 'stroke-linejoin':
declarations[i] = ''
if prop == 'stroke-linecap':
declarations[i] = ''
if prop == 'stroke-miterlimit':
declarations[i] = ''
node.set('style', ';'.join(declarations))
if __name__ == '__main__':