From a7e0a4f5f3f3bd9c1fedbae36a61c1f9eac8cf63 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 24 Feb 2012 11:40:31 -0200 Subject: [PATCH] Support rotated texts in Draft DXF import --- src/Mod/Draft/Draft.py | 16 ++++++++++++++++ src/Mod/Draft/importDXF.py | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 5de91a174..0a8e045f2 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -768,6 +768,22 @@ def rotate(objectslist,angle,center=Vector(0,0,0),axis=Vector(0,0,1),copy=False) shape = obj.Shape.copy() shape.rotate(fcvec.tup(center), fcvec.tup(axis), angle) newobj.Shape = shape + elif (obj.isDerivedFrom("App::Annotation")): + if axis.normalize() == Vector(1,0,0): + newobj.ViewObject.RotationAxis = "X" + newobj.ViewObject.Rotation = angle + elif axis.normalize() == Vector(0,1,0): + newobj.ViewObject.RotationAxis = "Y" + newobj.ViewObject.Rotation = angle + elif axis.normalize() == Vector(0,-1,0): + newobj.ViewObject.RotationAxis = "Y" + newobj.ViewObject.Rotation = -angle + elif axis.normalize() == Vector(0,0,1): + newobj.ViewObject.RotationAxis = "Z" + newobj.ViewObject.Rotation = angle + elif axis.normalize() == Vector(0,0,-1): + newobj.ViewObject.RotationAxis = "Z" + newobj.ViewObject.Rotation = -angle elif hasattr(obj,"Placement"): shape = Part.Shape() shape.Placement = obj.Placement diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index b3c91cad9..7669e055c 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -691,6 +691,17 @@ def addText(text,attrib=False): lay.addObject(newob) val = deformat(val) #val = val.decode("Latin1").encode("Latin1") + rx = rawValue(text,11) + ry = rawValue(text,21) + rz = rawValue(text,31) + if rx or ry or rz: + xv = Vector(rx,ry,rz) + if not fcvec.isNull(xv): + ax = fcvec.neg(xv.cross(Vector(1,0,0))) + if fcvec.isNull(ax): + ax = Vector(0,0,1) + ang = -math.degrees(fcvec.angle(xv,Vector(1,0,0),ax)) + Draft.rotate(newob,ang,axis=ax) newob.LabelText = val.split("\n") newob.Position = pos if gui: