Issue
BrowserNodeDefinition.DisplayState returns current states for native browser nodes. I find that it returns kDefaultDisplayState unless it was explicitly changed by using BrowserNodeDefinition.DisplayState. Is this assumption correct?
This is as designed. A return value of kDefaultDisplayState indicates that the browser node’s display state has been decided by Inventor. Other values indicate an override applied by API client. The DisplayState property is intended to be used for browser customization. If you're interested in state of associated object you need to query the object associated with the browser node.
The following samples illustrate this approach:
VBA:
Sub DumpAdaptivityInfo()
Dim doc As AssemblyDocument
Set doc = ThisApplication.ActiveDocument
Call DumpNodes(doc.BrowserPanes.ActivePane.topNode)
End Sub
Private Sub DumpNodes(topNode As BrowserNode)
On Error Resume Next
Dim node As BrowserNode
For Each node In topNode.BrowserNodes
Dim nodeDef As NativeBrowserNodeDefinition
Set nodeDef = node.BrowserNodeDefinition
Dim nativeObj As Object
Set nativeObj = nodeDef.NativeObject
If Not nativeObj Is Nothing Then
If TypeOf nativeObj Is ComponentOccurrence Then
Dim occ As ComponentOccurrence
Set occ = nodeDef.NativeObject
Debug.Print nodeDef.Label
Debug.Print Spc(2); "Adaptive: " & occ.Adaptive
End If
End If
Call DumpNodes(node)
Next
End Sub
VB .NET:
Sub DumpAdaptivityInfo()
Dim oDoc As AssemblyDocument _
= CType(oApp.ActiveDocument, AssemblyDocument)
DumpNodes(oDoc.BrowserPanes.ActivePane.TopNode)
End Sub
Private Sub DumpNodes(ByVal topNode As BrowserNode)
For Each node As BrowserNode In topNode.BrowserNodes
Dim nodeDef As NativeBrowserNodeDefinition _
= CType(node.BrowserNodeDefinition, NativeBrowserNodeDefinition)
Dim nativeObj As Object = Nothing
Try
nativeObj = nodeDef.NativeObject
Catch
End Try
If nativeObj IsNot Nothing Then
If TypeOf nativeObj Is ComponentOccurrence Then
Dim occ As ComponentOccurrence _
= CType(nodeDef.NativeObject, ComponentOccurrence)
Debug.Print(nodeDef.Label)
Debug.Print(Space(2) + "Adaptive: " & occ.Adaptive)
End If
End If
DumpNodes(node)
Next
End Sub