以下是我在VBA开发时的文字录入的方法:
Function WZ(X0, Y0, AG1, TXT, TXTH, LAY1) '定义标注文字方式
On Error Resume Next Dim INP1(0 To 2) As Double INP1(0) = X0: INP1(1) = Y0: INP1(2) = 0 Set OBJTXT = ThisDrawing.ModelSpace.AddText(TXT, INP1, TXTH) OBJTXT.StyleName = "DXT" OBJTXT.Layer = LAY1 OBJTXT.Rotation = AG1 Asc (Left(TXT, 1)) If Asc(Left(TXT, 1)) >= 48 And Asc(Left(TXT, 1)) <= 90 Then XX = Len(TXT) * TXTH / 40 * SCAL * 0.71 / 4 Else XX = (Len(TXT)) * TXTH / 40 * SCAL * 0.71 / 2 End If If AG1 <> 0 Then INP1(0) = X0: INP1(1) = Y0 + XX: INP1(2) = 0 Else INP1(0) = X0 + XX: INP1(1) = Y0 + TXTH / 2: INP1(2) = 0 End If OBJTXT.Rotate INP1, RAG
End Function
当需要输入文字时,适用如下代码:
Call WZ(TKBASEX + 20.8 * SCAL, TKBASEY + 19.6 * SCAL, 3.14159 * (-0.5), "数 量", 2.5 * SCAL, "TK")
可是目前有一个问题:要将文字的对正方式跟改为“调整”,该怎么操作??此时该如何指定“文字对齐 坐标”和“位置 坐标”? |