Draft: Fixed text rotation + dim text height in DXF export
This commit is contained in:
@@ -3665,7 +3665,9 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
else:
|
||||
# other cases, treat objects one by one
|
||||
dxf = dxfLibrary.Drawing()
|
||||
|
||||
# add global variables
|
||||
if hasattr(dxf,"header"):
|
||||
dxf.header.append(" 9\n$DIMTXT\n 40\n"+str(Draft.getParam("textheight", 20))+"\n")
|
||||
for ob in exportLayers:
|
||||
if ob.Label != "0": # dxflibrary already creates it
|
||||
ltype = 'continuous'
|
||||
@@ -3683,8 +3685,9 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
lineType=ltype))
|
||||
|
||||
for ob in exportList:
|
||||
obtype = Draft.getType(ob)
|
||||
# print("processing " + str(ob.Name))
|
||||
if Draft.getType(ob) == "PanelSheet":
|
||||
if obtype == "PanelSheet":
|
||||
if not hasattr(ob.Proxy, "sheetborder"):
|
||||
ob.Proxy.execute(ob)
|
||||
sb = ob.Proxy.sheetborder
|
||||
@@ -3707,10 +3710,44 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
writeShape(shp, ob, dxf, nospline, lwPoly,
|
||||
layer="Outlines", color=5)
|
||||
|
||||
elif Draft.getType(ob) == "PanelCut":
|
||||
elif obtype == "PanelCut":
|
||||
writePanelCut(ob, dxf, nospline, lwPoly)
|
||||
|
||||
elif Draft.getType(ob) == "Axis":
|
||||
elif obtype == "Space":
|
||||
vobj = ob.ViewObject
|
||||
c = utils.get_rgb(vobj.TextColor)
|
||||
n = vobj.FontName
|
||||
a = 0
|
||||
if rotation != 0:
|
||||
a = math.radians(rotation)
|
||||
t1 = "".join(vobj.Proxy.text1.string.getValues())
|
||||
t2 = "".join(vobj.Proxy.text2.string.getValues())
|
||||
scale = vobj.FirstLine.Value/vobj.FontSize.Value
|
||||
f1 = fontsize * scale
|
||||
if round(FreeCAD.DraftWorkingPlane.axis.getAngle(App.Vector(0,0,1)),2) not in [0,3.14]:
|
||||
# if not in XY view, place the label at center
|
||||
p2 = obj.Shape.CenterOfMass
|
||||
else:
|
||||
_v = vobj.Proxy.coords.translation.getValue().getValue()
|
||||
p2 = obj.Placement.multVec(App.Vector(_v))
|
||||
_h = vobj.Proxy.header.translation.getValue().getValue()
|
||||
lspc = FreeCAD.Vector(_h)
|
||||
p1 = p2 + lspc
|
||||
dxf.append(dxfLibrary.Text(t1, p1, height=f1,
|
||||
color=getACI(ob, text=True),
|
||||
style='STANDARD',
|
||||
layer=getStrGroup(ob)))
|
||||
if t2:
|
||||
ofs = FreeCAD.Vector(0, -lspc.Length, 0)
|
||||
if a:
|
||||
Z = FreeCAD.Vector(0, 0, 1)
|
||||
ofs = FreeCAD.Rotation(Z, -rotation).multVec(ofs)
|
||||
dxf.append(dxfLibrary.Text(t2, p1.add(ofs), height=f1,
|
||||
color=getACI(ob, text=True),
|
||||
style='STANDARD',
|
||||
layer=getStrGroup(ob)))
|
||||
|
||||
elif obtype == "Axis":
|
||||
axes = ob.Proxy.getAxisData(ob)
|
||||
if not axes:
|
||||
continue
|
||||
@@ -3810,7 +3847,7 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
else:
|
||||
writeShape(sh, ob, dxf, nospline, lwPoly)
|
||||
|
||||
elif Draft.getType(ob) == "Annotation":
|
||||
elif obtype == "Annotation":
|
||||
# old-style texts
|
||||
# temporary - as dxfLibrary doesn't support mtexts well,
|
||||
# we use several single-line texts
|
||||
@@ -3829,7 +3866,7 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
style='STANDARD',
|
||||
layer=getStrGroup(ob)))
|
||||
|
||||
elif Draft.getType(ob) in ("DraftText","Text"):
|
||||
elif obtype in ("DraftText","Text"):
|
||||
# texts
|
||||
if gui:
|
||||
height = float(ob.ViewObject.FontSize)
|
||||
@@ -3839,14 +3876,16 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
point = DraftVecUtils.tup(Vector(ob.Placement.Base.x,
|
||||
ob.Placement.Base.y - (height * 1.2 * ob.Text.index(text)),
|
||||
ob.Placement.Base.z))
|
||||
rotation = math.degrees(ob.Placement.Rotation.Angle)
|
||||
dxf.append(dxfLibrary.Text(text,
|
||||
point,
|
||||
height=height * 0.8,
|
||||
rotation=rotation,
|
||||
color=getACI(ob, text=True),
|
||||
style='STANDARD',
|
||||
layer=getStrGroup(ob)))
|
||||
|
||||
elif Draft.getType(ob) in ["Dimension","LinearDimension"]:
|
||||
elif obtype in ["Dimension","LinearDimension"]:
|
||||
p1 = DraftVecUtils.tup(ob.Start)
|
||||
p2 = DraftVecUtils.tup(ob.End)
|
||||
base = Part.LineSegment(ob.Start, ob.End).toShape()
|
||||
|
||||
Reference in New Issue
Block a user