大家好,我正在尝试在图形中选择对象和检索信息。到目前为止,我已经能够选择一个对象,在本例中是指引线注释,但我需要检索有关其节点等的信息。然而,我似乎无法使用我获得的代码访问此信息,因此我必须检索对象的参考键,我希望通过drawingnotes访问信息。如果我使用leadernotes引用对象,则可以获得leadernotes。第(1)项等。。。但问题是,项目编号将随着图纸的编辑而变化。。。
所以,问题是,拥有一个对象的引用键,然后我如何引用该对象,并访问其属性?
到目前为止,我掌握的代码是:
- Public Sub TestSelection()
- ' Create a new clsSelect object.
- Dim oSelect As New clsLeaderGhost
-
- Dim odoc As DrawingDocument
- Dim oleader As DrawingNote
- Dim oNotes As LeaderNotes
-
- Dim Lrefkey() As Byte
- Dim lrefkeystr As String
- Dim Leaderinfo As New Collection
-
- Set odoc = ThisApplication.ActiveDocument
- Set oNotes = odoc.ActiveSheet.DrawingNotes.LeaderNotes
- ' Call the pick method of the clsSelect object and set
- ' the filter to pick any Drawing Note.
- Set oleader = oSelect.Pick(kDrawingNoteFilter)
-
- ' Check to make sure an object was selected.
- If Not oleader Is Nothing Then
-
- Call oleader.GetReferenceKey(Lrefkey)
- lrefkeystr = odoc.ReferenceKeyManager.KeyToString(Lrefkey)
-
- For n = 1 To oNotes.Item(Lrefkey).Leader.AllNodes.Count
- Leaderinfo.Add (oNotes.Item(1).Leader.AllNodes.Item(n).Position.X)
- Next
-
- End If
- End Sub
|