AttributeSet.GetReferenceKey

AttributeSet.GetReferenceKey

MatthiasMinich
Participant Participant
488 Views
0 Replies
Message 1 of 1

AttributeSet.GetReferenceKey

MatthiasMinich
Participant
Participant

Product: Autodesk Inventor 2019

Programming Language: VBA

Application Programming Interface (API): Inventor API

 

I am trying to use the "GetReferenceKey"-Method on a AttributeSet.(Found at Inventor API Help "AttributeSet Object"

) I never had troubles using this method on other objects. But when I try to bind the key back on a object it always failes with AttributeSets. I attached a short Code-Example which shows the problem. 

Am i using the method wrong or is this an API-Bug?

 

Many thanks for your help.

 

Code Example: 

Sub AttributeSet_GetReferenceKey_Test()

    Dim oApp As Inventor.Application
    Set oApp = ThisApplication

    Dim oDoc As Inventor.Document
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim myAtSet As Inventor.AttributeSet
    Set myAtSet = oDoc.AttributeSets.Add("TestAttributeSet", False)
    
    Dim RefKeyBy() As Byte
    Dim KeyCon As Long
    Dim KeyConBy() As Byte
    
    KeyCon = oDoc.ReferenceKeyManager.CreateKeyContext()
    Call myAtSet.GetReferenceKey(RefKeyBy, KeyCon)
    Call oDoc.ReferenceKeyManager.SaveContextToArray(KeyCon, KeyConBy)
    
    'Set myAtSet = Nothing
    
    Dim myObject As Variant
    Dim myContext As Variant
    Dim CanBind As Boolean
    
    KeyCon = oDoc.ReferenceKeyManager.LoadContextFromArray(KeyConBy)
    
    CanBind = oDoc.ReferenceKeyManager.CanBindKeyToObject(RefKeyBy, KeyCon, myObject, myContext)

          
    If CanBind = True Then
        Debug.Print ("Das Gesuchte Objekt wurde gefunden.")
    Else
        Debug.Print ("Das Gesuchte Objekt wurde nicht gefunden.")
    End If
    ‘Set myObject = oDoc.ReferenceKeyManager.BindKeyToObject(RefKeyBy, KeyCon)

End Sub

 

0 Likes
489 Views
0 Replies
Replies (0)