UI Dialog allowing user to operate inventor before selecting an option

UI Dialog allowing user to operate inventor before selecting an option

bwangNYAKX
Contributor Contributor
910 Views
5 Replies
Message 1 of 6

UI Dialog allowing user to operate inventor before selecting an option

bwangNYAKX
Contributor
Contributor

I've created some VBA codes that automatically generates REVIT file. It basically changes all the sub-assembly's representation to "REVIT" and deletes all the unnecessary small parts. Then, it will show a UI dialog asking "Ready to Shrinkwarp?" If the user chooses yes, it will do a shrinkwrap and export a adsk file.  

 

My problem is that, the only way I know to generate a dialog is by "msgbox" but the limitation is that when a dialog shows, you are only allowed to click the options but not to operate anything in Inventor. My question is: is there a way that allows me to pan over the model to check if everything is okay, or even better, to make some changes if necessary before I click "yes"? 

 

Thank you for your help in advance!

 

Sub RevitGenerator()

 

'Code to replace the representation and delete unnecessary code.

                                Dim oUserInput As Integer
                                oUserInput = MsgBox("READY TO SHRINKWRAP?", 4)

                                If oUserInput = 7 Then
                                    Exit Sub
                                ElseIf oUserInput = 6 Then
                                     Call createShrinkWrapWithDefinition
                                End If

End Sub

 

0 Likes
Accepted solutions (3)
911 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor
Accepted solution

The only thing I can think of that 'might' act this way, outside of an AddIn, would be calling (showing) a non-modal Form near the beginning of the code, with more code afterwords that is waiting to use the FormResult, to determine what do do next.  If you're using VBA, I am just assuming using a UserForm would act similarly, but I'm not sure.  Dealing with the active 'focus' might be tricky though, if you're planning on trying to manually interact with the model in the middle of this.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

AlexKorzun
Autodesk
Autodesk
Accepted solution

Hi,

 

Please look into https://forums.autodesk.com/t5/inventor-customization/inventor-vba-userform-documentation-or-tutoria.... There is some discussion around VBA vs iLogic forms.

 

If you want, in addition to displaying form itself, to operate on Inventor UI, consider using modeless forms or Inventor dockable windows.

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

0 Likes
Message 4 of 6

ckeveryga
Advocate
Advocate
Accepted solution

This should do what you're looking for. 

 

Private Declare PtrSafe Function MessageBox Lib "User32" Alias "MessageBoxA" (ByVal hWnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long

Sub Main()
Continue = MessageBox(&O0, "This Macro will check for all related document drawings." & _
vbNewLine & vbNewLine & "Do you want to continue?", "Open All Related IDW's?", vbYesNo + vbSystemModal)

If Continue = vbNo Then Exit Sub
End Sub

0 Likes
Message 5 of 6

bwangNYAKX
Contributor
Contributor

Although I need to do some research on how that declaration statement work, but this solves my problem!! THank you!!

0 Likes
Message 6 of 6

_dscholtes_
Advocate
Advocate

@bwangNYAKX Just for info, I can pan, rotate and zoom using my 3d mouse while a message box (or form) is open.

Also opening a form / message box and then go back to operating Inventor is not a very good work flow. It's like asking Word to save your document and then hide the save dialog window so you can correct a typo in your document.

0 Likes