Support rotated texts in Draft DXF import
This commit is contained in:
parent
895031da83
commit
a7e0a4f5f3
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user