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.
Solved! Go to Solution.
Solved by ckeveryga. Go to Solution.
Solved by AlexKorzun. Go to Solution.
Solved by WCrihfield. Go to 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
(Not an Autodesk Employee)
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.
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
Although I need to do some research on how that declaration statement work, but this solves my problem!! THank you!!
@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.
Can't find what you're looking for? Ask the community or share your knowledge.