From: buliabyak Date: Mon, 29 May 2006 01:37:07 +0000 (+0000) Subject: fix effects failing when document has no namedview or no current-layer attr X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6fe0b3c04eb1666cc7e83f2360088fda4c9f1beb;p=inkscape.git fix effects failing when document has no namedview or no current-layer attr --- diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 41fdcd959..64efdabda 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -90,16 +90,21 @@ class Effect: #defaults self.current_layer = self.document.documentElement self.view_center = (0.0,0.0) - - layername = xml.xpath.Evaluate('//sodipodi:namedview/@inkscape:current-layer',self.document,context=ctx)[0].value - layer = xml.xpath.Evaluate('//g[@id="%s"]' % layername,self.document,context=ctx)[0] - if layer: - self.current_layer = layer - - x = xml.xpath.Evaluate('//sodipodi:namedview/@inkscape:cx',self.document,context=ctx)[0].value - y = xml.xpath.Evaluate('//sodipodi:namedview/@inkscape:cy',self.document,context=ctx)[0].value - if x and y: - self.view_center = (float(x),float(y)) + + layerattr = xml.xpath.Evaluate('//sodipodi:namedview/@inkscape:current-layer',self.document,context=ctx) + if layerattr: + layername = layerattr[0].value + layer = xml.xpath.Evaluate('//g[@id="%s"]' % layername,self.document,context=ctx)[0] + if layer: + self.current_layer = layer + + xattr = xml.xpath.Evaluate('//sodipodi:namedview/@inkscape:cx',self.document,context=ctx) + yattr = xml.xpath.Evaluate('//sodipodi:namedview/@inkscape:cy',self.document,context=ctx) + if xattr and yattr: + x = xattr[0].value + y = yattr[0].value + if x and y: + self.view_center = (float(x),float(y)) def getselected(self): """Collect selected nodes""" for id in self.options.ids: