Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Non-Modal Message Box/Input Box

Status
Not open for further replies.

handleman

Automotive
Jan 7, 2005
3,411
For those of you who write VBA macros, here are a couple of quick user forms I made as substitutes for MsgBox and InputBox. They are not intended to replace every use of MsgBox and InputBox, they are only for use when your user might want to interact with the model before continuing with the macro. I wrote them for the mating macros I've posted here in the past, because sometimes adding a mate moves the part/assembly out of the current field of view. When the macro uses a MsgBox to prompt the user to accept/flip alignment, the user can't rotate/pan/zoom the model to check it. It could also be used to prompt the user to select certain features/entities prior to continuing.

These user forms are designed to be easily used in existing code as an almost direct syntactical replacement for the vbYesNo type message box and the InputBox. Of course, they are not as flexible (especially the YesNoBox) as far as options go, but once imported into a macro the form can be changed if desired.

Pausing code execution is handled by the form, so no additional coding is needed in the main macro. It uses a loop with DoEvents, so you won't want to use it in a situation where you have the box open for a long time.

Enjoy!

-handleman, CSWP (The new, easy test)
 
I've had to do this for previous projects. It's definitely a good thing to have in your toolbox. Btw, your mating macros are very handy. So handy in fact that I took your original 3 (coincident, concentric, parallel) and added distance, angle, perendicular, and tangent. I also centralized the code so there's only one main function and .swp file. The modified version is posted on 3DContentCentral.

 
handleman, where are your original mating macros?
 
You can get to 'em via thread559-202450. However, if I'll go ahead and post what I'm currently using, which includes the YesBox and InBox from the first post. I've actually added some functionality so that you can add either sketch relations or mates with the same macro. This essentially lets you use the same hotkey to create sketch relations and mates. The macro starts out by looking to see if a sketch is active. If there is a sketch active, it attempts to add the type of sketch relation corresponding to the mate type (coincident, parallel, or concentric) the macro was originally written for. Of course, the distance mate macro doesn't include this because a distance sketch relation is a dimension. If there is no sketch active, the original mating functionality is used.

Of course, these could (should?) all probably be condensed down into one macro as noted above. I just haven't managed to do it yet. :)

-handleman, CSWP (The new, easy test)
 
 http://files.engineering.com/getfile.aspx?folder=59404b9c-229b-4843-96b3-c560eb81ef56&file=InsertMateMacros.zip
A combined sketch relation and mating hotkey would definitely be useful. It would also be a lot easier to remember than the managerie of hotkeys I have now. Ideally, I would never have to remember a shortcut that starts with Ctl+Shift or Ctl+Alt :) As far as combining multiple macros goes, the sooner you do it the easier modifying the macro(s) will be. You'd have to add a couple if's in order to handle the distance and angle mates, but once it's done editing all the code using one function pays for itself in saved time.
 
Handleman,
That's one hell of an algorithm you've got there for getting the initial mating distance. How long did it take you to work that out? Or was it in a SW example somewhere? I does an excellent job of replicating the distance calculation done by SW itself.
 
takedownca,
For using Hotkeys...I got a mouse with a couple programmable buttons (Logitech MX5?? or MX6??) and programmed on of the keys to be [Shift]+[Ctrl]...so now I hold that button down with my mouse thumb and have an entire keyboard of available single-key HotKeys.
Ken
 
takedownca said:
How long did it take you to work that out?

Probably way too long. It's been a while, but I would say probably 3-4 hours altogether. It was one of those things where you get an idea of how to do something, and you think it'll work, and it almost does, but you have to keep adding tweaks and intermediate steps (all those part-to-assembly transforms, for example) until after a while you have a big ol' ugly section of code that mostly works. :)

-handleman, CSWP (The new, easy test)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor