发一个研究AutoCAD字体有哪些字符的小代码,可能有不对的地方,请大家指正。
用法:1.设置你要测试的字体,在“字体样式”对话框设置,
2.
把以下代码放在vbaIDE里,运行。
- Option Explicit
- '测试字体中的特殊符号
- Public Sub cs()
- Dim tc1 As AcadAcCmColor, tc2 As AcadAcCmColor
- Set tc1 = ThisDrawing.Application.GetInterfaceObject("Autocad.AcCmColor" & "." & Left(ThisDrawing.Application.Version, 2))
- Set tc2 = ThisDrawing.Application.GetInterfaceObject("Autocad.AcCmColor" & "." & Left(ThisDrawing.Application.Version, 2))
- tc1.ColorIndex = acCyan
- tc2.ColorIndex = acRed
- Dim objTxt As AcadText, V As String, Inspt(2) As Double
- Dim i As Long, j As Long
- Const 列数 = 5
- Const 行距 = 20
- ''以下为初步测试
- For j = 1 To 999
- i = i + 1
- V = "%%%%" & CStr(j)
- Inspt(0) = (i - ((i - 1) \ 列数) * 列数) * 行距
- Inspt(1) = ((i - 1) \ 列数) * 行距
- Inspt(2) = 0
- Set objTxt = ThisDrawing.ModelSpace.AddText(V, Inspt, 3)
- objTxt.TrueColor = tc2
- V = "%%" & CStr(j)
- Inspt(0) = (i - ((i - 1) \ 列数) * 列数) * 行距
- Inspt(1) = ((i - 1) \ 列数) * 行距 - 行距 / 2
- Inspt(2) = 0
- Set objTxt = ThisDrawing.ModelSpace.AddText(V, Inspt, 3)
- objTxt.TrueColor = tc1
- Next j
- For j = Asc("A") To Asc("z")
- i = i + 1
- V = "%%%%" & Chr(j)
- Inspt(0) = (i - ((i - 1) \ 列数) * 列数) * 行距
- Inspt(1) = ((i - 1) \ 列数) * 行距
- Inspt(2) = 0
- Set objTxt = ThisDrawing.ModelSpace.AddText(V, Inspt, 3)
- objTxt.TrueColor = tc2
- V = "%%" & Chr(j)
- Inspt(0) = (i - ((i - 1) \ 列数) * 列数) * 行距
- Inspt(1) = ((i - 1) \ 列数) * 行距 - 行距 / 2
- Inspt(2) = 0
- Set objTxt = ThisDrawing.ModelSpace.AddText(V, Inspt, 3)
- objTxt.TrueColor = tc1
- Next j
- ThisDrawing.Application.ZoomExtents
- End Sub
3.测试结果如图所示:
4.例如,当你想输入η时,在文字框里输入%%951就可以了。
|