Home page

Our next meeting will be held on Thursday, July 17, 2008.

For more information (such as meeting topics or directions) please click the Calendar link above.

Eastern Virginia AutoCAD Users' Group
EVAUG information Upcoming events Become a member! EVAUG officer profiles More EVAUG content
Resources Past meeting minutes Tutorial Gallery - pictures of EVAUG events Local employment opportunities

Custom Menus

Custom menu files contain menus, toolbars, image tiles, keyboard shortcuts, and more things I never used, all of which allow you to issue a string of AutoCAD commands using an interface within AutoCAD. You set 'em up once & then click a menu or button and get a bunch of things done at once.

The file itself is just a text file with a .mnu extension. You create a MENUGROUP within this file that can contain menus, toolbars, etc. Generally, each line contains a menu item, toolbar, etc. followed by the CAD commands and arguments. The commands have to fit on one line, but you cram as many as you like in the line.

Basic Menu

The menu file starts with a MENUGROUP which provides a name for the group when you import it into AutoCAD. You can provide multiple menus in one file.

The ***POP# syntax starts each menu. POP1 thru POP16 are for defining the main menus (check your acad.mnu file in the SUPPORT directory for the definitions - and to see some real good examples of how menus are done) & POP17 thru POP500 are available for inserting extra menus using the MENULOAD command (see below).

Menu items have:

  • an optional ID (used to programmatically reference the item)
  • a name which is displayed on the menu in [brackets]
  • the commands & arguments that are issued when the menu is selected.

***MENUGROUP=Common
***POP17
Item_0_ID [&Common Stuff]
Item_1_ID [->&Layers]
Item_1a_ID [&Circuit Layer]^C^C-layer;Make;E-Circ;Color;114;;;
Item_1b_ID [Circuit &Arc]^C^C-layer;Make;E-Circ;Color;114;;;ARC;
Item_1c_ID [<-&Power Layer]^C^C-layer;Make;E-Powr;Color;5;;;
Item_2_ID [&Receptacle]*^C^C-insert;Receptacle;Scale;(getvar "DIMSCALE");\\

Menu Specifics

Menus have the ability to create cascading menus (sub-menus) built into the menu item names. As you can see in the example above, the first menu item named "Layers" has "->" in front of it, which makes Layers a popup menu item. The popup menu contains the next few items up to and including the item which is preceded with "<-". The above example would show up like this:

Example of menu opened

Use another "->" character sequence in a submenu item to create a subsubmenu. Just remember to always balance each "->" with a "<-"... or prepare for your flogging. Yes, AutoCAD is programmed to flog improper customizers.

The & in the menu item name specifies the keyboard access shortcut that can be used to issue the command using the ALT button. From the example above, a user could press ALT-L-A to create a circuit arc.

Toolbars

***TOOLBARS
** GENERAL_TOOLS
Item_01_ID [_Toolbar("General Tools", _Top, _Show, 3, 1, 1)]
Item_1A_ID [_Button("Circuit Layer", "1A.bmp", "1A.bmp")]^C^C-layer;Make;E-Circ;Color;114;;;
Item_2A_ID [_Button("Power Layer", "2A.bmp", "2A.bmp"]^C^C-layer;Make;E-Powr;Color;5;;;
Item_3A_ID [_Button("Receptacle", "3A.bmp", "3A.bmp"]*^C^C-insert;Receptacle;Scale;(getvar "DIMSCALE");\\

Toolbars accomplish the same task as menus, but with an interface that consists of buttons with pictures. Instead of creating a popup menu that is attached to the main menubar at the top of the AutoCAD window, you create floating toolbars with buttons that issue commands. You can even create a flyout button that contains another toolbar, much like a submenu. There are even common controls you can add to a toolbar, such as the current layer or color controls.

The toolbar section begins with the ***TOOLBARS keyword in your file. From there you can define toolbars using the _Toolbar keyword and then create buttons to be displayed in the toolbar using the _Button keyword.

In the example above, **GENERAL_TOOLS is the alias name for the next toolbar definition. This can be used to refer to the toolbar when using flyout buttons as described below.

Each toolbar item has the following bits to it:

  • an optional ID (used to programmatically reference the item)... the rest of the items are contained within brackets []
  • Either the _Toolbar or _Button keyword, depending on whether you're defining a button or toolbar. The items that define the toolbar or button follow and are contained in parenthesis ():
    • For a toolbar definition supply the following:
      • Name: This is displayed on the toolbar when it's floating and in the toolbar Customize dialog. Double quotes are needed if you include any spaces in the name & are probably a good idea in any case.

Example of toolbar displayed

The AutoCAD Customize dialog

      • Orientation: Describes the default configuration of the toolbar, which includes which side it should dock on and whether it's floating or docked. Once it's loaded, the user can control how it is docked and AutoCAD will save that setting. The options are: _Floating, _Top, _Bottom, _Left, or _Right.
      • Visibility: _Show or _Hide
      • X coordinate: the number of pixels from the left the toolbar is initially placed (every time the menu file is loaded).
      • Y coordinate: the number of pixels from the top the toolbar is initially placed (every time the menu file is loaded).
      • Rows: the number of rows of buttons the toolbar has. It's probably best to stick with one.
    • For buttons, provide the following:
      • Name. This text appears as a tooltip when the user hovers over the button with the mouse. Use double quotes around this one.
      • Small image: the name and path, if needed- see Getting Around Paths below, of a small bitmap or gif file to display in the button. The size should be 16 pixels wide by 15 high. This image is used by default. The large image file is used if the user opts to use large buttons.
      • Large image: the name (and path if not the image is not located in the AutoCAD search path) of a 32x30 pixel bitmap or gif file.
      • Finally, after closing the parenthesis and brackets )], provide the commands and options you want issued to the command line when the button is pressed.

Toolbar Flyouts

Flyouts are buttons that display another toolbar when you click them... the nested toolbar "flies out" of the button like a scene from Aliens (at least it would if the Autodesk programmers would take my suggestions).

In your menu file, flyouts have the same items as buttons with a few extra for that flyout action. Here's a list:

  • Name
  • Small image
  • Large image
  • Icon: there are two options
    • _OwnIcon - use this to always display the image you list in this item. The user must click the flyout button and then select a button from the flyout toolbar.
    • _OtherIcon - use this to display the image of the button that was last used from those in the flyout. This way the user can just click the flyout button to use the most recent button. Note that this causes the appearance of the toolbar to change, which can confuse users until they get used to it.
  • Alias: the name of the toolbar that will do the flying out. It's the optional name preceded by ** on the line before the toolbar definition.
  • Apparently you can also add commands to run when the button is pressed, but I haven't tried that out.

Loading Menu Files Into AutoCAD

Use the MENULOAD command to load a menu file. In the Load Menu dialog, you can find your menu file, and then insert each popup menu into the menubar.

The Menu Groups tab of the Menu Customization dialog

In order to use any menus, toolbars, etc., you have to load the menu group's file. Click the Browse button and located the file. You can load the .mnu, .mns, or .mnc files. Then press the load button to actually load it. You can also select a menu group from the list and click Unload to remove the group from the AutoCAD interface. You'll need to do this to reload menu groups.

Switch to the Menu Bar tab to insert your custom menus into the AutoCAD menu bar.

The Menu Bar tab of the Menu Customization dialog

Select your menu group from the pulldown at the top. This causes the list on the left to display all the menus defined in your menu file. The list on the left shows all the menus that are currently loaded into AutoCAD. Select your menu you wish to insert on the left and then the menu you want to insert your menu in front of.

See Also

In the AutoCAD help, see the "The Menu File" under the "Customization Guide", for more help than you really want.