- 积分
- 641
- 明经币
- 个
- 注册时间
- 2003-4-18
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2003-9-5 08:39:00
|
显示全部楼层
我已经基本琢磨清楚了
用vba进行了一些简单的字符串设置,可以实现上划线、下划线、文字堆叠(分数或公差)。我把它放在此,感兴趣可以试一下。好处是各种格式字符组成一个mtext对象,决不用考虑字型变化和后期编辑的问题。
可以简单,就有必要不用复杂。
源码如下:
Sub main()
Dim pt As Variant
Dim txtw As Double
Dim txtStr As String
Dim MtxtObj As AcadMText
Dim AMid As String
pt = Point3d(0, 10)
txtw = 100
AMid = "\A1;"
txtStr = AMid & "aaaa" & UStr(LStr("bbbb")) & UStr("uuuuu") & SStr("2", "3", 0.7, True) & LStr("llllll") & "200" & SStr("+0.010", "-0.020", 0.7) & "cccc" '
Set MtxtObj = ThisDrawing.ModelSpace.AddMText(pt, txtw, txtStr)
End Sub
'三维点
Function Point3d(ByVal x As Double, ByVal y As Double, Optional z = 0) As Variant
Dim pt3d(0 To 2) As Double
pt3d(0) = x
pt3d(1) = y
pt3d(2) = z
Point3d = pt3d
End Function
'顶线
Function UStr(ByVal s As String) As String
UStr = "\O" & s & "\o"
End Function
'底线
Function LStr(ByVal s As String) As String
LStr = "\L" & s & "\l"
End Function
'堆叠,h为高度系数;当l为true时,以分数显示
Function SStr(ByVal s1 As String, ByVal s2 As String, ByVal h As Double, Optional l As Boolean) As String
If l = True Then
SStr = "\S" & s1 & "/" & s2 & ";"
Else
SStr = "\S" & s1 & "^" & s2 & ";"
End If
If h > 0 And h <> 1 Then
SStr = "{\H" & h & "x;" & SStr & "}"
End If
End Function |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|