Skip to content

Commit

Permalink
fix Inkscape 0.91 compatibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
BvdP committed Feb 3, 2015
1 parent 874661a commit 46b2833
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions ell_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# first define some SVG primitives (we do not use them all so a cleanup may be in order)
objStyle = simplestyle.formatStyle(
{'stroke': '#000000',
'stroke-width': inkex.unittouu('0.1mm'),
'stroke-width': 0.28,
'fill': 'none'
})

greenStyle = simplestyle.formatStyle(
{'stroke': '#00ff00',
'stroke-width': inkex.unittouu('0.1mm'),
'stroke-width': 0.28,
'fill': 'none'
})

Expand Down Expand Up @@ -382,6 +382,16 @@ def __init__(self):
self.OptionParser.add_option('-R', '--central_rib_body', action = 'store',
type = 'inkbool', dest = 'centralRibBody', default = 'false',
help = 'Create a central rib in the body')

try:
inkex.Effect.unittouu # unitouu has moved since Inkscape 0.91
except AttributeError:
try:
def unittouu(self, unit):
return inkex.unittouu(unit)
except AttributeError:
pass

def effect(self):
"""
Draws as basic elliptical box, based on provided parameters
Expand Down Expand Up @@ -411,16 +421,16 @@ def effect(self):

# convert units
unit = self.options.unit
H = inkex.unittouu(str(self.options.height) + unit)
W = inkex.unittouu(str(self.options.width) + unit)
D = inkex.unittouu(str(self.options.depth) + unit)
thickness = inkex.unittouu(str(self.options.thickness) + unit)
cutSpacing = inkex.unittouu(str(self.options.cut_dist) + unit)
H = self.unittouu(str(self.options.height) + unit)
W = self.unittouu(str(self.options.width) + unit)
D = self.unittouu(str(self.options.depth) + unit)
thickness = self.unittouu(str(self.options.thickness) + unit)
cutSpacing = self.unittouu(str(self.options.cut_dist) + unit)
cutNr = self.options.cut_nr

svg = self.document.getroot()
docWidth = inkex.unittouu(svg.get('width'))
docHeigh = inkex.unittouu(svg.attrib['height'])
docWidth = self.unittouu(svg.get('width'))
docHeigh = self.unittouu(svg.attrib['height'])

layer = inkex.etree.SubElement(svg, 'g')
layer.set(inkex.addNS('label', 'inkscape'), 'Elliptical Box')
Expand Down

0 comments on commit 46b2833

Please sign in to comment.