From fc960bdc83646a68cffef94f040dae52b6a0eb61 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sat, 8 Aug 2020 11:54:38 +0200 Subject: [PATCH] Modded bounding box tool to have custom offset values --- extensions/fablabchemnitz_boundingbox.inx | 3 ++- extensions/fablabchemnitz_boundingbox.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/extensions/fablabchemnitz_boundingbox.inx b/extensions/fablabchemnitz_boundingbox.inx index 972241c9..5a176a4a 100644 --- a/extensions/fablabchemnitz_boundingbox.inx +++ b/extensions/fablabchemnitz_boundingbox.inx @@ -2,7 +2,8 @@ Bounding Box fablabchemnitz.de.boundingbox - Draws bounding boxes around selected objects, useful for debugging. Author: Pawel Mosakowski + Draws bounding boxes around selected objects, useful for debugging. Author: Pawel Mosakowski. Modded by Mario Voigt. + 0.0 all diff --git a/extensions/fablabchemnitz_boundingbox.py b/extensions/fablabchemnitz_boundingbox.py index 1a1f742d..ab779568 100644 --- a/extensions/fablabchemnitz_boundingbox.py +++ b/extensions/fablabchemnitz_boundingbox.py @@ -6,6 +6,7 @@ from lxml import etree class DrawBBoxes(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) + self.arg_parser.add_argument('--offset', type=float, default=0.0, help='Offset from object (all directions)') def effect(self): if len(self.svg.selected) > 0: @@ -13,10 +14,10 @@ class DrawBBoxes(inkex.Effect): for id, node, bbox in bboxes: attribs = { 'style' : str(inkex.Style({'stroke':'#ff0000','stroke-width' : '1','fill':'none'})), - 'x' : str(bbox.left), - 'y' : str(bbox.top), - 'width' : str(bbox.width), - 'height' : str(bbox.height), + 'x' : str(bbox.left - self.options.offset), + 'y' : str(bbox.top - self.options.offset), + 'width' : str(bbox.width + 2 * self.options.offset), + 'height' : str(bbox.height + 2 * self.options.offset), } etree.SubElement(self.svg.get_current_layer(), inkex.addNS('rect','svg'), attribs )