From 44e01fac122225bb026b494b6f563d74cbd0733f Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Wed, 4 Oct 2023 09:33:30 +0200 Subject: [PATCH] Draft: importSVG: handle viewBox in mm Forum topic: https://forum.freecad.org/viewtopic.php?t=81696 --- src/Mod/Draft/importSVG.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Mod/Draft/importSVG.py b/src/Mod/Draft/importSVG.py index 382cf87d5d..ce8bf32d11 100644 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -820,18 +820,16 @@ class svgHandler(xml.sax.ContentHandler): if 'width' in data \ and 'height' in data \ and 'viewBox' in data: - vbw = float(data['viewBox'][2]) - vbh = float(data['viewBox'][3]) - w = attrs.getValue('width') - h = attrs.getValue('height') - self.viewbox = (vbw, vbh) if len(self.grouptransform) == 0: unitmode = 'mm' + str(self.svgdpi) else: # nested svg element unitmode = 'css' + str(self.svgdpi) - abw = getsize(w, unitmode) - abh = getsize(h, unitmode) + vbw = getsize(data['viewBox'][2], unitmode) + vbh = getsize(data['viewBox'][3], unitmode) + abw = getsize(attrs.getValue('width'), unitmode) + abh = getsize(attrs.getValue('height'), unitmode) + self.viewbox = (vbw, vbh) sx = abw / vbw sy = abh / vbh _data = data.get('preserveAspectRatio', [])