Skip to content

Commit

Permalink
Draft: Fix importSVG.py: wrong position for certain ellipses (#5297)
Browse files Browse the repository at this point in the history
Ellipses and elliptical arcs with a y radius larger than their x radius would end up in the wrong position.
  • Loading branch information
Roy-043 authored and donovaly committed Jan 6, 2022
1 parent 186bfff commit f0d783b
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions src/Mod/Draft/importSVG.py
Expand Up @@ -1044,19 +1044,12 @@ def startElement(self, name, attrs):
# angle1 - 0 * swapaxis * d90,
# angle1 + angledelta
# - 0 * swapaxis * d90)
_precision = 10**(-1*Draft.precision())
if swapaxis or xrotation > _precision:
m3 = FreeCAD.Matrix()
m3.move(vcenter)
# 90
rot90 = FreeCAD.Matrix(0, -1, 0, 0, 1, 0)
# swapaxism = FreeCAD.Matrix(0, 1, 0, 0, 1, 0)
if swapaxis:
m3 = m3.multiply(rot90)
m3.rotateZ(math.radians(-xrotation))
m3.move(vcenter.multiply(-1))
e1a.transform(m3)
seg = e1a.toShape()
if swapaxis:
seg.rotate(vcenter, Vector(0, 0, 1), 90)
_precision = 10**(-1*Draft.precision())
if abs(xrotation) > _precision:
seg.rotate(vcenter, Vector(0, 0, 1), -xrotation)
if sweepflag:
seg.reverse()
# DEBUG
Expand Down Expand Up @@ -1380,14 +1373,7 @@ def startElement(self, name, attrs):
sh = Part.Ellipse(c, rx, ry).toShape()
else:
sh = Part.Ellipse(c, ry, rx).toShape()
m3 = FreeCAD.Matrix()
m3.move(c)
# 90
rot90 = FreeCAD.Matrix(0, -1, 0, 0, 1, 0)
m3 = m3.multiply(rot90)
m3.move(c.multiply(-1))
sh.transformShape(m3)
# sh = sh.transformGeometry(m3)
sh.rotate(c, Vector(0, 0, 1), 90)
if self.fill:
sh = Part.Wire([sh])
sh = Part.Face(sh)
Expand Down

0 comments on commit f0d783b

Please sign in to comment.