修改后的vba程序如下:
Sub AlignMtext()
Dim textObj As AcadMText
Dim TextStr As String
Dim InsPoint(0 To 2) As Double
Dim TextWidth As Double
Dim TextHeight As Double
Dim pointObj As AcadPoint
Dim BS As Long
Dim TS As Long
Dim SC As Long
BS = Asc("\")
TS = Asc("S")
SC = Asc("^")
TextStr = Chr(BS) + Chr(TS) + "0.8" + Chr(SC) + "8.9"
InsPoint(0) = 10
InsPoint(1) = 10
InsPoint(2) = 0
TextWidth = 50
TextHeight = 2
Set textObj = ThisDrawing.ModelSpace.AddMText(InsPoint, TextWidth, TextStr)
textObj.AttachmentPoint = acAttachmentPointMiddleLeft
textObj.height = TextHeight
textObj.Rotation = 0
MsgBox "The AttachmentPoint is set to the default "
ZoomExtents
End Sub
全部回复(3 )
只看楼主 我来说两句原因:没有指定文字对齐点。textObj.TextAlignmentPoint = InsPoint
文字变量中要求上下重叠的控制字符它也不买帐,竟然给原样印出了!
原因:必须创建多行文字才能支持控制字符。
修改后的vba程序如下:
Sub AlignMtext()
Dim textObj As AcadMText
Dim TextStr As String
Dim InsPoint(0 To 2) As Double
Dim TextWidth As Double
Dim TextHeight As Double
Dim pointObj As AcadPoint
Dim BS As Long
Dim TS As Long
Dim SC As Long
BS = Asc("\")
TS = Asc("S")
SC = Asc("^")
TextStr = Chr(BS) + Chr(TS) + "0.8" + Chr(SC) + "8.9"
InsPoint(0) = 10
InsPoint(1) = 10
InsPoint(2) = 0
TextWidth = 50
TextHeight = 2
Set textObj = ThisDrawing.ModelSpace.AddMText(InsPoint, TextWidth, TextStr)
textObj.AttachmentPoint = acAttachmentPointMiddleLeft
textObj.height = TextHeight
textObj.Rotation = 0
MsgBox "The AttachmentPoint is set to the default "
ZoomExtents
End Sub
回复 举报
回复 举报