From 94d389ae1ca065af8070aa2373c79d7c93ff09d9 Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Wed, 20 Jun 2012 10:12:46 +0200 Subject: [PATCH 1/2] importSVG: fixes in preserveAspectRatio and sweepflag handling --- src/Mod/Draft/importSVG.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mod/Draft/importSVG.py b/src/Mod/Draft/importSVG.py index 099041d0a..6c7b4eb2e 100644 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -448,8 +448,7 @@ class svgHandler(xml.sax.ContentHandler): abh = getsize(h,unitmode) sx=abw/vbw sy=abh/vbh - preservearstr=data.get('preserveAspectRatio',\ - '').lower() + preservearstr=' '.join(data.get('preserveAspectRatio',[])).lower() uniformscaling = round(sx/sy,5) == 1 if uniformscaling: m.scale(Vector(sx,sy,1)) @@ -624,7 +623,8 @@ class svgHandler(xml.sax.ContentHandler): if sweepflag: #angledelta=-(-angledelta % (math.pi *2)) # Step4 #angledelta=(-angledelta % (math.pi *2)) # Step4 - angle1 = angle1-angledelta + angle1 = angle1+angledelta + angledelta = -angledelta #angle1 = math.pi - angle1 e1a = Part.Arc(e1,angle1-swapaxis*math.radians(90),\ From 7147f3dd55ae1661d6fee431cafccd4e7e536f8a Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Thu, 21 Jun 2012 15:11:16 +0200 Subject: [PATCH 2/2] importSVG: create Face only if path is closed --- src/Mod/Draft/importSVG.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Mod/Draft/importSVG.py b/src/Mod/Draft/importSVG.py index 6c7b4eb2e..7a7c7056f 100644 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -51,8 +51,8 @@ if open.__module__ == '__builtin__': pythonopen = open svgcolors = { - 'Pink': (255, 192, 203), - 'Blue': (0, 0, 255), + 'Pink': (255, 192, 203), + 'Blue': (0, 0, 255), 'Honeydew': (240, 255, 240), 'Purple': (128, 0, 128), 'Fuchsia': (255, 0, 255), @@ -269,7 +269,7 @@ def makewire(path,checkclosed=False,donttry=False): #ToDo Do not catch all exceptions if not donttry: try: - sh = Part.Wire(DraftGeomUtils.sortEdges(path)) + sh = Part.Wire(DraftGeomUtils.sortEdges(path)) #sh = Part.Wire(path) isok = (not checkclosed) or sh.isClosed() except:# BRep_API:command not done @@ -533,7 +533,8 @@ class svgHandler(xml.sax.ContentHandler): if path: #sh = Part.Wire(path) sh = makewire(path) - if self.fill: sh = Part.Face(sh) + if self.fill and sh.isClosed(): + sh = Part.Face(sh) sh = self.applyTrans(sh) obj = self.doc.addObject("Part::Feature",pathname) obj.Shape = sh @@ -750,7 +751,8 @@ class svgHandler(xml.sax.ContentHandler): if path: sh=makewire(path,checkclosed=False) #sh = Part.Wire(path) - if self.fill: sh = Part.Face(sh) + if self.fill and sh.isClosed(): + sh = Part.Face(sh) sh = self.applyTrans(sh) obj = self.doc.addObject("Part::Feature",pathname) obj.Shape = sh @@ -828,7 +830,6 @@ class svgHandler(xml.sax.ContentHandler): obj = self.doc.addObject("Part::Feature",pathname) obj.Shape = sh self.format(obj) - # processing lines if name == "line": @@ -864,7 +865,8 @@ class svgHandler(xml.sax.ContentHandler): path.append(seg) if path: sh = Part.Wire(path) - if self.fill: sh = Part.Face(sh) + if self.fill and sh.isClosed(): + sh = Part.Face(sh) sh = self.applyTrans(sh) obj = self.doc.addObject("Part::Feature",pathname) obj.Shape = sh