From e24847941d9b62ed0276af1220d777f7ec656c67 Mon Sep 17 00:00:00 2001 From: leyghisbb Date: Thu, 22 Apr 2021 21:25:07 +0200 Subject: [PATCH] fix in vpypetools --- extensions/fablabchemnitz/vpypetools/vpypetools.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools.py b/extensions/fablabchemnitz/vpypetools/vpypetools.py index 90e11b82..b037cf4f 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools.py +++ b/extensions/fablabchemnitz/vpypetools/vpypetools.py @@ -424,14 +424,18 @@ class vpypetools (inkex.EffectExtension): lineLayer.attrib.pop('fill') # remove unneccesary fill attribute import_viewBox = import_doc.getroot().get('viewBox').split(" ") - self_viewBox = self.document.getroot().get('viewBox').split(" ") - scaleX = self.svg.unittouu(self_viewBox[2]) / self.svg.unittouu(import_viewBox[2]) - scaleY = self.svg.unittouu(self_viewBox[3]) / self.svg.unittouu(import_viewBox[3]) + self_viewBox = self.document.getroot().get('viewBox') + + if self_viewBox is not None: #some SVG files do not have this attribute + self_viewBoxValues = self_viewBox.split(" ") + scaleX = self.svg.unittouu(self_viewBoxValues[2]) / self.svg.unittouu(import_viewBox[2]) + scaleY = self.svg.unittouu(self_viewBoxValues[3]) / self.svg.unittouu(import_viewBox[3]) for element in import_doc.getroot().iter("{http://www.w3.org/2000/svg}g"): self.document.getroot().append(element) if self.options.input_handling == "layers": - element.set('transform', 'scale(' + str(scaleX) + ',' + str(scaleY) + ')') #imported groups need to be transformed. Or they have wrong size. Reason: different viewBox sizes/units in namedview definitions + if self_viewBox is not None: + element.set('transform', 'scale(' + str(scaleX) + ',' + str(scaleY) + ')') #imported groups need to be transformed. Or they have wrong size. Reason: different viewBox sizes/units in namedview definitions if self.options.apply_transformations is True and applyTransformAvailable is True: #we apply the transforms directly after adding them applytransform.ApplyTransform().recursiveFuseTransform(element)