From a6f2d5bd9b65318c2dc17553e7ea8bc12e5d3b74 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Thu, 14 Nov 2019 22:00:59 +0100 Subject: [PATCH] Added option to select unit and to remove initial object --- extensions/fablabchemnitz_filletchamfer.inx | 9 ++++++++- extensions/fablabchemnitz_filletchamfer.py | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/extensions/fablabchemnitz_filletchamfer.inx b/extensions/fablabchemnitz_filletchamfer.inx index 004b434..85de844 100644 --- a/extensions/fablabchemnitz_filletchamfer.inx +++ b/extensions/fablabchemnitz_filletchamfer.inx @@ -8,7 +8,14 @@ <_item value="fillet">Fillet <_item value="chamfer">Chamfer - 20.0 + 5.0 + + <_item value="mm">mm + <_item value="cm">cm + <_item value="in">in + <_item value="px">px + + false all diff --git a/extensions/fablabchemnitz_filletchamfer.py b/extensions/fablabchemnitz_filletchamfer.py index f297fe8..3ea4292 100644 --- a/extensions/fablabchemnitz_filletchamfer.py +++ b/extensions/fablabchemnitz_filletchamfer.py @@ -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()