The Down and Dirty Basics of Customizing AutoCAD1 Feb, 1999 By: Lynn Allen
A few issues ago, I covered the ins and outs of Toolbar customization ("Creating Your Own Toolbars [For the Technically Challenged!]," October 1998). That column stopped short of the actual programming behind the macros. I also suggested that you, the reader, email me if you wanted me to take customizing one step further and cover the actual macro programming. And so, I was overwhelmed by a plethora of emails requesting just that! You asked for it; you've got it!
It would take many issues to cover all there is to know about customizing, so I've decided to focus on the information that gives you the biggest bang for your buck. You don't need to be a programmer to do some powerful customizing. Your job is to learn what you want to know; my job is to help you get there! This month we'll cover an overview of the basics before we dive into the actual customizing.
There are many different sections of AutoCAD worthy of customizing. The pulldown menus and toolbars are probably the easiest and most popular. Most of you will start out modifying the ACAD menu file and move onto creating your own menus from scratch-followed by using the powerful partial menuload facility that came out in R13. Let's start by exploring the standard AutoCAD menu file.
With the release of AutoCAD R13, we were inundated with many new filetypes connected with menu files. Release 12 and before had only two menu filetypes we really bothered with-MNU and MNX. The MNU file was the ASCII text file we customized, the MNX file was the compiled version of the file that AutoCAD was reading and using. The MNX file was automatically compiled whenever you edited the MNU, ensuring you were always using the most up-to-date file. The onset of R13 introduced three new filetypes to our repertoire: MNC, MNS and MNR (overwhelmed yet? An example of programmers being paid by the filetype no doubt).
For those of you who've been AutoCADing since R13, you may recall that Autodesk permitted loading both a DOS and a Windows version simultaneously. The DOS menu file and the Windows menu file were very different. Consequently, it was important not to get the two confused because they would only work in their corresponding platform. Hence the birth of the MNC file. The MNC file equates to the MNX file in that it's the compiled version of the MNU file. The MNC file is Windows while the MNX is DOS.
You may also recall that R13 introduced the standard Windows interface for toolbars-a visual interface that was easily customizable because you could create your own icons, assign commands to them, rearrange them as you please and so on. The bitmaps for these toolbars are stored in the MNR file (another compiled file). If you accidentally removed the MNR file from your search path, you were introduced to the friendly smiley faces on your toolbars. Many of you have written to me asking how to rid yourself of these friendly guys and get your toolbar icons back-read on!
With the added flexibility of being able to create your own toolbars came the ability to completely destroy your desktop! It was fairly easy to accidentally send toolbars into oblivion never to be seen again. I can't tell you how many times I'd be moving a toolbar button from one toolbar to another only to accidentally drop it altogether. Autodesk in its infinite wisdom realized that there needed to be a method to restore our desktops, hence the MNS file was created as an insurance marker. All toolbar modifications, additions or subtractions were recorded in the MNS file. If you wanted to restore your original desktop, you would explicitly instruct AutoCAD to load the MNU file.
With this insurance came a price, and a change in the procedure we'd been trained to follow for over a decade. We were taught to modify the MNU file and let AutoCAD automatically compile and create the MNX. This process no longer worked! If we added a new pulldown to our MNU file and reloaded it, AutoCAD would write over the MNS file hence losing our precious custom toolbars. Ouch! To make our lives simple, I suggest customizing the MNS file and staying away from the MNU file altogether. When you have the file setup the way you like, simply copy the MNS file over the MNU file and your custom toolbars will remain safe for life. (Note: always keep a clean copy of the out-of-the-box acad.mnu file safely tucked away in another directory-just in case!)
For the record, the menu extensions were named with the following nomenclature in mind (should you be on AutoCAD Jeopardy):
MNS-Source File (keeper of the custom toolbars)
MNR-Resource file (keeper of the bitmaps)
By the way, if you were to compare the contents of the out-of-the-box MNS file to the MNU file, you wouldn't find much difference. The MNU file has a few more comments in it, but other than that they're pretty much the same.
Well, that was a mouthful, but I feel it's important you realize the difference between all of these filetypes or all of our customizing will be for not. With this background, let's take a look at the inner workings of the acad.mns file.
The Anatomy of a Menu File
Menu files comprise many small sections, using a modular approach. Each section controls a different part of the menu. All sections are delineated with three asterisks in front. Any of the following sections may be found within a valid AutoCAD menu (R13+).
***Buttons1, 2, 3 or 4
***AUX1, 2, 3 or 4
Though the above sections may appear a tad scary, you'll find that the programming syntax remains primarily consistent throughout. Hence, once you've learned the basics you can use it in all of the sections. It would take an entire year to cover every section adequately, so in this series of articles we'll cover the more popular sections: Toolbars, Popups and, my personal favorite, Accelerators. Let's review the different sections and what they're used for.
The pulldown menus are defined in the POP sections. POP0 defines the cursor menu while POP1-15 define the standard pulldowns that reside across the top of the screen. The cursor menu displays when you hit a shift-right click on your input device (or the third button on input devices with more than two buttons). You can have a total of 999 menu items in a standard pulldown menu and 499 menu items in the cursor menu. Of course, it's highly doubtful that your display will accommodate that (Thank God!), so they're truncated to fit the display. It should be noted-and this has got me a couple of times-that you must have at least one standard pulldown menu defined in order to use the cursor menu. In other words, ***POP0 all by itself is worthless and will never display.
Before the world of pulldowns, we relied heavily on the screen menu that displayed on the right side of the screen. At one time, every single AutoCAD command resided in the screen menu (making it quite popular). Though you can still display and use this menu, you'll find it somewhat limited in functionality.
***BUTTONS1-4 and ***AUX1-4
Customizing the buttons on your input device can be a great time-saver. Many of you are using input devices with as many as 25 buttons! This gives you plenty of leeway to set up the buttons in a way that complements your drawing style. Since the first button is always the pick or select button, only the remaining buttons are available for customizing. Hence, if you are using a four-button input device, you have three buttons available for customizing; a 16-button input device has 15 buttons available and so forth.
If you're using a system mouse (which is probably most of you), you'll be customizing the AUX sections. If you're using a tablet (or anything other than a system mouse), you'll be customizing the BUTTONS sections. This, incidentally, used to be the complete opposite in earlier releases. Both types of menus are programmed exactly the same. You will customize the one that works with your particular input device.
Let's assume you're using a tablet with four buttons on the input device. Programming the AUX1 menu determines what happens if you do a simple pick of any of the three customizable buttons. Programming the AUX2 menu determines what happens when you pair a simple pick with the Shift key. The AUX3 menu controls what happens when you hold the Control key down combined with a simple pick. Those of you who are incredibly coordinated can program the AUX4 menu, which controls what occurs when you hold down the Shift key plus the Control key combined with a simple pick. Confused yet? This means that if you have a four-button input device (three customizable buttons) you can assign a total of 12 commands to your buttons. The same is true of the ***Buttons menu. Here's a quick review:
***BUTTONS1: simple pick
***BUTTONS2: pick+ Shift key
***BUTTONS3: pick+ Control key
***BUTTONS4: pick+Control+Shift keys
Figure 1. This is the standard AutoCAD Digitizer Tablet Menu.
Your input devices can be more powerful than you ever imagined!
For those of you with digitizing tablets, you'll want to customize the top section of your menu. This would be TABLET1. The other sections are available for you to modify as well, but most users leave these sections alone. Tablet menus are among the easiest to customize. Figure 1 displays the standard ACAD tablet menu.
This section was added to Release 13 and contains the text information that displays along the status line when you select a menu item (pulldown or toolbar), as shown in Figure 2.
Figure 2. The text information that displays along the status line shown here was added to AutoCAD in Release 13.
You can easily create new toolbars via the user interface, or, if you're masochistic, you can hard code them in the ACAD menu file (I strongly recommend the former). If you're having problems with smiley faces, you might consider touring this section to make sure the bitmap name that's stored in the MNS is in fact the filename you have stored in your SUPPORT directory. Other than that, we'll pretty much steer clear of this section.
Before the new MFC compliant dialog boxes were prevalent, we would create our own dialogs using ICON menus. These files required no LISP expertise to create and were very powerful. Nearly all of the old ICON menus have been replaced with the new more polished looking dialogs, but don't discredit the power of these menus yet! If you've ever wanted to create a dialog box displaying a symbol library, this just might be the ticket for you. You don't need to know DCL, DIESEL or LISP-just some basic menu customizing. Release 13 renamed this section to ***IMAGE to avoid any confusion with the toolbar icons (though ***ICON still
Figure 3. Tiled Viewport Layout is one of the few remaining image menus in R14.
My personal favorite! This section is used to define the keys on your keyboard. You can assign AutoCAD commands to the Function Keys, Control-key combinations, Shift-key combinations, the arrow keys, Insert, Delete and Escape as well as the Number pad keys. Just imagine how dangerous you could become! All that power in one little unknown section. This will definitely be a topic covered in an upcoming column.
This one opens a huge can of worms. It's used in partial menu loading as well as disabling/enabling individual menu commands. It's essential but somewhat difficult to comprehend. It also requires a fairly in-depth understanding of customization to understand its full benefits.
All of this builds the basic foundation needed for customization. Next month, we'll dive into the actual programming codes and start you down the road to maximum productivity! Until then...
In her easy-to-follow, friendly style, long-time Cadalyst contributing editor Lynn Allen guides you through a new feature or time-saving trick in every episode of her popular AutoCAD Video Tips. Subscribe to the free Cadalyst Video Picks newsletter, and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!