From 647b3ccad1fd3b178e92341fdc92fd276a234dff Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 5 Nov 2016 22:29:03 +0100 Subject: Add exporters (bzr r15142.1.32) --- share/extensions/hpgl_output.py | 14 ++++++++++++++ share/extensions/synfig_output.py | 9 +++++++++ 2 files changed, 23 insertions(+) (limited to 'share') diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index 58f82da71..367a9addd 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # standard library import sys +from inkex import NSS # local libraries import hpgl_encoder import inkex @@ -48,6 +49,13 @@ class HpglOutput(inkex.Effect): def effect(self): self.options.debug = False # get hpgl data + svg = self.document.getroot() + xpathStr = '//sodipodi:namedview' + nv = svg.xpath(xpathStr, namespaces=NSS) + document_rotate = "0" + if nv != []: + document_rotate = nv[0].get("{http://www.inkscape.org/namespaces/inkscape}document-rotation") + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document-rotation","0") myHpglEncoder = hpgl_encoder.hpglEncoder(self) try: self.hpgl, debugObject = myHpglEncoder.getHpgl() @@ -56,9 +64,13 @@ class HpglOutput(inkex.Effect): # issue error if no paths found inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths.")) self.hpgl = '' + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) return else: type, value, traceback = sys.exc_info() + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) raise ValueError, ("", type, value), traceback # convert raw HPGL to HPGL hpglInit = 'IN' @@ -67,6 +79,8 @@ class HpglOutput(inkex.Effect): if self.options.speed > 0: hpglInit += ';VS%d' % self.options.speed self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) def output(self): # print to file diff --git a/share/extensions/synfig_output.py b/share/extensions/synfig_output.py index bcd1eeaf3..461078951 100755 --- a/share/extensions/synfig_output.py +++ b/share/extensions/synfig_output.py @@ -1046,6 +1046,11 @@ def extract_width(style, width_attrib, mtx): ###### Main Class ######################################### class SynfigExport(SynfigPrep): def __init__(self): + svg = self.document.getroot() + xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' + res = svg.xpath(xpathStr, namespaces=inkex.NSS) + self.document_rotate = res[0].get("inkscape:document_rotation") + res[0].set("inkscape:document_rotation","0") SynfigPrep.__init__(self) def effect(self): @@ -1073,6 +1078,10 @@ class SynfigExport(SynfigPrep): root_canvas.append(layer) d.get_root_tree().write(sys.stdout) + svg = self.document.getroot() + xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' + res = svg.xpath(xpathStr, namespaces=inkex.NSS) + res[0].set("inkscape:document_rotation",self.document_rotate) def convert_node(self, node, d): """Convert an SVG node to a list of Synfig layers""" -- cgit v1.2.3 From 1877acd7dc37abe559c94d3abea5e9148fce8fab Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 24 Jan 2017 18:52:08 +0100 Subject: Put namespace as constant (bzr r15142.1.40) --- share/extensions/hpgl_output.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'share') diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index 367a9addd..f31c3fc2d 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -45,6 +45,7 @@ class HpglOutput(inkex.Effect): self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut') self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness') self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align') + self.DOCROTATE = "{http://www.inkscape.org/namespaces/inkscape}document_rotation" def effect(self): self.options.debug = False @@ -54,8 +55,8 @@ class HpglOutput(inkex.Effect): nv = svg.xpath(xpathStr, namespaces=NSS) document_rotate = "0" if nv != []: - document_rotate = nv[0].get("{http://www.inkscape.org/namespaces/inkscape}document-rotation") - nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document-rotation","0") + document_rotate = nv[0].get(self.DOCROTATE) + nv[0].set(self.DOCROTATE,"0") myHpglEncoder = hpgl_encoder.hpglEncoder(self) try: self.hpgl, debugObject = myHpglEncoder.getHpgl() @@ -65,12 +66,12 @@ class HpglOutput(inkex.Effect): inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths.")) self.hpgl = '' if nv != [] and document_rotate: - nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) + nv[0].set("inkscape:document_rotation",document_rotate) return else: type, value, traceback = sys.exc_info() if nv != [] and document_rotate: - nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) + nv[0].set("inkscape:document_rotation",document_rotate) raise ValueError, ("", type, value), traceback # convert raw HPGL to HPGL hpglInit = 'IN' @@ -80,7 +81,7 @@ class HpglOutput(inkex.Effect): hpglInit += ';VS%d' % self.options.speed self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' if nv != [] and document_rotate: - nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) + nv[0].set("inkscape:document_rotation",document_rotate) def output(self): # print to file -- cgit v1.2.3