请大家帮我一下,是关于文本对齐方面的问题
比如我选了几个文本,我要设置它们的acalignmentmiddleleft 中的X坐标的相同(这一步我能解决),而Y坐标不变(这就有麻烦了),我不知道怎样把原来文本的y坐标调用出来我本来是这样写的
dim oldpt as Variant
dim nept(0 to 2) as double
oldpt=ent.ent.TextAlignmentPoint
nept(1)=oldpt(1)
“ent是已选中的单行文本”
这样做行不通,请大家帮一下我
帮助中已经说明,如果对齐方式为acAlignmentLeft时,对齐点的坐标值为0
所以在改变对齐方式后,应该把插入点重新设回原来的插入点,不然文字就会跑到原点上 去。以下程序你试试:
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
谢谢
让我先试一下
页:
[1]