fixes and ehancements in tab generator
This commit is contained in:
parent
b9e6eeba2c
commit
d9922309c2
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||||
<name>Tabgen</name>
|
<name>Tab Generator</name>
|
||||||
<id>fablabchemnitz.de.tabgen</id>
|
<id>fablabchemnitz.de.tab_generator</id>
|
||||||
<param name="usermenu" type="notebook">
|
<param name="usermenu" type="notebook">
|
||||||
<page name="settings" gui-text="Settings">
|
<page name="settings" gui-text="Settings">
|
||||||
<param name="tabangle" type="float" min="0.0" max="90.0" gui-text="Angle of tab edges (degrees):">45.0</param>
|
<param name="tabangle" type="float" min="0.0" max="90.0" gui-text="Angle of tab edges (degrees):">45.0</param>
|
||||||
@ -23,6 +23,9 @@
|
|||||||
<option value="ft">ft</option>
|
<option value="ft">ft</option>
|
||||||
<option value="yd">yd</option>
|
<option value="yd">yd</option>
|
||||||
</param>
|
</param>
|
||||||
|
<param name="strokewidth" min="0.0" max="10000.0" precision="3" gui-text="Stroke width (px)" type="float">1.0</param>
|
||||||
|
<param name="color_solid" type="color" appearance="colorbutton" gui-text="Solid line color">3419879935</param>
|
||||||
|
<param name="color_dash" type="color" appearance="colorbutton" gui-text="Dash line color">1592519679</param>
|
||||||
<param name="print_debug" type="bool" gui-text="Print debug info">true</param>
|
<param name="print_debug" type="bool" gui-text="Print debug info">true</param>
|
||||||
<param name="keep_original" type="bool" gui-text="Keep original elements">false</param>
|
<param name="keep_original" type="bool" gui-text="Keep original elements">false</param>
|
||||||
</page>
|
</page>
|
||||||
@ -33,10 +36,12 @@
|
|||||||
<effect needs-live-preview="true">
|
<effect needs-live-preview="true">
|
||||||
<object-type>all</object-type>
|
<object-type>all</object-type>
|
||||||
<effects-menu>
|
<effects-menu>
|
||||||
<submenu name="Papercraft" />
|
<submenu name="FabLab Chemnitz">
|
||||||
|
<submenu name="Paper/Cardboard Boxes"/>
|
||||||
|
</submenu>
|
||||||
</effects-menu>
|
</effects-menu>
|
||||||
</effect>
|
</effect>
|
||||||
<script>
|
<script>
|
||||||
<command location="inx" interpreter="python">tabgen.py</command>
|
<command location="inx" interpreter="python">tab_generator.py</command>
|
||||||
</script>
|
</script>
|
||||||
</inkscape-extension>
|
</inkscape-extension>
|
@ -22,7 +22,7 @@ tabs and score lines for each straight edge.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import inkex
|
import inkex
|
||||||
from inkex import Path
|
from inkex import Path, Color
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import math
|
import math
|
||||||
import copy
|
import copy
|
||||||
@ -77,6 +77,9 @@ class Tabgen(inkex.EffectExtension):
|
|||||||
pars.add_argument("--dashlength", type=float, default=0.25, help="Length of dashline in dimentional units (zero for solid line)")
|
pars.add_argument("--dashlength", type=float, default=0.25, help="Length of dashline in dimentional units (zero for solid line)")
|
||||||
pars.add_argument("--tabsets", default="both", help="Tab placement on polygons with cutouts")
|
pars.add_argument("--tabsets", default="both", help="Tab placement on polygons with cutouts")
|
||||||
pars.add_argument("--unit", default="in", help="Dimensional units of selected paths")
|
pars.add_argument("--unit", default="in", help="Dimensional units of selected paths")
|
||||||
|
pars.add_argument("--strokewidth", type=float, default=1.0, help="Stroke width (px)")
|
||||||
|
pars.add_argument("--color_solid", type=Color, default='3419879935', help="Solid line color")
|
||||||
|
pars.add_argument("--color_dash", type=Color, default='1592519679', help="Solid line dash")
|
||||||
pars.add_argument("--print_debug", type=inkex.Boolean, default=True, help="Print debug info")
|
pars.add_argument("--print_debug", type=inkex.Boolean, default=True, help="Print debug info")
|
||||||
pars.add_argument("--keep_original", type=inkex.Boolean, default=False, help="Keep original elements")
|
pars.add_argument("--keep_original", type=inkex.Boolean, default=False, help="Keep original elements")
|
||||||
|
|
||||||
@ -489,6 +492,7 @@ class Tabgen(inkex.EffectExtension):
|
|||||||
|
|
||||||
|
|
||||||
def effect(self):
|
def effect(self):
|
||||||
|
|
||||||
scale = self.svg.unittouu('1'+self.options.unit)
|
scale = self.svg.unittouu('1'+self.options.unit)
|
||||||
layer = self.svg.get_current_layer()
|
layer = self.svg.get_current_layer()
|
||||||
tab_angle = float(self.options.tabangle)
|
tab_angle = float(self.options.tabangle)
|
||||||
@ -499,6 +503,11 @@ class Tabgen(inkex.EffectExtension):
|
|||||||
savid = ''
|
savid = ''
|
||||||
elems = []
|
elems = []
|
||||||
pc = 0
|
pc = 0
|
||||||
|
|
||||||
|
solidLineStyle = {'stroke': str(self.options.color_solid), 'fill': 'none', 'stroke-width': self.options.strokewidth}
|
||||||
|
dashLineStyle = {'stroke': str(self.options.color_dash), 'fill': 'none', 'stroke-width': self.options.strokewidth}
|
||||||
|
|
||||||
|
|
||||||
for selem in self.svg.selection.filter(inkex.PathElement):
|
for selem in self.svg.selection.filter(inkex.PathElement):
|
||||||
elems.append(selem)
|
elems.append(selem)
|
||||||
if len(elems) == 0:
|
if len(elems) == 0:
|
||||||
@ -557,6 +566,7 @@ class Tabgen(inkex.EffectExtension):
|
|||||||
else:
|
else:
|
||||||
raise inkex.AbortExtension("Unrecognized path command {0}".format(ptoken.letter))
|
raise inkex.AbortExtension("Unrecognized path command {0}".format(ptoken.letter))
|
||||||
npath.path.append(inkex.paths.Line(ptx2,pty2))
|
npath.path.append(inkex.paths.Line(ptx2,pty2))
|
||||||
|
npath.style = solidLineStyle
|
||||||
if ptoken.letter == 'Z':
|
if ptoken.letter == 'Z':
|
||||||
npaths.append(npath)
|
npaths.append(npath)
|
||||||
else:
|
else:
|
Reference in New Issue
Block a user