Model Browser & Ribbon Unresponsive after VBA Macro Finishes ..Sometimes

Model Browser & Ribbon Unresponsive after VBA Macro Finishes ..Sometimes

rcolon9E4ZX
Advocate Advocate
417 Views
2 Replies
Message 1 of 3

Model Browser & Ribbon Unresponsive after VBA Macro Finishes ..Sometimes

rcolon9E4ZX
Advocate
Advocate

Hello.

 

Every so often when one of my VBA macros ends, I lose control over the model browser and ribbon and ultimately have to restart Inventor. I have attached a 30s video depicting the loss of control. There is no control over the model browser. I do not get a rectangle for the node under my cursor, and right clicking on a node does not give me a corresponding context menu. The ribbon will still perform commands, but there is no highlighting of the control under the cursor. Clicking constrain will still bring up the Constraint form, but the button is not highlighted before click. When I try to switch to another tab, the tab does not change, and then the command buttons no longer function. 

 

I use the below to hide the Inventor application during macro operation so the user does not interfere, and then I bring it back up. This may happen about 5% of the time as well. Sometimes this loss of control takes place even when I do not toggle application visibility.

 

Public Sub InventorScreen(ByRef oApp As Inventor.Application, Visible As Boolean, ScreenUpdating As Boolean, Minimized As Boolean)

If Visible = True Then
    oApp.Visible = True
    
ElseIf Visible = False Then
    oApp.Visible = False
End If

If ScreenUpdating = True Then
    oApp.ScreenUpdating = True
    'oApp.ActiveView.Update
    
ElseIf ScreenUpdating = False Then
    oApp.ScreenUpdating = False
End If

If Minimized = True Then
    oApp.WindowState = kMinimize
    
ElseIf Minimized = False Then
    oApp.WindowState = kMaximize
End If
    
End Sub

 

Is there some VBA code that can reinitialize the model browser and ribbon so I don't have to restart Inventor?

 

Many thanks in advance.

Rafael

0 Likes
418 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor

Hi @rcolon9E4ZX 

If you set the property ScreenUpdating to False and never change it back to true this will happen (Since you've told the application to not update the screen).

 

 

0 Likes
Message 3 of 3

rcolon9E4ZX
Advocate
Advocate

Hi @JhoelForshav ,

 

Thank you for looking through my post. My code opens and closes documents, sets home view, adjusts colors, etc. I do not want the user to interfere, and I also believe the code runs faster with the application hidden. The code runs perfectly fine 95% of the time. It just happened to me today, which is why I made this post. Did you get a chance to see the attached video? The model space is still fully functional. I can also switch to the Vault Browser and I can highlight nodes.

 

Rafael

0 Likes