Modded bounding box tool to have custom offset values
This commit is contained in:
parent
daa1e85c5b
commit
fc960bdc83
@ -2,7 +2,8 @@
|
|||||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||||
<name>Bounding Box</name>
|
<name>Bounding Box</name>
|
||||||
<id>fablabchemnitz.de.boundingbox</id>
|
<id>fablabchemnitz.de.boundingbox</id>
|
||||||
<param name="help_text" type="description">Draws bounding boxes around selected objects, useful for debugging. Author: Pawel Mosakowski</param>
|
<param name="help_text" type="description">Draws bounding boxes around selected objects, useful for debugging. Author: Pawel Mosakowski. Modded by Mario Voigt.</param>
|
||||||
|
<param min="-10000.0" max="10000.0" name="offset" type="float" gui-text="Offset from object (all directions)">0.0</param>
|
||||||
<effect>
|
<effect>
|
||||||
<object-type>all</object-type>
|
<object-type>all</object-type>
|
||||||
<effects-menu>
|
<effects-menu>
|
||||||
|
@ -6,6 +6,7 @@ from lxml import etree
|
|||||||
class DrawBBoxes(inkex.Effect):
|
class DrawBBoxes(inkex.Effect):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
inkex.Effect.__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):
|
def effect(self):
|
||||||
if len(self.svg.selected) > 0:
|
if len(self.svg.selected) > 0:
|
||||||
@ -13,10 +14,10 @@ class DrawBBoxes(inkex.Effect):
|
|||||||
for id, node, bbox in bboxes:
|
for id, node, bbox in bboxes:
|
||||||
attribs = {
|
attribs = {
|
||||||
'style' : str(inkex.Style({'stroke':'#ff0000','stroke-width' : '1','fill':'none'})),
|
'style' : str(inkex.Style({'stroke':'#ff0000','stroke-width' : '1','fill':'none'})),
|
||||||
'x' : str(bbox.left),
|
'x' : str(bbox.left - self.options.offset),
|
||||||
'y' : str(bbox.top),
|
'y' : str(bbox.top - self.options.offset),
|
||||||
'width' : str(bbox.width),
|
'width' : str(bbox.width + 2 * self.options.offset),
|
||||||
'height' : str(bbox.height),
|
'height' : str(bbox.height + 2 * self.options.offset),
|
||||||
}
|
}
|
||||||
etree.SubElement(self.svg.get_current_layer(), inkex.addNS('rect','svg'), attribs )
|
etree.SubElement(self.svg.get_current_layer(), inkex.addNS('rect','svg'), attribs )
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user