Added option to select unit and to remove initial object
This commit is contained in:
parent
6bde5301c2
commit
a6f2d5bd9b
@ -8,7 +8,14 @@
|
||||
<_item value="fillet">Fillet</_item>
|
||||
<_item value="chamfer">Chamfer</_item>
|
||||
</param>
|
||||
<param name="radius" type="float" min="0.0" max="1000.0" _gui-text="Radius (px):">20.0</param>
|
||||
<param name="radius" type="float" min="0.0" max="1000.0" _gui-text="Radius:">5.0</param>
|
||||
<param name="unit" _gui-text="Unit" type="enum">
|
||||
<_item value="mm">mm</_item>
|
||||
<_item value="cm">cm</_item>
|
||||
<_item value="in">in</_item>
|
||||
<_item value="px">px</_item>
|
||||
</param>
|
||||
<param name="remove" type="boolean" _gui-text="Remove control object">false</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
|
@ -168,6 +168,16 @@ class FilletChamfer(inkex.Effect):
|
||||
action="store", type="float",
|
||||
dest="radius", default=60.0,
|
||||
help="The radius")
|
||||
self.OptionParser.add_option('--unit',
|
||||
action='store',
|
||||
type='string',
|
||||
dest='unit',
|
||||
default='px',
|
||||
help='units of measurement')
|
||||
self.OptionParser.add_option("--remove",
|
||||
action="store", type="inkbool",
|
||||
dest="remove", default=False,
|
||||
help="If True, control object will be removed")
|
||||
|
||||
def addEle(self, ele, parent, props):
|
||||
# https://inkscape.org/~pacogarcia/%E2%98%85new-version-of-shapes-extension
|
||||
@ -274,7 +284,7 @@ class FilletChamfer(inkex.Effect):
|
||||
return d_str(new_p, use_closed_attrib=True, rel=True)
|
||||
|
||||
def effect(self):
|
||||
self.options.radius = self.unittouu(str(self.options.radius) + 'px')
|
||||
self.options.radius = self.unittouu(str(self.options.radius) + self.options.unit)
|
||||
|
||||
if self.options.radius == 0:
|
||||
return
|
||||
@ -289,6 +299,9 @@ class FilletChamfer(inkex.Effect):
|
||||
attrib['d'] = self.add_fillet_to_path(attrib['d'])
|
||||
self.addEle(inkex.addNS('path','svg'), node.getparent(), attrib)
|
||||
|
||||
if self.options.remove:
|
||||
node.getparent().remove(node)
|
||||
|
||||
if __name__ == '__main__':
|
||||
e = FilletChamfer()
|
||||
e.affect()
|
||||
|
Reference in New Issue
Block a user