Is it a bug in Inventor professional 2022 ?

Is it a bug in Inventor professional 2022 ?

Anonymous
Not applicable
1,294 Views
14 Replies
Message 1 of 15

Is it a bug in Inventor professional 2022 ?

Anonymous
Not applicable

Is it a bug in Inventor professional 2022 ?
What is the reason? (In Inventor Professional 2022)
Run In (VBA Editor F5).
But
Doesn't run in (Customize ShortCut Key '4')
What is the reason?

Public Sub CollapseAll() 'Set ShortCut Key = 4
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager
Dim oControlDef As ControlDefinition
Set oControlDef = oCommandMgr.ControlDefinitions.Item("AppBrowserCollapseAllCmd")
Call oControlDef.Execute
ThisApplication.ActiveDocument.Update
End Sub

0 Likes
Accepted solutions (1)
1,295 Views
14 Replies
Replies (14)
Message 2 of 15

bradeneuropeArthur
Mentor
Mentor

What is the problem precisely?

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 15

laszlo_nagy
Contributor
Contributor

this code doesn't work me neither in Inventor 2022
I think there is an issue with the internal command

maybe try this code, it traverses through the browsernodes and close them one by one

Public Sub closeAll()
    
    Dim oDoc  As Document
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oModelPane As BrowserPane
    Set oModelPane = oDoc.BrowserPanes.Item("Model")
    
    Dim oTopNode As BrowserNode
    Set oTopNode = oModelPane.TopNode
    
    Dim oNode As BrowserNode
    
    For Each oNode In oTopNode.BrowserNodes
    
        Call closeNodes(oNode)
        
    Next
    
End Sub

Private Sub closeNodes(ByRef oNode As BrowserNode)
    
    If oNode.BrowserNodes.Count <> 0 Then
        
        Dim oChildNode As BrowserNode
        
        For Each oChildNode In oNode.BrowserNodes
            Call closeNodes(oChildNode)
        Next
        
    End If
    
    On Error Resume Next
        oNode.Expanded = False
    On Error GoTo 0
    
End Sub

 

0 Likes
Message 4 of 15

dg2405
Advocate
Advocate

On my Inventor 2022 this code works!

0 Likes
Message 5 of 15

dg2405
Advocate
Advocate

Sorry with press key 4 it also don't work here.

0 Likes
Message 6 of 15

Anonymous
Not applicable

Thank you, but it's too slow.

0 Likes
Message 7 of 15

A.Acheson
Mentor
Mentor

@Anonymous 

 

I tested this in inv 2020 and it worked. Unfortunately I could not test in 2022. 
Is there a chance this keyboard key his used elsewhere on your installation?

 

Also if you would like to bump the forum post to the top to ensure it gets noticed, under options click float this item to the top. Creating multiple post with the same content can be confusing for users looking to answer the question and for future users looking for a direct single source answer.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 8 of 15

bradeneuropeArthur
Mentor
Mentor

@A.Acheson 

A question beside.

Where to find that option float to top?

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 9 of 15

A.Acheson
Mentor
Mentor

@bradeneuropeArthur @Anonymous 

My apologies!!, that button does not float the post to the top but rather pins it to the top which is maybe not the correct use of the button. The only other way I would think is to comment on your own post. 

Float this topic to the top.png

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 10 of 15

bradeneuropeArthur
Mentor
Mentor

@A.Acheson 

It would be a good option to have the possibility to move topics up, but if everyone uses this.......

Otherwise we could add it to the Idea Station, but it will make no sense!

Thanks for the hint anyway.

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 11 of 15

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

This button pins the thread only for yourself. Pin for all users is a function only for moderators or administrators.

 

In Inventor 2022 it seems to make a difference where mouse cursor is positioned when hitting shortcut key. If it is above model browser, it works. So I thought of moving mouse to model browser in macro and back to original position. Can you give it a try?

 

Option Explicit

Private Declare PtrSafe Function SetCursorPos Lib "user32.dll" (ByVal X As Integer, ByVal Y As Integer) As Integer
Private Declare PtrSafe Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Long
Public Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Public Const MOUSEEVENTF_MOVE = &H1

Private Type POINTAPI
    X_Pos As Long
    Y_Pos As Long
End Type
      
Private Sub MoveMouse()

    Dim X As Integer
    X = ThisApplication.UserInterfaceManager.DockableWindows.Item(1).Left + ThisApplication.UserInterfaceManager.DockableWindows.Item(1).Width - 50
    Dim Y As Integer
    Y = ThisApplication.UserInterfaceManager.DockableWindows.Item(1).Top + ThisApplication.UserInterfaceManager.DockableWindows.Item(1).Height - 50
    Dim i As Integer
    i = SetCursorPos(X, Y)
    
    Call mouse_event(MOUSEEVENTF_MOVE, -100, -100, 0, 100)
    
End Sub


Public Sub CollapseAll() 'Set ShortCut Key = 4
    Dim Coords As POINTAPI
    Call GetCursorPos(Coords)
    
    Call MoveMouse
    
    DoEvents
    
    Dim oCommandMgr As CommandManager
    Set oCommandMgr = ThisApplication.CommandManager
    
    Dim oControlDef As ControlDefinition
    Set oControlDef = oCommandMgr.ControlDefinitions.Item("AppBrowserCollapseAllCmd")

    Call oControlDef.Execute
    
    Call SetCursorPos(Coords.X_Pos, Coords.Y_Pos)
End Sub

Public Sub ExpandAll() 'Set ShortCut Key = 5
    Dim Coords As POINTAPI
    Call GetCursorPos(Coords)
    
    Call MoveMouse
    
    DoEvents
    
    Dim oCommandMgr As CommandManager
    Set oCommandMgr = ThisApplication.CommandManager
    
    Dim oControlDef As ControlDefinition
    Set oControlDef = oCommandMgr.ControlDefinitions.Item("AppBrowserExpandAllCmd")
    
    Call oControlDef.Execute
    
    Call SetCursorPos(Coords.X_Pos, Coords.Y_Pos)
End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 12 of 15

Anonymous
Not applicable

It works fine.

Thank yoy.

0 Likes
Message 13 of 15

Anonymous
Not applicable

Thank you.

0 Likes
Message 14 of 15

cnoJTCG6
Contributor
Contributor

Nice solution Krieg for this problem.
I ran into the same thing for some macros after moving to IV2022.

 

After collapsing the Browser Pane I set a few nodes, 'Model States', 'Representations-View and Position' and 'Origin', back to expanded.
I now do that through a 2nd and 3th For Next loop inside the first one who is checking 'node.FullPath' for a specific string.

In some cases, depending on the size of the Assembly, this takes quite some time.

 

Is it possible to directly access these nodes?

0 Likes
Message 15 of 15

checkcheck_master
Advocate
Advocate

This time on my previously used account:
Nice solution Krieg for this problem.
I ran into the same thing for some macros after moving to IV2022.

After collapsing the Browser Pane I set a few nodes, 'Model States', 'Representations-View and Position' and 'Origin', back to expanded.
I now do that through a 2nd and 3th For Next loop inside the first one who is checking 'node.FullPath' for a specific string.

In some cases, depending on the size of the Assembly, this takes quite some time.

 

Is it possible to directly access these nodes?

0 Likes