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="fillet">Fillet</_item>
|
||||||
<_item value="chamfer">Chamfer</_item>
|
<_item value="chamfer">Chamfer</_item>
|
||||||
</param>
|
</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>
|
<effect>
|
||||||
<object-type>all</object-type>
|
<object-type>all</object-type>
|
||||||
<effects-menu>
|
<effects-menu>
|
||||||
|
@ -168,6 +168,16 @@ class FilletChamfer(inkex.Effect):
|
|||||||
action="store", type="float",
|
action="store", type="float",
|
||||||
dest="radius", default=60.0,
|
dest="radius", default=60.0,
|
||||||
help="The radius")
|
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):
|
def addEle(self, ele, parent, props):
|
||||||
# https://inkscape.org/~pacogarcia/%E2%98%85new-version-of-shapes-extension
|
# 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)
|
return d_str(new_p, use_closed_attrib=True, rel=True)
|
||||||
|
|
||||||
def effect(self):
|
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:
|
if self.options.radius == 0:
|
||||||
return
|
return
|
||||||
@ -289,6 +299,9 @@ class FilletChamfer(inkex.Effect):
|
|||||||
attrib['d'] = self.add_fillet_to_path(attrib['d'])
|
attrib['d'] = self.add_fillet_to_path(attrib['d'])
|
||||||
self.addEle(inkex.addNS('path','svg'), node.getparent(), attrib)
|
self.addEle(inkex.addNS('path','svg'), node.getparent(), attrib)
|
||||||
|
|
||||||
|
if self.options.remove:
|
||||||
|
node.getparent().remove(node)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
e = FilletChamfer()
|
e = FilletChamfer()
|
||||||
e.affect()
|
e.affect()
|
||||||
|
Reference in New Issue
Block a user