doc.BrowserPanes.ActivePane.TopNode not give current document after crop in idw

doc.BrowserPanes.ActivePane.TopNode not give current document after crop in idw

hakon_sakseid
Explorer Explorer
462 Views
2 Replies
Message 1 of 3

doc.BrowserPanes.ActivePane.TopNode not give current document after crop in idw

hakon_sakseid
Explorer
Explorer

I have an addin which is getting the selected object when user is clicking in the browser tree, in a drawing, by using activeDoc.BrowserPanes.ActivePane.TopNode in OnChangeSelectSet event. This works fine until I create a crop. After the crop is done, the activeDoc.BrowserPanes.ActivePane.TopNode returns the previous selected node, not the current one. And yes, BeforeOrAfter = kAfter in both cases...

 

Needs help on this one. Anyone seen the same? How to fix?

 

I am using Inventor Professional 2018.

Accepted solutions (1)
463 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor
Hi,

Could you please give some more details in what your are doing and what the problem is?
maybe some screenshots or the code in your add in.
only then we can test it.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 3

hakon_sakseid
Explorer
Explorer
Accepted solution

I have made this vba macro code, which does the same as my c# addin is doing. It takes the top node and recursively runs through the tree and finds the selected items. The macro works fine, but the c# addin does not. When I do a activeDocument.Update() before traversing the tree, it works fine. It seems like this is a bug in Inventor, not updating the structure.

 

Option Explicit


Private Sub GetSelected()
GetSelectionFromBrowserNodes ThisDocument.BrowserPanes.ActivePane.TopNode
End Sub

Private Sub GetSelectionFromBrowserNodes(node As BrowserNode)
On Error GoTo Error_GetSelectionFromBrowserNodes
If node.Selected Then
Dim componentDef As ComponentDefinition

'On Error Resume Next
If TypeName(node.NativeObject) = "ComponentDefinition" Then
Set componentDef = node.NativeObject
Else
Set componentDef = Nothing
End If
On Error GoTo Error_GetSelectionFromBrowserNodes

If componentDef Is Nothing Then
Dim occ As ComponentOccurrence
'On Error Resume Next
If TypeName(node.NativeObject) = "ComponentOccurrence" Then
Set occ = node.NativeObject
Else
Set occ = Nothing
End If
On Error GoTo Error_GetSelectionFromBrowserNodes
If Not occ Is Nothing Then
Set componentDef = occ.Definition
End If
End If

If InStr(node.FullPath, ":Crop") > 0 Then
Debug.Print node.FullPath
Stop
End If

Dim doc As Document
If Not componentDef Is Nothing Then
Set doc = componentDef.Document
End If
If Not doc Is Nothing Then
Dim docId As String
docId = doc.FullFileName
Debug.Print "--> " & docId
End If
End If
If node.Expanded Then
Dim subnode As BrowserNode
For Each subnode In node.BrowserNodes
GetSelectionFromBrowserNodes subnode
Next
End If
Exit Sub

Error_GetSelectionFromBrowserNodes:
Debug.Print Err.Description
Stop
Exit Sub
Resume
End Sub

0 Likes