Inventor VBA,使用ref
大家好,我正在尝试在图形中选择对象和检索信息。到目前为止,我已经能够选择一个对象,在本例中是指引线注释,但我需要检索有关其节点等的信息。然而,我似乎无法使用我获得的代码访问此信息,因此我必须检索对象的参考键,我希望通过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 您对Inventor API一无所知,是否尝试过在代码中添加断点,并查看您正在引用的对象在运行时可以使用哪些方法或属性? 只是在试图输入解释它为什么不起作用的解释时找到了它。。。我已将oLeader声明为drawingnote,将oNotes声明为leadernotes。。。。因此,通过将oLeader声明为leadernote(注意,oNotes是leadernoteS,即复数),我可以访问我想要的所有信息。。。
谢谢你让我看起来更努力
页:
[1]