From d40fecad0ce52a4aea0a674efe7f28409cc1d11b Mon Sep 17 00:00:00 2001 From: acspike Date: Sun, 28 May 2006 03:41:31 +0000 Subject: [PATCH] add a function to pull some info from the sodipodi:namedview --- share/extensions/inkex.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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() -- 2.30.2