1
from .base_exporter import BasePrimitiveDXFExporter
4
class TextDXFExporter(BasePrimitiveDXFExporter):
7
#-----------------------------------------------------
8
def exportText(ob, mx, mw, **common):
9
"""converts Text-Object to desired projection and representation(DXF-Entity type)
12
textstr = text3d.getText()
13
WCS_loc = ob.loc # WCS_loc is object location in WorldCoordSystem
20
#print 'deb: sizeX=%s, sizeY=%s' %(sizeX, sizeY) #---------
22
Thickness,Extrusion,ZRotation,Elevation = None,None,None,None
24
AXaxis = mx[0].copy().resize3D() # = ArbitraryXvector
26
#Extrusion, ZRotation, Elevation = getExtrusion(mx)
27
Extrusion, AXaxis = getExtrusion(mx)
29
# no thickness/width for TEXTs converted into ScreenCS
30
if text3d.getExtrudeDepth():
31
Thickness = text3d.getExtrudeDepth() * sizeZ
33
#Horizontal text justification type, code 72, (optional, default = 0)
34
# integer codes (not bit-coded)
35
#0=left, 1=center, 2=right
36
#3=aligned, 4=middle, 5=fit
38
alignment = text3d.getAlignment().value
39
if alignment in {1, 2}: Alignment = alignment
41
textHeight = text3d.getSize() / 1.7
43
if sizeX < 0.0: textFlag |= 2 # set flag for horizontal mirrored
44
if sizeZ < 0.0: textFlag |= 4 # vertical mirrored
47
c = text_as_list[GUI_A['text_as'].val]
49
if c=="TEXT": # export text as TEXT
51
ZRotation,Zrotmatrix,OCS_origin,ECS_origin = getTargetOrientation(mx,Extrusion,\
52
AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ)
55
else: #TODO: fails correct location
56
point1 = mathutils.Vector(ob.loc)
57
[point] = projected_co([point1], mx)
60
coef = -clipStart / (point1*mx)[2]
62
#print 'deb: coef=', coef #--------------
64
#print 'deb: point=', point #--------------
65
[point] = toGlobalOrigin([point])
68
#if DEBUG: text_drawBlender(textstr,points,OCS_origin) #deb: draw to scene
69
common['extrusion']= Extrusion
70
#common['elevation']= Elevation
71
common['thickness']= Thickness
72
#print 'deb: common=', common #------------------
74
#linepoints = [[0,0,0], [AXaxis[0],AXaxis[1],AXaxis[2]]]
75
linepoints = [[0,0,0], point]
76
dxfLINE = DXF.Line(linepoints,**common)
77
entities.append(dxfLINE)
79
dxfTEXT = DXF.Text(text=textstr,point=point,alignment=point2,rotation=ZRotation,\
80
flag=textFlag,height=textHeight,justifyhor=Alignment,**common)
81
entities.append(dxfTEXT)
83
common['thickness']= -Thickness
84
dxfTEXT = DXF.Text(text=textstr,point=point,alignment=point2,rotation=ZRotation,\
85
flag=textFlag,height=textHeight,justifyhor=Alignment,**common)
86
entities.append(dxfTEXT)