所以在改变对齐方式后,应该把插入点重新设回原来的插入点,不然文字就会跑到原点上 去。
以下程序你试试:
- Sub TextAlignPnt()
- Dim pnt As Variant
- Dim pnt1 As Variant
- Dim pnt2 As Variant
- Dim obj As AcadEntity
- Dim txt As AcadText
- ThisDrawing.Utility.GetEntity obj, pnt1, "Select Text:"
- If obj.ObjectName = "AcDbText" Then
- Set txt = obj
- pnt = txt.InsertionPoint
- Debug.Print "Insertionpoint=" & pnt(0) & " " & pnt(1) & " "; pnt(2)
- txt.Alignment = acAlignmentMiddleLeft
- pnt1 = txt.TextAlignmentPoint
- txt.InsertionPoint = pnt
- Debug.Print "Alignmentpoint=" & pnt1(0) & " " & pnt1(1) & " "; pnt1(2)
- pnt2 = ThisDrawing.Utility.GetPoint(, "Select New Alignment point:")
- Debug.Print "Selectpoint=" & pnt2(0) & " " & pnt2(1) & " "; pnt2(2)
- pnt1(0) = pnt2(0)
- txt.TextAlignmentPoint = pnt1
- ThisDrawing.Application.Update
- End If
- End Sub
|