From: acspike Date: Sun, 28 May 2006 03:41:31 +0000 (+0000) Subject: add a function to pull some info from the sodipodi:namedview X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d40fecad0ce52a4aea0a674efe7f28409cc1d11b;p=inkscape.git add a function to pull some info from the sodipodi:namedview --- diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index b8bba3803..41fdcd959 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -85,6 +85,21 @@ class Effect: stream = sys.stdin self.document = reader.fromStream(stream) stream.close() + def getposinlayer(self): + ctx = xml.xpath.Context.Context(self.document,processorNss=NSS) + #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)) def getselected(self): """Collect selected nodes""" for id in self.options.ids: @@ -98,6 +113,7 @@ class Effect: """Affect an SVG document with a callback effect""" self.getoptions() self.parse() + self.getposinlayer() self.getselected() self.effect() self.output()