我们知道,工程图里的引线一般会和某个视图几何线绑定,作为对其的注释。当曲线发生变化,引线位置和内容也会联动。那如何得知引线注释的是哪个零件或装配?其实思路就是得到其绑定的几何线。以下是一段小小的代码样例,假定先选中一个引线(API对象是LeaderNote)。
Sub test()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
'选取一个引线
Dim oLeaderNote As LeaderNote
Set oLeaderNote = oDoc.SelectSet(1)
'获得其Leader中最后一个节点,该节点指向几何线
Dim oLastNode As LeaderNode
Set oLastNode = oLeaderNote.Leader.AllNodes(oLeaderNote.Leader.AllNodes.Count)
Dim oGeIntent As GeometryIntent
Dim oAttachedDrawingCurve As DrawingCurve
Dim oDrawingView As DrawingView
Dim oModelG As Object
'查看是否该引线和几何线绑定
If Not oLastNode.AttachedEntity Is Nothing Then
'得到对应的几何线
Set oGeIntent = oLastNode.AttachedEntity
Set oAttachedDrawingCurve = oGeIntent.Geometry
'得到几