Sub Ch5_AddAnnotation()
Dim leaderObj As AcadLeader
Dim mtextObj As AcadMText
Dim points(0 To 8) As Double
Dim insertionPoint(0 To 2) As Double
Dim width As Double
Dim leaderType As Integer
Dim annotationObject As Object
Dim textString As String, msg As String
' 在模型空间中创建 MText 对象
textString = "Hello, World."
insertionPoint(0) = 5
insertionPoint(1) = 5
insertionPoint(2) = 0
width = 2
Set mtextObj = ThisDrawing.ModelSpace. _
AddMText(insertionPoint, width, textString)
' 引线的数据
points(0) = 0: points(1) = 0: points(2) = 0
points(3) = 4: points(4) = 4: points(5) = 0
points(6) = 4: points(7) = 5: points(8) = 0
leaderType = acLineWithArrow
' 在模型空间中创建 Leader 对象并关联
' MText 对象和引线
Set annotationObject = mtextObj
Set leaderObj = ThisDrawing.ModelSpace. _
AddLeader(points, annotationObject, leaderType)
ZoomAll
End Sub
本例在模型空间中创建半径标注。
Sub Ch5_CreateRadialDimension()
Dim dimObj As AcadDimRadial
Dim center(0 To 2) As Double
Dim chordPoint(0 To 2) As Double
Dim leaderLen As Integer
' 定义标注
center(0) = 0
center(1) = 0
center(2) = 0
chordPoint(0) = 5
chordPoint(1) = 5
chordPoint(2) = 0
leaderLen = 5
' 在模型空间中创建半径标注
Set dimObj = ThisDrawing.ModelSpace. _
AddDimRadial(center, chordPoint, leaderLen)
ZoomAll
End Sub
注意 只有当标注设置为使用默认的文字位置值时,才会在创建标注时使用 LeaderLength 设置。在第一次关闭标注之后,修改 LeaderLength 的值下载本文